Skip to content

Commit

Permalink
Remove dependencies of the Configurator on the ComponentUpdateService.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sorin@chromium.org committed Jun 24, 2014
1 parent 17a444c commit 6550438
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 51 deletions.
2 changes: 1 addition & 1 deletion chrome/browser/browser_process_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);

Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/component_updater/component_updater_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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_;

Expand Down Expand Up @@ -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())),
Expand Down Expand Up @@ -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);
}
Expand Down
42 changes: 3 additions & 39 deletions chrome/browser/component_updater/component_updater_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ResourceThrottle;

namespace component_updater {

class Configurator;
class OnDemandUpdater;

// Component specific installers must derive from this class and implement
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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_
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 6550438

Please sign in to comment.