OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 void ExtensionUpdater::Start() { | 411 void ExtensionUpdater::Start() { |
412 // Make sure our prefs are registered, then schedule the first check. | 412 // Make sure our prefs are registered, then schedule the first check. |
413 EnsureInt64PrefRegistered(prefs_, kLastExtensionsUpdateCheck); | 413 EnsureInt64PrefRegistered(prefs_, kLastExtensionsUpdateCheck); |
414 EnsureInt64PrefRegistered(prefs_, kNextExtensionsUpdateCheck); | 414 EnsureInt64PrefRegistered(prefs_, kNextExtensionsUpdateCheck); |
415 EnsureBlacklistVersionPrefRegistered(prefs_); | 415 EnsureBlacklistVersionPrefRegistered(prefs_); |
416 ScheduleNextCheck(DetermineFirstCheckDelay()); | 416 ScheduleNextCheck(DetermineFirstCheckDelay()); |
417 } | 417 } |
418 | 418 |
419 void ExtensionUpdater::Stop() { | 419 void ExtensionUpdater::Stop() { |
| 420 service_ = NULL; |
420 timer_.Stop(); | 421 timer_.Stop(); |
421 manifest_fetcher_.reset(); | 422 manifest_fetcher_.reset(); |
422 extension_fetcher_.reset(); | 423 extension_fetcher_.reset(); |
423 manifests_pending_.clear(); | 424 manifests_pending_.clear(); |
424 extensions_pending_.clear(); | 425 extensions_pending_.clear(); |
425 } | 426 } |
426 | 427 |
427 void ExtensionUpdater::OnURLFetchComplete( | 428 void ExtensionUpdater::OnURLFetchComplete( |
428 const URLFetcher* source, const GURL& url, const URLRequestStatus& status, | 429 const URLFetcher* source, const GURL& url, const URLRequestStatus& status, |
429 int response_code, const ResponseCookies& cookies, | 430 int response_code, const ResponseCookies& cookies, |
430 const std::string& data) { | 431 const std::string& data) { |
| 432 // This can be called after we've been stopped. |
| 433 if (!service_) |
| 434 return; |
| 435 |
431 if (source == manifest_fetcher_.get()) { | 436 if (source == manifest_fetcher_.get()) { |
432 OnManifestFetchComplete(url, status, response_code, data); | 437 OnManifestFetchComplete(url, status, response_code, data); |
433 } else if (source == extension_fetcher_.get()) { | 438 } else if (source == extension_fetcher_.get()) { |
434 OnCRXFetchComplete(url, status, response_code, data); | 439 OnCRXFetchComplete(url, status, response_code, data); |
435 } else { | 440 } else { |
436 NOTREACHED(); | 441 NOTREACHED(); |
437 } | 442 } |
438 } | 443 } |
439 | 444 |
440 // Utility class to handle doing xml parsing in a sandboxed utility process. | 445 // Utility class to handle doing xml parsing in a sandboxed utility process. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 if (!manifests_pending_.empty()) { | 538 if (!manifests_pending_.empty()) { |
534 ManifestFetchData* manifest_fetch = manifests_pending_.front(); | 539 ManifestFetchData* manifest_fetch = manifests_pending_.front(); |
535 manifests_pending_.pop_front(); | 540 manifests_pending_.pop_front(); |
536 StartUpdateCheck(manifest_fetch); | 541 StartUpdateCheck(manifest_fetch); |
537 } | 542 } |
538 } | 543 } |
539 | 544 |
540 void ExtensionUpdater::HandleManifestResults( | 545 void ExtensionUpdater::HandleManifestResults( |
541 const ManifestFetchData& fetch_data, | 546 const ManifestFetchData& fetch_data, |
542 const UpdateManifest::Results& results) { | 547 const UpdateManifest::Results& results) { |
| 548 // This can be called after we've been stopped. |
| 549 if (!service_) |
| 550 return; |
543 | 551 |
544 // Examine the parsed manifest and kick off fetches of any new crx files. | 552 // Examine the parsed manifest and kick off fetches of any new crx files. |
545 std::vector<int> updates = DetermineUpdates(fetch_data, results); | 553 std::vector<int> updates = DetermineUpdates(fetch_data, results); |
546 for (size_t i = 0; i < updates.size(); i++) { | 554 for (size_t i = 0; i < updates.size(); i++) { |
547 const UpdateManifest::Result* update = &(results.list.at(updates[i])); | 555 const UpdateManifest::Result* update = &(results.list.at(updates[i])); |
548 FetchUpdatedExtension(update->extension_id, update->crx_url, | 556 FetchUpdatedExtension(update->extension_id, update->crx_url, |
549 update->package_hash, update->version); | 557 update->package_hash, update->version); |
550 } | 558 } |
551 | 559 |
552 // If the manifest response included a <daystart> element, we want to save | 560 // If the manifest response included a <daystart> element, we want to save |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); | 868 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); |
861 extension_fetcher_->set_request_context( | 869 extension_fetcher_->set_request_context( |
862 Profile::GetDefaultRequestContext()); | 870 Profile::GetDefaultRequestContext()); |
863 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 871 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | |
864 net::LOAD_DO_NOT_SAVE_COOKIES | | 872 net::LOAD_DO_NOT_SAVE_COOKIES | |
865 net::LOAD_DISABLE_CACHE); | 873 net::LOAD_DISABLE_CACHE); |
866 extension_fetcher_->Start(); | 874 extension_fetcher_->Start(); |
867 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); | 875 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); |
868 } | 876 } |
869 } | 877 } |
OLD | NEW |