Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: chrome/browser/component_updater/chrome_component_updater_configurator.cc

Issue 2240263004: Allow injecting a PrefService into ChromeComponentUpdaterConfigurator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/component_updater/chrome_component_updater_configurator .h" 5 #include "chrome/browser/component_updater/chrome_component_updater_configurator .h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 14 matching lines...) Expand all
25 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
26 #include "content/public/browser/browser_thread.h" 26 #include "content/public/browser/browser_thread.h"
27 27
28 namespace component_updater { 28 namespace component_updater {
29 29
30 namespace { 30 namespace {
31 31
32 class ChromeConfigurator : public update_client::Configurator { 32 class ChromeConfigurator : public update_client::Configurator {
33 public: 33 public:
34 ChromeConfigurator(const base::CommandLine* cmdline, 34 ChromeConfigurator(const base::CommandLine* cmdline,
35 net::URLRequestContextGetter* url_request_getter); 35 net::URLRequestContextGetter* url_request_getter,
36 PrefService* pref_service);
36 37
37 // update_client::Configurator overrides. 38 // update_client::Configurator overrides.
38 int InitialDelay() const override; 39 int InitialDelay() const override;
39 int NextCheckDelay() const override; 40 int NextCheckDelay() const override;
40 int StepDelay() const override; 41 int StepDelay() const override;
41 int OnDemandDelay() const override; 42 int OnDemandDelay() const override;
42 int UpdateDelay() const override; 43 int UpdateDelay() const override;
43 std::vector<GURL> UpdateUrl() const override; 44 std::vector<GURL> UpdateUrl() const override;
44 std::vector<GURL> PingUrl() const override; 45 std::vector<GURL> PingUrl() const override;
45 base::Version GetBrowserVersion() const override; 46 base::Version GetBrowserVersion() const override;
(...skipping 12 matching lines...) Expand all
58 bool EnabledCupSigning() const override; 59 bool EnabledCupSigning() const override;
59 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() 60 scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner()
60 const override; 61 const override;
61 PrefService* GetPrefService() const override; 62 PrefService* GetPrefService() const override;
62 63
63 private: 64 private:
64 friend class base::RefCountedThreadSafe<ChromeConfigurator>; 65 friend class base::RefCountedThreadSafe<ChromeConfigurator>;
65 66
66 ConfiguratorImpl configurator_impl_; 67 ConfiguratorImpl configurator_impl_;
67 68
69 PrefService* pref_service_; // This member is not owned by this class.
70
68 ~ChromeConfigurator() override {} 71 ~ChromeConfigurator() override {}
69 }; 72 };
70 73
71 // Allows the component updater to use non-encrypted communication with the 74 // Allows the component updater to use non-encrypted communication with the
72 // update backend. The security of the update checks is enforced using 75 // update backend. The security of the update checks is enforced using
73 // a custom message signing protocol and it does not depend on using HTTPS. 76 // a custom message signing protocol and it does not depend on using HTTPS.
74 ChromeConfigurator::ChromeConfigurator( 77 ChromeConfigurator::ChromeConfigurator(
75 const base::CommandLine* cmdline, 78 const base::CommandLine* cmdline,
76 net::URLRequestContextGetter* url_request_getter) 79 net::URLRequestContextGetter* url_request_getter,
77 : configurator_impl_(cmdline, url_request_getter, false) {} 80 PrefService* pref_service)
81 : configurator_impl_(cmdline, url_request_getter, false),
82 pref_service_(pref_service) {
83 DCHECK(pref_service_);
84 }
78 85
79 int ChromeConfigurator::InitialDelay() const { 86 int ChromeConfigurator::InitialDelay() const {
80 return configurator_impl_.InitialDelay(); 87 return configurator_impl_.InitialDelay();
81 } 88 }
82 89
83 int ChromeConfigurator::NextCheckDelay() const { 90 int ChromeConfigurator::NextCheckDelay() const {
84 return configurator_impl_.NextCheckDelay(); 91 return configurator_impl_.NextCheckDelay();
85 } 92 }
86 93
87 int ChromeConfigurator::StepDelay() const { 94 int ChromeConfigurator::StepDelay() const {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // not accessing any global browser state while the code is running. 181 // not accessing any global browser state while the code is running.
175 scoped_refptr<base::SequencedTaskRunner> 182 scoped_refptr<base::SequencedTaskRunner>
176 ChromeConfigurator::GetSequencedTaskRunner() const { 183 ChromeConfigurator::GetSequencedTaskRunner() const {
177 return content::BrowserThread::GetBlockingPool() 184 return content::BrowserThread::GetBlockingPool()
178 ->GetSequencedTaskRunnerWithShutdownBehavior( 185 ->GetSequencedTaskRunnerWithShutdownBehavior(
179 base::SequencedWorkerPool::GetSequenceToken(), 186 base::SequencedWorkerPool::GetSequenceToken(),
180 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 187 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
181 } 188 }
182 189
183 PrefService* ChromeConfigurator::GetPrefService() const { 190 PrefService* ChromeConfigurator::GetPrefService() const {
184 return g_browser_process->local_state(); 191 DCHECK(pref_service_);
192 return pref_service_;
185 } 193 }
186 194
187 } // namespace 195 } // namespace
188 196
189 scoped_refptr<update_client::Configurator> 197 scoped_refptr<update_client::Configurator>
190 MakeChromeComponentUpdaterConfigurator( 198 MakeChromeComponentUpdaterConfigurator(
191 const base::CommandLine* cmdline, 199 const base::CommandLine* cmdline,
192 net::URLRequestContextGetter* context_getter) { 200 net::URLRequestContextGetter* context_getter,
193 return new ChromeConfigurator(cmdline, context_getter); 201 PrefService* pref_service) {
202 return new ChromeConfigurator(cmdline, context_getter, pref_service);
194 } 203 }
195 204
196 } // namespace component_updater 205 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698