| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/component_updater_configurator.h" | 5 #include "chrome/browser/component_updater/component_updater_configurator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/strings/string_util.h" | |
| 14 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 15 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 16 #include "chrome/browser/component_updater/component_patcher.h" | 15 #include "chrome/browser/component_updater/component_patcher.h" |
| 17 #include "chrome/common/chrome_switches.h" | |
| 18 #include "net/url_request/url_request_context_getter.h" | 16 #include "net/url_request/url_request_context_getter.h" |
| 19 | 17 |
| 20 namespace component_updater { | 18 namespace component_updater { |
| 21 | 19 |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 // Default time constants. | 22 // Default time constants. |
| 25 const int kDelayOneMinute = 60; | 23 const int kDelayOneMinute = 60; |
| 26 const int kDelayOneHour = kDelayOneMinute * 60; | 24 const int kDelayOneHour = kDelayOneMinute * 60; |
| 27 | 25 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 80 } |
| 83 } | 81 } |
| 84 } | 82 } |
| 85 return std::string(); | 83 return std::string(); |
| 86 } | 84 } |
| 87 | 85 |
| 88 } // namespace | 86 } // namespace |
| 89 | 87 |
| 90 class ChromeConfigurator : public ComponentUpdateService::Configurator { | 88 class ChromeConfigurator : public ComponentUpdateService::Configurator { |
| 91 public: | 89 public: |
| 92 ChromeConfigurator(const CommandLine* cmdline, | 90 ChromeConfigurator(const std::vector<std::string>& switch_values, |
| 93 net::URLRequestContextGetter* url_request_getter); | 91 net::URLRequestContextGetter* url_request_getter); |
| 94 | 92 |
| 95 virtual ~ChromeConfigurator() {} | 93 virtual ~ChromeConfigurator() {} |
| 96 | 94 |
| 97 virtual int InitialDelay() OVERRIDE; | 95 virtual int InitialDelay() OVERRIDE; |
| 98 virtual int NextCheckDelay() OVERRIDE; | 96 virtual int NextCheckDelay() OVERRIDE; |
| 99 virtual int StepDelay() OVERRIDE; | 97 virtual int StepDelay() OVERRIDE; |
| 100 virtual int StepDelayMedium() OVERRIDE; | 98 virtual int StepDelayMedium() OVERRIDE; |
| 101 virtual int MinimumReCheckWait() OVERRIDE; | 99 virtual int MinimumReCheckWait() OVERRIDE; |
| 102 virtual int OnDemandDelay() OVERRIDE; | 100 virtual int OnDemandDelay() OVERRIDE; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 113 net::URLRequestContextGetter* url_request_getter_; | 111 net::URLRequestContextGetter* url_request_getter_; |
| 114 std::string extra_info_; | 112 std::string extra_info_; |
| 115 std::string url_source_; | 113 std::string url_source_; |
| 116 bool fast_update_; | 114 bool fast_update_; |
| 117 bool pings_enabled_; | 115 bool pings_enabled_; |
| 118 bool deltas_enabled_; | 116 bool deltas_enabled_; |
| 119 bool background_downloads_enabled_; | 117 bool background_downloads_enabled_; |
| 120 }; | 118 }; |
| 121 | 119 |
| 122 ChromeConfigurator::ChromeConfigurator( | 120 ChromeConfigurator::ChromeConfigurator( |
| 123 const CommandLine* cmdline, | 121 const std::vector<std::string>& switch_values, |
| 124 net::URLRequestContextGetter* url_request_getter) | 122 net::URLRequestContextGetter* url_request_getter) |
| 125 : url_request_getter_(url_request_getter), | 123 : url_request_getter_(url_request_getter), |
| 126 fast_update_(false), | 124 fast_update_(false), |
| 127 pings_enabled_(false), | 125 pings_enabled_(false), |
| 128 deltas_enabled_(false), | 126 deltas_enabled_(false), |
| 129 background_downloads_enabled_(false) { | 127 background_downloads_enabled_(false) { |
| 130 // Parse comma-delimited debug flags. | |
| 131 std::vector<std::string> switch_values; | |
| 132 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdater), | |
| 133 ",", | |
| 134 &switch_values); | |
| 135 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); | 128 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); |
| 136 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); | 129 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); |
| 137 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); | 130 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); |
| 138 | 131 |
| 139 #if defined(OS_WIN) | 132 #if defined(OS_WIN) |
| 140 background_downloads_enabled_ = | 133 background_downloads_enabled_ = |
| 141 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads); | 134 !HasSwitchValue(switch_values, kSwitchDisableBackgroundDownloads); |
| 142 #else | 135 #else |
| 143 background_downloads_enabled_ = false; | 136 background_downloads_enabled_ = false; |
| 144 #endif | 137 #endif |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 195 |
| 203 bool ChromeConfigurator::DeltasEnabled() const { | 196 bool ChromeConfigurator::DeltasEnabled() const { |
| 204 return deltas_enabled_; | 197 return deltas_enabled_; |
| 205 } | 198 } |
| 206 | 199 |
| 207 bool ChromeConfigurator::UseBackgroundDownloader() const { | 200 bool ChromeConfigurator::UseBackgroundDownloader() const { |
| 208 return background_downloads_enabled_; | 201 return background_downloads_enabled_; |
| 209 } | 202 } |
| 210 | 203 |
| 211 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( | 204 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( |
| 212 const CommandLine* cmdline, | 205 const std::vector<std::string>& switch_values, |
| 213 net::URLRequestContextGetter* context_getter) { | 206 net::URLRequestContextGetter* context_getter) { |
| 214 return new ChromeConfigurator(cmdline, context_getter); | 207 return new ChromeConfigurator(switch_values, context_getter); |
| 215 } | 208 } |
| 216 | 209 |
| 217 } // namespace component_updater | 210 } // namespace component_updater |
| OLD | NEW |