| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/updater/extension_updater.h" | 5 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ThrottleInfo() | 122 ThrottleInfo() |
| 123 : in_progress(true), | 123 : in_progress(true), |
| 124 throttle_delay(kMinUpdateThrottleTime), | 124 throttle_delay(kMinUpdateThrottleTime), |
| 125 check_start(Time::Now()) {} | 125 check_start(Time::Now()) {} |
| 126 | 126 |
| 127 bool in_progress; | 127 bool in_progress; |
| 128 int throttle_delay; | 128 int throttle_delay; |
| 129 Time check_start; | 129 Time check_start; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 ExtensionUpdater::ExtensionUpdater(ExtensionServiceInterface* service, | 132 ExtensionUpdater::ExtensionUpdater( |
| 133 ExtensionPrefs* extension_prefs, | 133 ExtensionServiceInterface* service, |
| 134 PrefService* prefs, | 134 ExtensionPrefs* extension_prefs, |
| 135 Profile* profile, | 135 PrefService* prefs, |
| 136 int frequency_seconds, | 136 Profile* profile, |
| 137 ExtensionCache* cache) | 137 int frequency_seconds, |
| 138 ExtensionCache* cache, |
| 139 scoped_ptr<IdentityProvider> webstore_identity_provider) |
| 138 : alive_(false), | 140 : alive_(false), |
| 139 weak_ptr_factory_(this), | 141 weak_ptr_factory_(this), |
| 140 service_(service), frequency_seconds_(frequency_seconds), | 142 service_(service), |
| 141 will_check_soon_(false), extension_prefs_(extension_prefs), | 143 frequency_seconds_(frequency_seconds), |
| 142 prefs_(prefs), profile_(profile), | 144 will_check_soon_(false), |
| 145 extension_prefs_(extension_prefs), |
| 146 prefs_(prefs), |
| 147 profile_(profile), |
| 143 next_request_id_(0), | 148 next_request_id_(0), |
| 144 extension_registry_observer_(this), | 149 extension_registry_observer_(this), |
| 145 crx_install_is_running_(false), | 150 crx_install_is_running_(false), |
| 146 extension_cache_(cache) { | 151 extension_cache_(cache), |
| 152 webstore_identity_provider_(webstore_identity_provider.release()) { |
| 147 DCHECK_GE(frequency_seconds_, 5); | 153 DCHECK_GE(frequency_seconds_, 5); |
| 148 DCHECK_LE(frequency_seconds_, kMaxUpdateFrequencySeconds); | 154 DCHECK_LE(frequency_seconds_, kMaxUpdateFrequencySeconds); |
| 149 #if defined(NDEBUG) | 155 #if defined(NDEBUG) |
| 150 // In Release mode we enforce that update checks don't happen too often. | 156 // In Release mode we enforce that update checks don't happen too often. |
| 151 frequency_seconds_ = std::max(frequency_seconds_, kMinUpdateFrequencySeconds); | 157 frequency_seconds_ = std::max(frequency_seconds_, kMinUpdateFrequencySeconds); |
| 152 #endif | 158 #endif |
| 153 frequency_seconds_ = std::min(frequency_seconds_, kMaxUpdateFrequencySeconds); | 159 frequency_seconds_ = std::min(frequency_seconds_, kMaxUpdateFrequencySeconds); |
| 154 | 160 |
| 155 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); | 161 extension_registry_observer_.Add(ExtensionRegistry::Get(profile)); |
| 156 } | 162 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 NotifyStarted(); | 337 NotifyStarted(); |
| 332 | 338 |
| 333 DCHECK(alive_); | 339 DCHECK(alive_); |
| 334 | 340 |
| 335 InProgressCheck& request = requests_in_progress_[request_id]; | 341 InProgressCheck& request = requests_in_progress_[request_id]; |
| 336 request.callback = params.callback; | 342 request.callback = params.callback; |
| 337 request.install_immediately = params.install_immediately; | 343 request.install_immediately = params.install_immediately; |
| 338 | 344 |
| 339 if (!downloader_.get()) { | 345 if (!downloader_.get()) { |
| 340 downloader_.reset( | 346 downloader_.reset( |
| 341 new ExtensionDownloader(this, profile_->GetRequestContext())); | 347 new ExtensionDownloader(this, |
| 348 profile_->GetRequestContext(), |
| 349 webstore_identity_provider_.get())); |
| 342 } | 350 } |
| 343 | 351 |
| 344 // Add fetch records for extensions that should be fetched by an update URL. | 352 // Add fetch records for extensions that should be fetched by an update URL. |
| 345 // These extensions are not yet installed. They come from group policy | 353 // These extensions are not yet installed. They come from group policy |
| 346 // and external install sources. | 354 // and external install sources. |
| 347 const PendingExtensionManager* pending_extension_manager = | 355 const PendingExtensionManager* pending_extension_manager = |
| 348 service_->pending_extension_manager(); | 356 service_->pending_extension_manager(); |
| 349 | 357 |
| 350 std::list<std::string> pending_ids; | 358 std::list<std::string> pending_ids; |
| 351 | 359 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 const InProgressCheck& request = requests_in_progress_[request_id]; | 642 const InProgressCheck& request = requests_in_progress_[request_id]; |
| 635 if (request.in_progress_ids_.empty()) { | 643 if (request.in_progress_ids_.empty()) { |
| 636 VLOG(2) << "Finished update check " << request_id; | 644 VLOG(2) << "Finished update check " << request_id; |
| 637 if (!request.callback.is_null()) | 645 if (!request.callback.is_null()) |
| 638 request.callback.Run(); | 646 request.callback.Run(); |
| 639 requests_in_progress_.erase(request_id); | 647 requests_in_progress_.erase(request_id); |
| 640 } | 648 } |
| 641 } | 649 } |
| 642 | 650 |
| 643 } // namespace extensions | 651 } // namespace extensions |
| OLD | NEW |