diff options
author | sorin@chromium.org <sorin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-24 01:50:36 +0000 |
---|---|---|
committer | sorin@chromium.org <sorin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-24 01:50:36 +0000 |
commit | 65504381567d0d85838e2a07cdeb98262e40be07 (patch) | |
tree | 02233e54478c22c5b94acfe1ac143481769072f2 | |
parent | 17a444c332ee3adfb37e15a795694b7d90732244 (diff) | |
download | chromium_src-65504381567d0d85838e2a07cdeb98262e40be07.zip chromium_src-65504381567d0d85838e2a07cdeb98262e40be07.tar.gz chromium_src-65504381567d0d85838e2a07cdeb98262e40be07.tar.bz2 |
Remove dependencies of the Configurator on the ComponentUpdateService.
This is a mechanical change (no difference in behavior is introduced).
The class was an inner class, now it is a free standing class in the
component_updater namespace.
BUG=371463
Review URL: https://codereview.chromium.org/344253010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279266 0039d316-1c4b-4281-b951-d872f2087c98
7 files changed, 55 insertions, 51 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 7f492c5..44fbf9c 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -781,7 +781,7 @@ BrowserProcessImpl::component_updater() { if (!component_updater_.get()) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) return NULL; - component_updater::ComponentUpdateService::Configurator* configurator = + component_updater::Configurator* configurator = component_updater::MakeChromeComponentUpdaterConfigurator( CommandLine::ForCurrentProcess(), io_thread()->system_url_request_context_getter()); diff --git a/chrome/browser/component_updater/component_updater_configurator.cc b/chrome/browser/component_updater/component_updater_configurator.cc index 269dea1..b0feeed 100644 --- a/chrome/browser/component_updater/component_updater_configurator.cc +++ b/chrome/browser/component_updater/component_updater_configurator.cc @@ -87,7 +87,7 @@ std::string GetSwitchArgument(const std::vector<std::string>& vec, } // namespace -class ChromeConfigurator : public ComponentUpdateService::Configurator { +class ChromeConfigurator : public Configurator { public: ChromeConfigurator(const CommandLine* cmdline, net::URLRequestContextGetter* url_request_getter); @@ -208,7 +208,7 @@ bool ChromeConfigurator::UseBackgroundDownloader() const { return background_downloads_enabled_; } -ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( +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 index c9c7b14..1017399 100644 --- a/chrome/browser/component_updater/component_updater_configurator.h +++ b/chrome/browser/component_updater/component_updater_configurator.h @@ -5,6 +5,8 @@ #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_ #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_CONFIGURATOR_H_ +#include <string> + #include "chrome/browser/component_updater/component_updater_service.h" namespace base { @@ -17,7 +19,45 @@ class URLRequestContextGetter; namespace component_updater { -ComponentUpdateService::Configurator* MakeChromeComponentUpdaterConfigurator( +// Controls the component updater behavior. +class Configurator { + public: + virtual ~Configurator() {} + // Delay in seconds from calling Start() to the first update check. + virtual int InitialDelay() = 0; + // Delay in seconds to every subsequent update check. 0 means don't check. + virtual int NextCheckDelay() = 0; + // Delay in seconds from each task step. Used to smooth out CPU/IO usage. + virtual int StepDelay() = 0; + // Delay in seconds between applying updates for different components, if + // several updates are available at a given time. + virtual int StepDelayMedium() = 0; + // Minimum delta time in seconds before checking again the same component. + virtual int MinimumReCheckWait() = 0; + // Minimum delta time in seconds before an on-demand check is allowed + // for the same component. + virtual int OnDemandDelay() = 0; + // The url that is going to be used update checks over Omaha protocol. + virtual GURL UpdateUrl() = 0; + // The url where the completion pings are sent. Invalid if and only if + // pings are disabled. + virtual GURL PingUrl() = 0; + // Parameters added to each url request. It can be null if none are needed. + virtual std::string ExtraRequestParams() = 0; + // How big each update request can be. Don't go above 2000. + virtual size_t UrlSizeLimit() = 0; + // The source of contexts for all the url requests. + virtual net::URLRequestContextGetter* RequestContext() = 0; + // True means that all ops are performed in this process. + virtual bool InProcess() = 0; + // True means that this client can handle delta updates. + virtual bool DeltasEnabled() const = 0; + // True means that the background downloader can be used for downloading + // non on-demand components. + virtual bool UseBackgroundDownloader() const = 0; +}; + +Configurator* MakeChromeComponentUpdaterConfigurator( const base::CommandLine* cmdline, net::URLRequestContextGetter* context_getter); diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc index 94ae2b3..5f51212 100644 --- a/chrome/browser/component_updater/component_updater_service.cc +++ b/chrome/browser/component_updater/component_updater_service.cc @@ -22,6 +22,7 @@ #include "base/timer/timer.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/component_updater/component_unpacker.h" +#include "chrome/browser/component_updater/component_updater_configurator.h" #include "chrome/browser/component_updater/component_updater_ping_manager.h" #include "chrome/browser/component_updater/component_updater_utils.h" #include "chrome/browser/component_updater/crx_downloader.h" @@ -52,7 +53,7 @@ bool IsVersionNewer(const Version& current, const std::string& proposed) { // Returns true if a differential update is available, it has not failed yet, // and the configuration allows it. bool CanTryDiffUpdate(const CrxUpdateItem* update_item, - const ComponentUpdateService::Configurator& config) { + const Configurator& config) { return HasDiffUpdate(update_item) && !update_item->diff_update_failed && config.DeltasEnabled(); } @@ -144,7 +145,7 @@ void UnblockandReapAllThrottles(CUResourceThrottle::WeakPtrVector* throttles) { // thread. class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { public: - explicit CrxUpdateService(ComponentUpdateService::Configurator* config); + explicit CrxUpdateService(Configurator* config); virtual ~CrxUpdateService(); // Overrides for ComponentUpdateService. @@ -244,7 +245,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { Status GetServiceStatus(const CrxUpdateItem::Status status); - scoped_ptr<ComponentUpdateService::Configurator> config_; + scoped_ptr<Configurator> config_; scoped_ptr<UpdateChecker> update_checker_; @@ -273,7 +274,7 @@ class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { ////////////////////////////////////////////////////////////////////////////// -CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config) +CrxUpdateService::CrxUpdateService(Configurator* config) : config_(config), ping_manager_( new PingManager(config->PingUrl(), config->RequestContext())), @@ -1088,8 +1089,7 @@ void CUResourceThrottle::Unblock() { // The component update factory. Using the component updater as a singleton // is the job of the browser process. -ComponentUpdateService* ComponentUpdateServiceFactory( - ComponentUpdateService::Configurator* config) { +ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { DCHECK(config); return new CrxUpdateService(config); } diff --git a/chrome/browser/component_updater/component_updater_service.h b/chrome/browser/component_updater/component_updater_service.h index 2f2fca6..ff01c89 100644 --- a/chrome/browser/component_updater/component_updater_service.h +++ b/chrome/browser/component_updater/component_updater_service.h @@ -30,6 +30,7 @@ class ResourceThrottle; namespace component_updater { +class Configurator; class OnDemandUpdater; // Component specific installers must derive from this class and implement @@ -99,43 +100,6 @@ struct CrxUpdateItem; class ComponentUpdateService { public: enum Status { kOk, kReplaced, kInProgress, kError }; - // Controls the component updater behavior. - class Configurator { - public: - virtual ~Configurator() {} - // Delay in seconds from calling Start() to the first update check. - virtual int InitialDelay() = 0; - // Delay in seconds to every subsequent update check. 0 means don't check. - virtual int NextCheckDelay() = 0; - // Delay in seconds from each task step. Used to smooth out CPU/IO usage. - virtual int StepDelay() = 0; - // Delay in seconds between applying updates for different components, if - // several updates are available at a given time. - virtual int StepDelayMedium() = 0; - // Minimum delta time in seconds before checking again the same component. - virtual int MinimumReCheckWait() = 0; - // Minimum delta time in seconds before an on-demand check is allowed - // for the same component. - virtual int OnDemandDelay() = 0; - // The url that is going to be used update checks over Omaha protocol. - virtual GURL UpdateUrl() = 0; - // The url where the completion pings are sent. Invalid if and only if - // pings are disabled. - virtual GURL PingUrl() = 0; - // Parameters added to each url request. It can be null if none are needed. - virtual std::string ExtraRequestParams() = 0; - // How big each update request can be. Don't go above 2000. - virtual size_t UrlSizeLimit() = 0; - // The source of contexts for all the url requests. - virtual net::URLRequestContextGetter* RequestContext() = 0; - // True means that all ops are performed in this process. - virtual bool InProcess() = 0; - // True means that this client can handle delta updates. - virtual bool DeltasEnabled() const = 0; - // True means that the background downloader can be used for downloading - // non on-demand components. - virtual bool UseBackgroundDownloader() const = 0; - }; // Defines an interface to observe ComponentUpdateService. It provides // notifications when state changes occur for the service or for the @@ -249,8 +213,8 @@ class OnDemandUpdater { // Creates the component updater. You must pass a valid |config| allocated on // the heap which the component updater will own. -ComponentUpdateService* ComponentUpdateServiceFactory( - ComponentUpdateService::Configurator* config); +ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config); + } // namespace component_updater #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UPDATER_SERVICE_H_ diff --git a/chrome/browser/component_updater/component_updater_utils.cc b/chrome/browser/component_updater/component_updater_utils.cc index ec6d497..bd23865 100644 --- a/chrome/browser/component_updater/component_updater_utils.cc +++ b/chrome/browser/component_updater/component_updater_utils.cc @@ -15,7 +15,6 @@ #include "base/strings/stringprintf.h" #include "base/sys_info.h" #include "base/win/windows_version.h" -#include "chrome/browser/component_updater/component_updater_service.h" #include "chrome/browser/component_updater/crx_update_item.h" #include "chrome/browser/omaha_query_params/omaha_query_params.h" #include "chrome/common/chrome_version_info.h" diff --git a/chrome/browser/component_updater/test/component_updater_service_unittest.h b/chrome/browser/component_updater/test/component_updater_service_unittest.h index 90e1e45..3cb7f06 100644 --- a/chrome/browser/component_updater/test/component_updater_service_unittest.h +++ b/chrome/browser/component_updater/test/component_updater_service_unittest.h @@ -16,6 +16,7 @@ #include "base/files/file_path.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "chrome/browser/component_updater/component_updater_configurator.h" #include "chrome/browser/component_updater/component_updater_service.h" #include "chrome/browser/component_updater/test/url_request_post_interceptor.h" #include "content/public/test/test_browser_thread_bundle.h" @@ -73,7 +74,7 @@ const uint8 ihfo_hash[] = {0x87, 0x5e, 0xa1, 0xa6, 0x9f, 0x85, 0xd1, 0x1e, 0xe7, 0xc5, 0xc8, 0xf5, 0x60, 0x19, 0x78, 0x1b, 0x6d, 0xe9, 0x4c, 0xeb, 0x96, 0x05, 0x42, 0x17}; -class TestConfigurator : public ComponentUpdateService::Configurator { +class TestConfigurator : public Configurator { public: TestConfigurator(); virtual ~TestConfigurator(); |