diff options
Diffstat (limited to 'ios/chrome/browser')
5 files changed, 121 insertions, 0 deletions
diff --git a/ios/chrome/browser/application_context.h b/ios/chrome/browser/application_context.h index db856c6..9cf30da 100644 --- a/ios/chrome/browser/application_context.h +++ b/ios/chrome/browser/application_context.h @@ -25,6 +25,10 @@ namespace net_log { class ChromeNetLog; } +namespace network_time { +class NetworkTimeTracker; +} + namespace policy { class BrowserPolicyConnector; } @@ -68,6 +72,9 @@ class ApplicationContext { // Gets the ChromeNetLog. virtual net_log::ChromeNetLog* GetNetLog() = 0; + // Gets the NetworkTimeTracker. + virtual network_time::NetworkTimeTracker* GetNetworkTimeTracker() = 0; + protected: // Sets the global ApplicationContext instance. static void SetApplicationContext(ApplicationContext* context); diff --git a/ios/chrome/browser/application_context_impl.cc b/ios/chrome/browser/application_context_impl.cc index 8b3eec7..5946416 100644 --- a/ios/chrome/browser/application_context_impl.cc +++ b/ios/chrome/browser/application_context_impl.cc @@ -7,7 +7,9 @@ #include "base/command_line.h" #include "base/files/file_path.h" #include "base/logging.h" +#include "base/time/default_tick_clock.h" #include "components/net_log/chrome_net_log.h" +#include "components/network_time/network_time_tracker.h" #include "components/translate/core/browser/translate_download_manager.h" #include "ios/chrome/common/channel_info.h" #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" @@ -54,22 +56,37 @@ void ApplicationContextImpl::SetApplicationLocale(const std::string& locale) { ios::ChromeBrowserStateManager* ApplicationContextImpl::GetChromeBrowserStateManager() { + DCHECK(thread_checker_.CalledOnValidThread()); return ios::GetChromeBrowserProvider()->GetChromeBrowserStateManager(); } metrics::MetricsService* ApplicationContextImpl::GetMetricsService() { + DCHECK(thread_checker_.CalledOnValidThread()); return ios::GetChromeBrowserProvider()->GetMetricsService(); } policy::BrowserPolicyConnector* ApplicationContextImpl::GetBrowserPolicyConnector() { + DCHECK(thread_checker_.CalledOnValidThread()); return ios::GetChromeBrowserProvider()->GetBrowserPolicyConnector(); } rappor::RapporService* ApplicationContextImpl::GetRapporService() { + DCHECK(thread_checker_.CalledOnValidThread()); return ios::GetChromeBrowserProvider()->GetRapporService(); } net_log::ChromeNetLog* ApplicationContextImpl::GetNetLog() { + DCHECK(thread_checker_.CalledOnValidThread()); return net_log_.get(); } + +network_time::NetworkTimeTracker* +ApplicationContextImpl::GetNetworkTimeTracker() { + DCHECK(thread_checker_.CalledOnValidThread()); + if (!network_time_tracker_) { + network_time_tracker_.reset(new network_time::NetworkTimeTracker( + make_scoped_ptr(new base::DefaultTickClock), GetLocalState())); + } + return network_time_tracker_.get(); +} diff --git a/ios/chrome/browser/application_context_impl.h b/ios/chrome/browser/application_context_impl.h index dd7e0a1..162954a 100644 --- a/ios/chrome/browser/application_context_impl.h +++ b/ios/chrome/browser/application_context_impl.h @@ -34,9 +34,11 @@ class ApplicationContextImpl : public ApplicationContext { policy::BrowserPolicyConnector* GetBrowserPolicyConnector() override; rappor::RapporService* GetRapporService() override; net_log::ChromeNetLog* GetNetLog() override; + network_time::NetworkTimeTracker* GetNetworkTimeTracker() override; base::ThreadChecker thread_checker_; scoped_ptr<net_log::ChromeNetLog> net_log_; + scoped_ptr<network_time::NetworkTimeTracker> network_time_tracker_; std::string application_locale_; DISALLOW_COPY_AND_ASSIGN(ApplicationContextImpl); 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_ |