Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: chrome/browser/extensions/updater/extension_updater.cc

Issue 456063002: ExtensionUpdater: Abstract ExtensionDownloader creation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments and some cleanup Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/updater/extension_updater.cc
diff --git a/chrome/browser/extensions/updater/extension_updater.cc b/chrome/browser/extensions/updater/extension_updater.cc
index e4843d134026f8c8ba4f02579eb10fdef84232c1..1c64bc9bb74f59401e14b8aa2fbe7837b7224da2 100644
--- a/chrome/browser/extensions/updater/extension_updater.cc
+++ b/chrome/browser/extensions/updater/extension_updater.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
-#include "chrome/browser/extensions/updater/extension_downloader.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -136,10 +135,11 @@ ExtensionUpdater::ExtensionUpdater(
Profile* profile,
int frequency_seconds,
ExtensionCache* cache,
- scoped_ptr<IdentityProvider> webstore_identity_provider)
+ const ExtensionDownloader::Factory& downloader_factory)
: alive_(false),
weak_ptr_factory_(this),
service_(service),
+ downloader_factory_(downloader_factory),
frequency_seconds_(frequency_seconds),
will_check_soon_(false),
extension_prefs_(extension_prefs),
@@ -148,8 +148,7 @@ ExtensionUpdater::ExtensionUpdater(
next_request_id_(0),
extension_registry_observer_(this),
crx_install_is_running_(false),
- extension_cache_(cache),
- webstore_identity_provider_(webstore_identity_provider.release()) {
+ extension_cache_(cache) {
DCHECK_GE(frequency_seconds_, 5);
DCHECK_LE(frequency_seconds_, kMaxUpdateFrequencySeconds);
#if defined(NDEBUG)
@@ -165,6 +164,12 @@ ExtensionUpdater::~ExtensionUpdater() {
Stop();
}
+void ExtensionUpdater::EnsureDownloaderCreated() {
+ if (!downloader_.get()) {
+ downloader_ = downloader_factory_.Run(this);
+ }
+}
+
// The overall goal here is to balance keeping clients up to date while
// avoiding a thundering herd against update servers.
TimeDelta ExtensionUpdater::DetermineFirstCheckDelay() {
@@ -342,12 +347,7 @@ void ExtensionUpdater::CheckNow(const CheckParams& params) {
request.callback = params.callback;
request.install_immediately = params.install_immediately;
- if (!downloader_.get()) {
- downloader_.reset(
- new ExtensionDownloader(this,
- profile_->GetRequestContext(),
- webstore_identity_provider_.get()));
- }
+ EnsureDownloaderCreated();
// Add fetch records for extensions that should be fetched by an update URL.
// These extensions are not yet installed. They come from group policy
« no previous file with comments | « chrome/browser/extensions/updater/extension_updater.h ('k') | chrome/browser/extensions/updater/extension_updater_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698