summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/variations
diff options
context:
space:
mode:
Diffstat (limited to 'ios/chrome/browser/variations')
-rw-r--r--ios/chrome/browser/variations/ios_chrome_variations_service_client.cc62
-rw-r--r--ios/chrome/browser/variations/ios_chrome_variations_service_client.h33
2 files changed, 95 insertions, 0 deletions
diff --git a/ios/chrome/browser/variations/ios_chrome_variations_service_client.cc b/ios/chrome/browser/variations/ios_chrome_variations_service_client.cc
new file mode 100644
index 0000000..066d53e
--- /dev/null
+++ b/ios/chrome/browser/variations/ios_chrome_variations_service_client.cc
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/chrome/browser/variations/ios_chrome_variations_service_client.h"
+
+#include "base/bind.h"
+#include "base/version.h"
+#include "components/version_info/version_info.h"
+#include "ios/chrome/browser/application_context.h"
+#include "ios/chrome/common/channel_info.h"
+#include "ios/web/public/web_thread.h"
+
+namespace {
+
+// Gets the version number to use for variations seed simulation. Must be called
+// on a thread where IO is allowed.
+base::Version GetVersionForSimulation() {
+ // TODO(asvitkine): Get the version that will be used on restart instead of
+ // the current version.
+ return base::Version(version_info::GetVersionNumber());
+}
+
+} // namespace
+
+IOSChromeVariationsServiceClient::IOSChromeVariationsServiceClient() {}
+
+IOSChromeVariationsServiceClient::~IOSChromeVariationsServiceClient() {}
+
+std::string IOSChromeVariationsServiceClient::GetApplicationLocale() {
+ return GetApplicationContext()->GetApplicationLocale();
+}
+
+base::SequencedWorkerPool* IOSChromeVariationsServiceClient::GetBlockingPool() {
+ return web::WebThread::GetBlockingPool();
+}
+
+base::Callback<base::Version()>
+IOSChromeVariationsServiceClient::GetVersionForSimulationCallback() {
+ return base::Bind(&GetVersionForSimulation);
+}
+
+net::URLRequestContextGetter*
+IOSChromeVariationsServiceClient::GetURLRequestContext() {
+ return GetApplicationContext()->GetSystemURLRequestContext();
+}
+
+network_time::NetworkTimeTracker*
+IOSChromeVariationsServiceClient::GetNetworkTimeTracker() {
+ return GetApplicationContext()->GetNetworkTimeTracker();
+}
+
+version_info::Channel IOSChromeVariationsServiceClient::GetChannel() {
+ return ::GetChannel();
+}
+
+bool IOSChromeVariationsServiceClient::OverridesRestrictParameter(
+ std::string* parameter) {
+ return false;
+}
+
+void IOSChromeVariationsServiceClient::OnInitialStartup() {}
diff --git a/ios/chrome/browser/variations/ios_chrome_variations_service_client.h b/ios/chrome/browser/variations/ios_chrome_variations_service_client.h
new file mode 100644
index 0000000..6be4a28
--- /dev/null
+++ b/ios/chrome/browser/variations/ios_chrome_variations_service_client.h
@@ -0,0 +1,33 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_BROWSER_VARIATIONS_IOS_CHROME_VARIATIONS_SERVICE_CLIENT_H_
+#define IOS_CHROME_BROWSER_VARIATIONS_IOS_CHROME_VARIATIONS_SERVICE_CLIENT_H_
+
+#include "base/macros.h"
+#include "components/variations/service/variations_service_client.h"
+
+// IOSChromeVariationsServiceClient provides an implementation of
+// VariationsServiceClient that depends on ios/chrome/.
+class IOSChromeVariationsServiceClient
+ : public variations::VariationsServiceClient {
+ public:
+ IOSChromeVariationsServiceClient();
+ ~IOSChromeVariationsServiceClient() override;
+
+ private:
+ // variations::VariationsServiceClient implementation.
+ std::string GetApplicationLocale() override;
+ base::SequencedWorkerPool* GetBlockingPool() override;
+ base::Callback<base::Version()> GetVersionForSimulationCallback() override;
+ net::URLRequestContextGetter* GetURLRequestContext() override;
+ network_time::NetworkTimeTracker* GetNetworkTimeTracker() override;
+ version_info::Channel GetChannel() override;
+ bool OverridesRestrictParameter(std::string* parameter) override;
+ void OnInitialStartup() override;
+
+ DISALLOW_COPY_AND_ASSIGN(IOSChromeVariationsServiceClient);
+};
+
+#endif // IOS_CHROME_BROWSER_VARIATIONS_IOS_CHROME_VARIATIONS_SERVICE_CLIENT_H_