Chromium Code Reviews| Index: ios/chrome/browser/component_updater/component_updater_configurator.cc |
| diff --git a/ios/chrome/browser/component_updater/component_updater_configurator.cc b/ios/chrome/browser/component_updater/component_updater_configurator.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3b18fdbaaf5abd9808a54a5954030c41c8eaff9f |
| --- /dev/null |
| +++ b/ios/chrome/browser/component_updater/component_updater_configurator.cc |
| @@ -0,0 +1,149 @@ |
| +// 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/component_updater/component_updater_configurator.h" |
| + |
| +#include <string> |
| + |
| +#include "base/threading/sequenced_worker_pool.h" |
| +#include "components/component_updater/configurator_impl.h" |
| +#include "components/update_client/component_patcher_operation.h" |
| +#include "components/update_client/update_query_params_delegate.h" |
| +#include "ios/chrome/browser/application_context.h" |
| +#include "ios/chrome/common/channel_info.h" |
| +#include "ios/web/public/web_thread.h" |
| + |
| +namespace component_updater { |
| + |
| +namespace { |
| + |
| +class ChromeConfigurator : public update_client::Configurator { |
| + public: |
| + ChromeConfigurator(const base::CommandLine* cmdline, |
| + net::URLRequestContextGetter* url_request_getter); |
| + |
| + // update_client::Configurator: |
|
Sorin Jianu
2015/08/12 02:27:51
update_client::Configurator overrides.
droger
2015/08/12 08:43:41
Done.
|
| + int InitialDelay() const override; |
| + int NextCheckDelay() const override; |
| + int StepDelay() const override; |
| + int OnDemandDelay() const override; |
| + int UpdateDelay() const override; |
| + std::vector<GURL> UpdateUrl() const override; |
| + std::vector<GURL> PingUrl() const override; |
| + base::Version GetBrowserVersion() const override; |
| + std::string GetChannel() const override; |
| + std::string GetLang() const override; |
| + std::string GetOSLongName() const override; |
| + std::string ExtraRequestParams() const override; |
| + net::URLRequestContextGetter* RequestContext() const override; |
| + scoped_refptr<update_client::OutOfProcessPatcher> CreateOutOfProcessPatcher() |
| + const override; |
| + bool DeltasEnabled() const override; |
| + bool UseBackgroundDownloader() const override; |
| + scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() |
| + const override; |
| + scoped_refptr<base::SingleThreadTaskRunner> GetSingleThreadTaskRunner() |
| + const override; |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<ChromeConfigurator>; |
| + |
| + ConfiguratorImpl configurator_impl_; |
| + |
| + ~ChromeConfigurator() override {} |
| +}; |
| + |
| +ChromeConfigurator::ChromeConfigurator( |
| + const base::CommandLine* cmdline, |
| + net::URLRequestContextGetter* url_request_getter) |
| + : configurator_impl_(cmdline, url_request_getter) {} |
| + |
| +int ChromeConfigurator::InitialDelay() const { |
| + return configurator_impl_.InitialDelay(); |
| +} |
| + |
| +int ChromeConfigurator::NextCheckDelay() const { |
| + return configurator_impl_.NextCheckDelay(); |
| +} |
| + |
| +int ChromeConfigurator::StepDelay() const { |
| + return configurator_impl_.StepDelay(); |
| +} |
| + |
| +int ChromeConfigurator::OnDemandDelay() const { |
| + return configurator_impl_.OnDemandDelay(); |
| +} |
| + |
| +int ChromeConfigurator::UpdateDelay() const { |
| + return configurator_impl_.UpdateDelay(); |
| +} |
| + |
| +std::vector<GURL> ChromeConfigurator::UpdateUrl() const { |
| + return configurator_impl_.UpdateUrl(); |
| +} |
| + |
| +std::vector<GURL> ChromeConfigurator::PingUrl() const { |
| + return configurator_impl_.PingUrl(); |
| +} |
| + |
| +base::Version ChromeConfigurator::GetBrowserVersion() const { |
| + return configurator_impl_.GetBrowserVersion(); |
| +} |
| + |
| +std::string ChromeConfigurator::GetChannel() const { |
| + return update_client::UpdateQueryParamsDelegate::GetChannelStringHelper( |
| + ::GetChannel()); |
| +} |
| + |
| +std::string ChromeConfigurator::GetLang() const { |
| + return GetApplicationContext()->GetApplicationLocale(); |
|
Sorin Jianu
2015/08/12 02:27:51
In the future, would it be possible to get a compo
droger
2015/08/12 08:43:41
You are right.
It would be possible to componentiz
|
| +} |
| + |
| +std::string ChromeConfigurator::GetOSLongName() const { |
| + return configurator_impl_.GetOSLongName(); |
| +} |
| + |
| +std::string ChromeConfigurator::ExtraRequestParams() const { |
| + return configurator_impl_.ExtraRequestParams(); |
| +} |
| + |
| +net::URLRequestContextGetter* ChromeConfigurator::RequestContext() const { |
| + return configurator_impl_.RequestContext(); |
| +} |
| + |
| +scoped_refptr<update_client::OutOfProcessPatcher> |
| +ChromeConfigurator::CreateOutOfProcessPatcher() const { |
| + return nullptr; |
| +} |
| + |
| +bool ChromeConfigurator::DeltasEnabled() const { |
| + return configurator_impl_.DeltasEnabled(); |
| +} |
| + |
| +bool ChromeConfigurator::UseBackgroundDownloader() const { |
| + return configurator_impl_.UseBackgroundDownloader(); |
| +} |
| + |
| +scoped_refptr<base::SequencedTaskRunner> |
| +ChromeConfigurator::GetSequencedTaskRunner() const { |
| + return web::WebThread::GetBlockingPool() |
| + ->GetSequencedTaskRunnerWithShutdownBehavior( |
| + web::WebThread::GetBlockingPool()->GetSequenceToken(), |
| + base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| +} |
| + |
| +scoped_refptr<base::SingleThreadTaskRunner> |
| +ChromeConfigurator::GetSingleThreadTaskRunner() const { |
| + return web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE); |
| +} |
| + |
| +} // namespace |
| + |
| +scoped_refptr<update_client::Configurator> MakeComponentUpdaterConfigurator( |
| + const base::CommandLine* cmdline, |
| + net::URLRequestContextGetter* context_getter) { |
| + return new ChromeConfigurator(cmdline, context_getter); |
| +} |
| + |
| +} // namespace component_updater |