1 // Copyright 2014 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.
5 #include "chrome/browser/component_updater/chrome_component_updater_configurator.h"
9 #include "base/threading/sequenced_worker_pool.h"
10 #include "base/version.h"
11 #include "chrome/browser/component_updater/component_patcher_operation_out_of_process.h"
12 #include "chrome/browser/update_client/chrome_update_query_params_delegate.h"
13 #include "chrome/common/channel_info.h"
14 #include "components/component_updater/configurator_impl.h"
15 #include "content/public/browser/browser_thread.h"
17 namespace component_updater
{
21 class ChromeConfigurator
: public update_client::Configurator
{
23 ChromeConfigurator(const base::CommandLine
* cmdline
,
24 net::URLRequestContextGetter
* url_request_getter
);
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()
42 bool DeltasEnabled() const override
;
43 bool UseBackgroundDownloader() const override
;
44 scoped_refptr
<base::SequencedTaskRunner
> GetSequencedTaskRunner()
46 scoped_refptr
<base::SingleThreadTaskRunner
> GetSingleThreadTaskRunner()
50 friend class base::RefCountedThreadSafe
<ChromeConfigurator
>;
52 ConfiguratorImpl configurator_impl_
;
54 ~ChromeConfigurator() override
{}
57 ChromeConfigurator::ChromeConfigurator(
58 const base::CommandLine
* cmdline
,
59 net::URLRequestContextGetter
* url_request_getter
)
60 : configurator_impl_(cmdline
, url_request_getter
) {}
62 int ChromeConfigurator::InitialDelay() const {
63 return configurator_impl_
.InitialDelay();
66 int ChromeConfigurator::NextCheckDelay() const {
67 return configurator_impl_
.NextCheckDelay();
70 int ChromeConfigurator::StepDelay() const {
71 return configurator_impl_
.StepDelay();
74 int ChromeConfigurator::OnDemandDelay() const {
75 return configurator_impl_
.OnDemandDelay();
78 int ChromeConfigurator::UpdateDelay() const {
79 return configurator_impl_
.UpdateDelay();
82 std::vector
<GURL
> ChromeConfigurator::UpdateUrl() const {
83 return configurator_impl_
.UpdateUrl();
86 std::vector
<GURL
> ChromeConfigurator::PingUrl() const {
87 return configurator_impl_
.PingUrl();
90 base::Version
ChromeConfigurator::GetBrowserVersion() const {
91 return configurator_impl_
.GetBrowserVersion();
94 std::string
ChromeConfigurator::GetChannel() const {
95 return chrome::GetChannelString();
98 std::string
ChromeConfigurator::GetLang() const {
99 return ChromeUpdateQueryParamsDelegate::GetLang();
102 std::string
ChromeConfigurator::GetOSLongName() const {
103 return configurator_impl_
.GetOSLongName();
106 std::string
ChromeConfigurator::ExtraRequestParams() const {
107 return configurator_impl_
.ExtraRequestParams();
110 net::URLRequestContextGetter
* ChromeConfigurator::RequestContext() const {
111 return configurator_impl_
.RequestContext();
114 scoped_refptr
<update_client::OutOfProcessPatcher
>
115 ChromeConfigurator::CreateOutOfProcessPatcher() const {
116 return make_scoped_refptr(new ChromeOutOfProcessPatcher
);
119 bool ChromeConfigurator::DeltasEnabled() const {
120 return configurator_impl_
.DeltasEnabled();
123 bool ChromeConfigurator::UseBackgroundDownloader() const {
124 return configurator_impl_
.UseBackgroundDownloader();
127 scoped_refptr
<base::SequencedTaskRunner
>
128 ChromeConfigurator::GetSequencedTaskRunner() const {
129 return content::BrowserThread::GetBlockingPool()
130 ->GetSequencedTaskRunnerWithShutdownBehavior(
131 content::BrowserThread::GetBlockingPool()->GetSequenceToken(),
132 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN
);
135 scoped_refptr
<base::SingleThreadTaskRunner
>
136 ChromeConfigurator::GetSingleThreadTaskRunner() const {
137 return content::BrowserThread::GetMessageLoopProxyForThread(
138 content::BrowserThread::FILE);
143 scoped_refptr
<update_client::Configurator
>
144 MakeChromeComponentUpdaterConfigurator(
145 const base::CommandLine
* cmdline
,
146 net::URLRequestContextGetter
* context_getter
) {
147 return new ChromeConfigurator(cmdline
, context_getter
);
150 } // namespace component_updater