Chromium Code Reviews| Index: chrome/browser/component_updater/component_updater_configurator.cc |
| diff --git a/chrome/browser/component_updater/component_updater_configurator.cc b/chrome/browser/component_updater/component_updater_configurator.cc |
| index 16fa3e9619752730b02326dba994faf4c14aef10..fe6c4ca3d5bbd950b68cb9618cc117056cfe634d 100644 |
| --- a/chrome/browser/component_updater/component_updater_configurator.cc |
| +++ b/chrome/browser/component_updater/component_updater_configurator.cc |
| @@ -14,11 +14,17 @@ |
| #include "base/strings/string_util.h" |
| #include "base/win/windows_version.h" |
| #include "build/build_config.h" |
| +#include "chrome/browser/component_updater/component_patcher.h" |
| #include "chrome/common/chrome_switches.h" |
| #include "chrome/common/omaha_query_params/omaha_query_params.h" |
| #include "net/url_request/url_request_context_getter.h" |
| +#if defined(OS_WIN) |
| +#include "chrome/browser/component_updater/component_patcher_win.h" |
| +#endif |
| + |
| namespace { |
| + |
| // Default time constants. |
| const int kDelayOneMinute = 60; |
| const int kDelayOneHour = kDelayOneMinute * 60; |
| @@ -35,9 +41,13 @@ const char kDebugRequestParam[] = "test-request"; |
| const char* kUrlSources[] = { |
| "http://clients2.google.com/service/update2/crx", // BANDAID |
| "http://omaha.google.com/service/update2/crx", // CWS_PUBLIC |
| - "http://omaha.sandbox.google.com/service/update2/crx" // CWS_SANDBOX |
| + "http://omaha.sandbox.google.com/service/update2/crx", // CWS_SANDBOX |
| }; |
| +// The url to send the completion pings to. Completion pings are sent when |
| +// updates have completed, either successfully or with errors. |
| +const char kUrlPing[] = "http://tools.google.com/service/update2"; |
| + |
| bool HasDebugValue(const std::vector<std::string>& vec, const char* test) { |
| if (vec.empty()) |
| return 0; |
| @@ -59,24 +69,32 @@ class ChromeConfigurator : public ComponentUpdateService::Configurator { |
| virtual int MinimumReCheckWait() OVERRIDE; |
| virtual int OnDemandDelay() OVERRIDE; |
| virtual GURL UpdateUrl(CrxComponent::UrlSource source) OVERRIDE; |
| + virtual GURL PingUrl() OVERRIDE; |
| virtual const char* ExtraRequestParams() OVERRIDE; |
| virtual size_t UrlSizeLimit() OVERRIDE; |
| virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; |
| virtual bool InProcess() OVERRIDE; |
| virtual void OnEvent(Events event, int val) OVERRIDE; |
| + virtual ComponentPatcher* CreateComponentPatcher() OVERRIDE; |
| + virtual bool PingsEnabled() const OVERRIDE; |
|
cpu_(ooo_6.6-7.5)
2013/06/17 20:27:01
I feel we have duplicated state here, I propose th
waffles
2013/06/17 23:51:07
Done.
|
| + virtual bool DeltasEnabled() const OVERRIDE; |
| private: |
| net::URLRequestContextGetter* url_request_getter_; |
| std::string extra_info_; |
| bool fast_update_; |
| bool out_of_process_; |
| + bool pings_enabled_; |
| + bool deltas_enabled_; |
| }; |
| ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, |
| net::URLRequestContextGetter* url_request_getter) |
| : url_request_getter_(url_request_getter), |
| extra_info_(chrome::OmahaQueryParams::Get( |
| - chrome::OmahaQueryParams::CHROME)) { |
| + chrome::OmahaQueryParams::CHROME)), |
| + pings_enabled_(false), |
|
robertshield
2013/06/17 17:47:00
don't need these in the initializer list if they a
Sorin Jianu
2013/06/17 22:21:09
We prefer to initialize any member in all cases ev
robertshield
2013/06/18 13:27:07
Sounds good. In that case, please initialize fast_
Sorin Jianu
2013/06/18 17:00:11
Done.
|
| + deltas_enabled_(false) { |
| // Parse comma-delimited debug flags. |
| std::vector<std::string> debug_values; |
| Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdaterDebug), |
| @@ -84,6 +102,14 @@ ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, |
| fast_update_ = HasDebugValue(debug_values, kDebugFastUpdate); |
| out_of_process_ = HasDebugValue(debug_values, kDebugOutOfProcess); |
| + // Parse other command-ling flags. |
| + pings_enabled_ = cmdline->HasSwitch(switches::kEnableComponentUpdatePings); |
| +#if defined(OS_WIN) |
| + deltas_enabled_ = cmdline->HasSwitch(switches::kEnableComponentUpdateDeltas); |
|
cpu_(ooo_6.6-7.5)
2013/06/17 20:27:01
if deltas enabled are an option, it does not seem
Sorin Jianu
2013/06/17 22:21:09
People could turn on deltas on platforms that we d
|
| +#else |
| + deltas_enabled_ = false; |
| +#endif |
| + |
| // Make the extra request params, they are necessary so omaha does |
| // not deliver components that are going to be rejected at install time. |
| #if defined(OS_WIN) |
| @@ -119,6 +145,10 @@ GURL ChromeConfigurator::UpdateUrl(CrxComponent::UrlSource source) { |
| return GURL(kUrlSources[source]); |
| } |
| +GURL ChromeConfigurator::PingUrl() { |
| + return GURL(kUrlPing); |
| +} |
| + |
| const char* ChromeConfigurator::ExtraRequestParams() { |
| return extra_info_.c_str(); |
| } |
| @@ -161,6 +191,22 @@ void ChromeConfigurator::OnEvent(Events event, int val) { |
| } |
| } |
| +ComponentPatcher* ChromeConfigurator::CreateComponentPatcher() { |
| +#if defined(OS_WIN) |
| + return new ComponentPatcherWin(); |
|
cpu_(ooo_6.6-7.5)
2013/06/17 20:27:01
this DI is nice but I do wonder if the configurato
Sorin Jianu
2013/06/17 22:21:09
Right on, I needed this primarily for DI and this
|
| +#else |
| + return new ComponentPatcherCrossPlatform(); |
| +#endif |
| +} |
| + |
| +bool ChromeConfigurator::DeltasEnabled() const { |
| + return deltas_enabled_; |
| +} |
| + |
| +bool ChromeConfigurator::PingsEnabled() const { |
| + return pings_enabled_; |
| +} |
| + |
| ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( |
| const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { |
| return new ChromeConfigurator(cmdline, context_getter); |