OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ios/chrome/browser/component_updater/ios_component_updater_configurato
r.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/threading/sequenced_worker_pool.h" |
| 10 #include "base/version.h" |
| 11 #include "components/component_updater/configurator_impl.h" |
| 12 #include "components/update_client/component_patcher_operation.h" |
| 13 #include "ios/chrome/browser/application_context.h" |
| 14 #include "ios/chrome/common/channel_info.h" |
| 15 #include "ios/web/public/web_thread.h" |
| 16 |
| 17 namespace component_updater { |
| 18 |
| 19 namespace { |
| 20 |
| 21 class IOSConfigurator : public update_client::Configurator { |
| 22 public: |
| 23 IOSConfigurator(const base::CommandLine* cmdline, |
| 24 net::URLRequestContextGetter* url_request_getter); |
| 25 |
| 26 // update_client::Configurator overrides. |
| 27 int InitialDelay() const override; |
| 28 int NextCheckDelay() const override; |
| 29 int StepDelay() const override; |
| 30 int OnDemandDelay() const override; |
| 31 int UpdateDelay() const override; |
| 32 std::vector<GURL> UpdateUrl() const override; |
| 33 std::vector<GURL> PingUrl() const override; |
| 34 base::Version GetBrowserVersion() const override; |
| 35 std::string GetChannel() const override; |
| 36 std::string GetLang() const override; |
| 37 std::string GetOSLongName() const override; |
| 38 std::string ExtraRequestParams() const override; |
| 39 net::URLRequestContextGetter* RequestContext() const override; |
| 40 scoped_refptr<update_client::OutOfProcessPatcher> CreateOutOfProcessPatcher() |
| 41 const override; |
| 42 bool DeltasEnabled() const override; |
| 43 bool UseBackgroundDownloader() const override; |
| 44 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() |
| 45 const override; |
| 46 scoped_refptr<base::SingleThreadTaskRunner> GetSingleThreadTaskRunner() |
| 47 const override; |
| 48 |
| 49 private: |
| 50 friend class base::RefCountedThreadSafe<IOSConfigurator>; |
| 51 |
| 52 ConfiguratorImpl configurator_impl_; |
| 53 |
| 54 ~IOSConfigurator() override {} |
| 55 }; |
| 56 |
| 57 IOSConfigurator::IOSConfigurator( |
| 58 const base::CommandLine* cmdline, |
| 59 net::URLRequestContextGetter* url_request_getter) |
| 60 : configurator_impl_(cmdline, url_request_getter) {} |
| 61 |
| 62 int IOSConfigurator::InitialDelay() const { |
| 63 return configurator_impl_.InitialDelay(); |
| 64 } |
| 65 |
| 66 int IOSConfigurator::NextCheckDelay() const { |
| 67 return configurator_impl_.NextCheckDelay(); |
| 68 } |
| 69 |
| 70 int IOSConfigurator::StepDelay() const { |
| 71 return configurator_impl_.StepDelay(); |
| 72 } |
| 73 |
| 74 int IOSConfigurator::OnDemandDelay() const { |
| 75 return configurator_impl_.OnDemandDelay(); |
| 76 } |
| 77 |
| 78 int IOSConfigurator::UpdateDelay() const { |
| 79 return configurator_impl_.UpdateDelay(); |
| 80 } |
| 81 |
| 82 std::vector<GURL> IOSConfigurator::UpdateUrl() const { |
| 83 return configurator_impl_.UpdateUrl(); |
| 84 } |
| 85 |
| 86 std::vector<GURL> IOSConfigurator::PingUrl() const { |
| 87 return configurator_impl_.PingUrl(); |
| 88 } |
| 89 |
| 90 base::Version IOSConfigurator::GetBrowserVersion() const { |
| 91 return configurator_impl_.GetBrowserVersion(); |
| 92 } |
| 93 |
| 94 std::string IOSConfigurator::GetChannel() const { |
| 95 return GetChannelString(); |
| 96 } |
| 97 |
| 98 std::string IOSConfigurator::GetLang() const { |
| 99 return GetApplicationContext()->GetApplicationLocale(); |
| 100 } |
| 101 |
| 102 std::string IOSConfigurator::GetOSLongName() const { |
| 103 return configurator_impl_.GetOSLongName(); |
| 104 } |
| 105 |
| 106 std::string IOSConfigurator::ExtraRequestParams() const { |
| 107 return configurator_impl_.ExtraRequestParams(); |
| 108 } |
| 109 |
| 110 net::URLRequestContextGetter* IOSConfigurator::RequestContext() const { |
| 111 return configurator_impl_.RequestContext(); |
| 112 } |
| 113 |
| 114 scoped_refptr<update_client::OutOfProcessPatcher> |
| 115 IOSConfigurator::CreateOutOfProcessPatcher() const { |
| 116 return nullptr; |
| 117 } |
| 118 |
| 119 bool IOSConfigurator::DeltasEnabled() const { |
| 120 return configurator_impl_.DeltasEnabled(); |
| 121 } |
| 122 |
| 123 bool IOSConfigurator::UseBackgroundDownloader() const { |
| 124 return configurator_impl_.UseBackgroundDownloader(); |
| 125 } |
| 126 |
| 127 scoped_refptr<base::SequencedTaskRunner> |
| 128 IOSConfigurator::GetSequencedTaskRunner() const { |
| 129 return web::WebThread::GetBlockingPool() |
| 130 ->GetSequencedTaskRunnerWithShutdownBehavior( |
| 131 web::WebThread::GetBlockingPool()->GetSequenceToken(), |
| 132 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 133 } |
| 134 |
| 135 scoped_refptr<base::SingleThreadTaskRunner> |
| 136 IOSConfigurator::GetSingleThreadTaskRunner() const { |
| 137 return web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE); |
| 138 } |
| 139 |
| 140 } // namespace |
| 141 |
| 142 scoped_refptr<update_client::Configurator> MakeIOSComponentUpdaterConfigurator( |
| 143 const base::CommandLine* cmdline, |
| 144 net::URLRequestContextGetter* context_getter) { |
| 145 return new IOSConfigurator(cmdline, context_getter); |
| 146 } |
| 147 |
| 148 } // namespace component_updater |
OLD | NEW |