diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-03 22:11:37 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-03 22:11:37 +0000 |
commit | c1adf5a793a790365bc79b8a489d598619065ef6 (patch) | |
tree | 324e113a022133520a24b6597e5e4db96d27d5c2 | |
parent | 93f47838f2da4727b8b0dbc63275495be6defcd7 (diff) | |
download | chromium_src-c1adf5a793a790365bc79b8a489d598619065ef6.zip chromium_src-c1adf5a793a790365bc79b8a489d598619065ef6.tar.gz chromium_src-c1adf5a793a790365bc79b8a489d598619065ef6.tar.bz2 |
Component update part six, wire sigleton to browser
Also adds a minimalistic configurator
TEST=none
BUG=61602
Review URL: http://codereview.chromium.org/7545004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95336 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_process.h | 3 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 19 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.h | 6 | ||||
-rw-r--r-- | chrome/browser/component_updater/component_updater_configurator.cc | 103 | ||||
-rw-r--r-- | chrome/browser/component_updater/component_updater_configurator.h | 15 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 4 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 1 | ||||
-rw-r--r-- | chrome/test/testing_browser_process.cc | 4 | ||||
-rw-r--r-- | chrome/test/testing_browser_process.h | 1 |
10 files changed, 158 insertions, 0 deletions
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index 8ac80ad..4d7c430 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -21,6 +21,7 @@ class AutomationProviderList; class BackgroundModeManager; class ChromeNetLog; +class ComponentUpdateService; class DevToolsManager; class DownloadRequestLimiter; class DownloadStatusUpdater; @@ -246,6 +247,8 @@ class BrowserProcess { virtual GpuBlacklistUpdater* gpu_blacklist_updater() = 0; + virtual ComponentUpdateService* component_updater() = 0; + private: // User-data-dir based profiles. std::vector<std::wstring> user_data_dir_profiles_; diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 0d4be7f..69bf3fb 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -20,6 +20,8 @@ #include "chrome/browser/browser_main.h" #include "chrome/browser/browser_process_sub_thread.h" #include "chrome/browser/browser_trial.h" +#include "chrome/browser/component_updater/component_updater_configurator.h" +#include "chrome/browser/component_updater/component_updater_service.h" #include "chrome/browser/debugger/devtools_protocol_handler.h" #include "chrome/browser/debugger/remote_debugging_server.h" #include "chrome/browser/download/download_file_manager.h" @@ -677,6 +679,23 @@ GpuBlacklistUpdater* BrowserProcessImpl::gpu_blacklist_updater() { return gpu_blacklist_updater_.get(); } +ComponentUpdateService* BrowserProcessImpl::component_updater() { +#if defined(OS_CHROMEOS) + return NULL; +#else + if (!component_updater_.get()) { + ComponentUpdateService::Configurator* configurator = + MakeChromeComponentUpdaterConfigurator( + CommandLine::ForCurrentProcess(), + io_thread()->system_url_request_context_getter()); + // Creating the component updater does not do anything, components + // need to be registered and Start() needs to be called. + component_updater_.reset(ComponentUpdateServiceFactory(configurator)); + } + return component_updater_.get(); +} +#endif + void BrowserProcessImpl::CreateResourceDispatcherHost() { DCHECK(!created_resource_dispatcher_host_ && resource_dispatcher_host_.get() == NULL); diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index e22ec85..2c69436 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -126,6 +126,8 @@ class BrowserProcessImpl : public BrowserProcess, virtual GpuBlacklistUpdater* gpu_blacklist_updater(); + virtual ComponentUpdateService* component_updater(); + private: void CreateResourceDispatcherHost(); void CreateMetricsService(); @@ -321,6 +323,10 @@ class BrowserProcessImpl : public BrowserProcess, scoped_refptr<GpuBlacklistUpdater> gpu_blacklist_updater_; +#if !defined(OS_CHROMEOS) + scoped_ptr<ComponentUpdateService> component_updater_; +#endif + DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); }; diff --git a/chrome/browser/component_updater/component_updater_configurator.cc b/chrome/browser/component_updater/component_updater_configurator.cc new file mode 100644 index 0000000..67b2e5d --- /dev/null +++ b/chrome/browser/component_updater/component_updater_configurator.cc @@ -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"); +} + +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); +} + diff --git a/chrome/browser/component_updater/component_updater_configurator.h b/chrome/browser/component_updater/component_updater_configurator.h new file mode 100644 index 0000000..f1ffe6c --- /dev/null +++ b/chrome/browser/component_updater/component_updater_configurator.h @@ -0,0 +1,15 @@ +// 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. + +#ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_ +#define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_ +#pragma once + +#include "chrome/browser/component_updater/component_updater_service.h" + +ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( + const CommandLine* cmdline, net::URLRequestContextGetter* context_getter); + +#endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_ + diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index a7b594c..3275cda 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -772,6 +772,8 @@ 'browser/chromeos/xinput_hierarchy_changed_event_listener.h', 'browser/command_updater.cc', 'browser/command_updater.h', + 'browser/component_updater/component_updater_configurator.cc', + 'browser/component_updater/component_updater_configurator.h', 'browser/component_updater/component_unpacker.cc', 'browser/component_updater/component_unpacker.h', 'browser/component_updater/component_updater_service.cc', diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index e57b2a7..5f6ec9e 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -139,6 +139,10 @@ const char kCloudPrintProxyId[] = "cloud-print-proxy-id"; // print service has been enabled (see enable-cloud-print). const char kCloudPrintServiceURL[] = "cloud-print-service"; +// Comma-separated options to troubleshoot the component updater. +// Only valid for the browser process. +const char kComponentUpdaterDebug[] = "component-updater-debug"; + // Causes the browser process to inspect loaded and registered DLLs for // known conflicts and warn the user. const char kConflictingModulesCheck[] = "conflicting-modules-check"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index fea7f0f..7879e04 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -55,6 +55,7 @@ extern const char kCloudPrintJobTitle[]; extern const char kCloudPrintFileType[]; extern const char kCloudPrintProxyId[]; extern const char kCloudPrintServiceURL[]; +extern const char kComponentUpdaterDebug[]; extern const char kConflictingModulesCheck[]; extern const char kCountry[]; extern const char kCrashOnHangSeconds[]; diff --git a/chrome/test/testing_browser_process.cc b/chrome/test/testing_browser_process.cc index 115de3e..f194a0b 100644 --- a/chrome/test/testing_browser_process.cc +++ b/chrome/test/testing_browser_process.cc @@ -243,6 +243,10 @@ GpuBlacklistUpdater* TestingBrowserProcess::gpu_blacklist_updater() { return NULL; } +ComponentUpdateService* TestingBrowserProcess::component_updater() { + return NULL; +} + void TestingBrowserProcess::SetLocalState(PrefService* local_state) { if (!local_state && notification_ui_manager_.get()) notification_ui_manager_.reset(); // Used local_state_. diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h index 079e7f8..dc1ce95 100644 --- a/chrome/test/testing_browser_process.h +++ b/chrome/test/testing_browser_process.h @@ -117,6 +117,7 @@ class TestingBrowserProcess : public BrowserProcess { #endif virtual MHTMLGenerationManager* mhtml_generation_manager(); virtual GpuBlacklistUpdater* gpu_blacklist_updater(); + virtual ComponentUpdateService* component_updater(); // Set the local state for tests. Consumer is responsible for cleaning it up // afterwards (using ScopedTestingLocalState, for example). |