Chromium Code Reviews| Index: chrome/browser/component_updater/component_updater_configurator.cc |
| =================================================================== |
| --- chrome/browser/component_updater/component_updater_configurator.cc (revision 0) |
| +++ chrome/browser/component_updater/component_updater_configurator.cc (revision 0) |
| @@ -0,0 +1,103 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/component_updater/component_updater_service.h" |
| + |
| +#include <algorithm> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/command_line.h" |
| +#include "base/compiler_specific.h" |
| +#include "base/string_util.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "net/url_request/url_request_context_getter.h" |
| + |
| +namespace { |
| +// Default time constants. |
| +const int kDelayOneMinute = 60; |
| +const int kDelayOneHour = kDelayOneMinute * 60; |
| + |
| +// Debug values you can pass to --component-updater-debug=<value>. |
| +const char kDebugFastUpdate[] = "fast-update"; |
| +const char kDebugOutOfProcess[] = "out-of-process"; |
| + |
| +bool HasDebugValue(const std::vector<std::string>& vec, const char* test) { |
| + if (vec.empty()) |
| + return 0; |
| + return (std::find(vec.begin(), vec.end(), test) != vec.end()); |
| +} |
| + |
| +} // namespace |
| + |
| +class ChromeConfigurator : public ComponentUpdateService::Configurator { |
| + public: |
| + ChromeConfigurator(const CommandLine* cmdline, |
| + net::URLRequestContextGetter* url_request_getter); |
| + |
| + virtual ~ChromeConfigurator() {} |
| + |
| + virtual int InitialDelay() OVERRIDE; |
| + virtual int NextCheckDelay() OVERRIDE; |
| + virtual int StepDelay() OVERRIDE; |
| + virtual int MinimumReCheckWait() OVERRIDE; |
| + virtual GURL UpdateUrl() OVERRIDE; |
| + virtual size_t UrlSizeLimit() OVERRIDE; |
| + virtual net::URLRequestContextGetter* RequestContext() OVERRIDE; |
| + virtual bool InProcess() OVERRIDE; |
| + |
| + private: |
| + net::URLRequestContextGetter* url_request_getter_; |
| + bool fast_update_; |
| + bool out_of_process_; |
| +}; |
| + |
| +ChromeConfigurator::ChromeConfigurator(const CommandLine* cmdline, |
| + net::URLRequestContextGetter* url_request_getter) |
| + : url_request_getter_(url_request_getter) { |
| + // Parse comma-delimited debug flags. |
| + std::vector<std::string> debug_values; |
| + Tokenize(cmdline->GetSwitchValueASCII(switches::kComponentUpdaterDebug), |
| + ",", &debug_values); |
| + fast_update_ = HasDebugValue(debug_values, kDebugFastUpdate); |
| + out_of_process_ = HasDebugValue(debug_values, kDebugOutOfProcess); |
| +} |
| + |
| +int ChromeConfigurator::InitialDelay() { |
| + return fast_update_ ? 1 : (6 * kDelayOneMinute); |
| +} |
| + |
| +int ChromeConfigurator::NextCheckDelay() { |
| + return fast_update_ ? 3 : (4 * kDelayOneHour); |
| +} |
| + |
| +int ChromeConfigurator::StepDelay() { |
| + return fast_update_ ? 1 : 4; |
| +} |
| + |
| +int ChromeConfigurator::MinimumReCheckWait() { |
| + return fast_update_ ? 30 : (6 * kDelayOneHour); |
| +} |
| + |
| +GURL ChromeConfigurator::UpdateUrl() { |
| + return GURL("http://clients2.google.com/service/update2/crx"); |
|
asargent_no_longer_on_chrome
2011/08/02 23:57:07
I think we have a constant for this somewhere in t
cpu_(ooo_6.6-7.5)
2011/08/03 20:17:15
I don't think this is going to be the real url. I
|
| +} |
| + |
| +size_t ChromeConfigurator::UrlSizeLimit() { |
| + return 1024ul; |
| +} |
| + |
| +net::URLRequestContextGetter* ChromeConfigurator::RequestContext() { |
| + return url_request_getter_; |
| +} |
| + |
| +bool ChromeConfigurator::InProcess() { |
| + return out_of_process_; |
| +} |
| + |
| +ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( |
| + const CommandLine* cmdline, net::URLRequestContextGetter* context_getter) { |
| + return new ChromeConfigurator(cmdline, context_getter); |
| +} |
| + |
| Property changes on: chrome\browser\component_updater\component_updater_configurator.cc |
| ___________________________________________________________________ |
| Added: svn:eol-style |
| + LF |