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 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // The default url for the v3 protocol service endpoint. Can be | 46 // The default url for the v3 protocol service endpoint. Can be |
47 // overridden with --component-updater=url-source=someurl. | 47 // overridden with --component-updater=url-source=someurl. |
48 const char kDefaultUrlSource[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT; | 48 const char kDefaultUrlSource[] = "https:" COMPONENT_UPDATER_SERVICE_ENDPOINT; |
49 | 49 |
50 // The url to send the pings to. | 50 // The url to send the pings to. |
51 const char kPingUrl[] = "http:" COMPONENT_UPDATER_SERVICE_ENDPOINT; | 51 const char kPingUrl[] = "http:" COMPONENT_UPDATER_SERVICE_ENDPOINT; |
52 | 52 |
53 #if defined(OS_WIN) | 53 #if defined(OS_WIN) |
54 // Disables differential updates. | 54 // Disables differential updates. |
55 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; | 55 const char kSwitchDisableDeltaUpdates[] = "disable-delta-updates"; |
| 56 // Enables background downloads. |
| 57 const char kSwitchEnableBackgroundDownloads[] = "enable-background-downloads"; |
56 #endif // defined(OS_WIN) | 58 #endif // defined(OS_WIN) |
57 | 59 |
58 // Returns true if and only if |test| is contained in |vec|. | 60 // Returns true if and only if |test| is contained in |vec|. |
59 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { | 61 bool HasSwitchValue(const std::vector<std::string>& vec, const char* test) { |
60 if (vec.empty()) | 62 if (vec.empty()) |
61 return 0; | 63 return 0; |
62 return (std::find(vec.begin(), vec.end(), test) != vec.end()); | 64 return (std::find(vec.begin(), vec.end(), test) != vec.end()); |
63 } | 65 } |
64 | 66 |
65 // If there is an element of |vec| of the form |test|=.*, returns the right- | 67 // If there is an element of |vec| of the form |test|=.*, returns the right- |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 virtual int MinimumReCheckWait() OVERRIDE; | 101 virtual int MinimumReCheckWait() OVERRIDE; |
100 virtual int OnDemandDelay() OVERRIDE; | 102 virtual int OnDemandDelay() OVERRIDE; |
101 virtual GURL UpdateUrl() OVERRIDE; | 103 virtual GURL UpdateUrl() OVERRIDE; |
102 virtual GURL PingUrl() OVERRIDE; | 104 virtual GURL PingUrl() OVERRIDE; |
103 virtual const char* ExtraRequestParams() OVERRIDE; | 105 virtual const char* ExtraRequestParams() OVERRIDE; |
104 virtual size_t UrlSizeLimit() OVERRIDE; | 106 virtual size_t UrlSizeLimit() OVERRIDE; |
105 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; | 107 virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; |
106 virtual bool InProcess() OVERRIDE; | 108 virtual bool InProcess() OVERRIDE; |
107 virtual ComponentPatcher* CreateComponentPatcher() OVERRIDE; | 109 virtual ComponentPatcher* CreateComponentPatcher() OVERRIDE; |
108 virtual bool DeltasEnabled() const OVERRIDE; | 110 virtual bool DeltasEnabled() const OVERRIDE; |
| 111 virtual bool UseBackgroundDownloader() const OVERRIDE; |
109 | 112 |
110 private: | 113 private: |
111 net::URLRequestContextGetter* url_request_getter_; | 114 net::URLRequestContextGetter* url_request_getter_; |
112 std::string extra_info_; | 115 std::string extra_info_; |
113 std::string url_source_; | 116 std::string url_source_; |
114 bool fast_update_; | 117 bool fast_update_; |
115 bool pings_enabled_; | 118 bool pings_enabled_; |
116 bool deltas_enabled_; | 119 bool deltas_enabled_; |
| 120 bool background_downloads_enabled_; |
117 }; | 121 }; |
118 | 122 |
119 ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, | 123 ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, |
120 net::URLRequestContextGetter* url_request_getter) | 124 net::URLRequestContextGetter* url_request_getter) |
121 : url_request_getter_(url_request_getter), | 125 : url_request_getter_(url_request_getter), |
122 extra_info_(chrome::OmahaQueryParams::Get( | 126 extra_info_(chrome::OmahaQueryParams::Get( |
123 chrome::OmahaQueryParams::CHROME)), | 127 chrome::OmahaQueryParams::CHROME)), |
124 fast_update_(false), | 128 fast_update_(false), |
125 pings_enabled_(false), | 129 pings_enabled_(false), |
126 deltas_enabled_(false) { | 130 deltas_enabled_(false), |
| 131 background_downloads_enabled_(false) { |
127 // Parse comma-delimited debug flags. | 132 // Parse comma-delimited debug flags. |
128 std::vector<std::string> switch_values; | 133 std::vector<std::string> switch_values; |
129 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdater), | 134 Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdater), |
130 ",", &switch_values); | 135 ",", &switch_values); |
131 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); | 136 fast_update_ = HasSwitchValue(switch_values, kSwitchFastUpdate); |
132 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); | 137 pings_enabled_ = !HasSwitchValue(switch_values, kSwitchDisablePings); |
133 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
134 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); | 139 deltas_enabled_ = !HasSwitchValue(switch_values, kSwitchDisableDeltaUpdates); |
| 140 background_downloads_enabled_ = |
| 141 HasSwitchValue(switch_values, kSwitchEnableBackgroundDownloads); |
135 #else | 142 #else |
136 deltas_enabled_ = false; | 143 deltas_enabled_ = false; |
137 #endif | 144 #endif |
138 | 145 |
139 url_source_ = GetSwitchArgument(switch_values, kSwitchUrlSource); | 146 url_source_ = GetSwitchArgument(switch_values, kSwitchUrlSource); |
140 if (url_source_.empty()) { | 147 if (url_source_.empty()) { |
141 url_source_ = kDefaultUrlSource; | 148 url_source_ = kDefaultUrlSource; |
142 } | 149 } |
143 | 150 |
144 // Make the extra request params, they are necessary so omaha does | 151 // Make the extra request params, they are necessary so omaha does |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 return new ComponentPatcherWin(); | 212 return new ComponentPatcherWin(); |
206 #else | 213 #else |
207 return new ComponentPatcherCrossPlatform(); | 214 return new ComponentPatcherCrossPlatform(); |
208 #endif | 215 #endif |
209 } | 216 } |
210 | 217 |
211 bool ChromeConfigurator::DeltasEnabled() const { | 218 bool ChromeConfigurator::DeltasEnabled() const { |
212 return deltas_enabled_; | 219 return deltas_enabled_; |
213 } | 220 } |
214 | 221 |
| 222 bool ChromeConfigurator::UseBackgroundDownloader() const { |
| 223 return background_downloads_enabled_; |
| 224 } |
| 225 |
215 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( | 226 ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( |
216 const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { | 227 const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { |
217 return new ChromeConfigurator(cmdline, context_getter); | 228 return new ChromeConfigurator(cmdline, context_getter); |
218 } | 229 } |
OLD | NEW |