| 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_downloader.h" | 5 #include "chrome/browser/extensions/updater/extension_downloader.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 if (source->FileErrorOccurred(&error_code)) { | 712 if (source->FileErrorOccurred(&error_code)) { |
| 713 LOG(ERROR) << "Failed to write update CRX with id " << id << ". " | 713 LOG(ERROR) << "Failed to write update CRX with id " << id << ". " |
| 714 << "Error is "<< net::ErrorToString(error_code); | 714 << "Error is "<< net::ErrorToString(error_code); |
| 715 RecordCRXWriteHistogram(false, base::FilePath()); | 715 RecordCRXWriteHistogram(false, base::FilePath()); |
| 716 delegate_->OnExtensionDownloadFailed( | 716 delegate_->OnExtensionDownloadFailed( |
| 717 id, ExtensionDownloaderDelegate::CRX_FETCH_FAILED, ping, request_ids); | 717 id, ExtensionDownloaderDelegate::CRX_FETCH_FAILED, ping, request_ids); |
| 718 } else if (status.status() == net::URLRequestStatus::SUCCESS && | 718 } else if (status.status() == net::URLRequestStatus::SUCCESS && |
| 719 (response_code == 200 || url.SchemeIsFile())) { | 719 (response_code == 200 || url.SchemeIsFile())) { |
| 720 RETRY_HISTOGRAM("CrxFetchSuccess", | 720 RETRY_HISTOGRAM("CrxFetchSuccess", |
| 721 extensions_queue_.active_request_failure_count(), url); | 721 extensions_queue_.active_request_failure_count(), url); |
| 722 if (id == kBlacklistAppID) { | 722 base::FilePath crx_path; |
| 723 std::string data; | 723 // Take ownership of the file at |crx_path|. |
| 724 source->GetResponseAsString(&data); | 724 CHECK(source->GetResponseAsFilePath(true, &crx_path)); |
| 725 // TODO(asargent): try to get rid of this special case for the blacklist | 725 RecordCRXWriteHistogram(true, crx_path); |
| 726 // to simplify the delegate's interface. | 726 delegate_->OnExtensionDownloadFinished( |
| 727 delegate_->OnBlacklistDownloadFinished( | 727 id, crx_path, url, extensions_queue_.active_request()->version, |
| 728 data, extensions_queue_.active_request()->package_hash, | 728 ping, request_ids); |
| 729 extensions_queue_.active_request()->version, ping, request_ids); | |
| 730 } else { | |
| 731 base::FilePath crx_path; | |
| 732 // Take ownership of the file at |crx_path|. | |
| 733 CHECK(source->GetResponseAsFilePath(true, &crx_path)); | |
| 734 RecordCRXWriteHistogram(true, crx_path); | |
| 735 delegate_->OnExtensionDownloadFinished( | |
| 736 id, crx_path, url, extensions_queue_.active_request()->version, | |
| 737 ping, request_ids); | |
| 738 } | |
| 739 } else { | 729 } else { |
| 740 VLOG(1) << "Failed to fetch extension '" << url.possibly_invalid_spec() | 730 VLOG(1) << "Failed to fetch extension '" << url.possibly_invalid_spec() |
| 741 << "' response code:" << response_code; | 731 << "' response code:" << response_code; |
| 742 if (ShouldRetryRequest(status, response_code) && | 732 if (ShouldRetryRequest(status, response_code) && |
| 743 extensions_queue_.active_request_failure_count() < kMaxRetries) { | 733 extensions_queue_.active_request_failure_count() < kMaxRetries) { |
| 744 extensions_queue_.RetryRequest(backoff_delay); | 734 extensions_queue_.RetryRequest(backoff_delay); |
| 745 } else { | 735 } else { |
| 746 RETRY_HISTOGRAM("CrxFetchFailure", | 736 RETRY_HISTOGRAM("CrxFetchFailure", |
| 747 extensions_queue_.active_request_failure_count(), url); | 737 extensions_queue_.active_request_failure_count(), url); |
| 748 delegate_->OnExtensionDownloadFailed( | 738 delegate_->OnExtensionDownloadFailed( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 774 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, | 764 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, |
| 775 const std::string& version) { | 765 const std::string& version) { |
| 776 UpdateDetails updateInfo(id, Version(version)); | 766 UpdateDetails updateInfo(id, Version(version)); |
| 777 content::NotificationService::current()->Notify( | 767 content::NotificationService::current()->Notify( |
| 778 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, | 768 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, |
| 779 content::NotificationService::AllBrowserContextsAndSources(), | 769 content::NotificationService::AllBrowserContextsAndSources(), |
| 780 content::Details<UpdateDetails>(&updateInfo)); | 770 content::Details<UpdateDetails>(&updateInfo)); |
| 781 } | 771 } |
| 782 | 772 |
| 783 } // namespace extensions | 773 } // namespace extensions |
| OLD | NEW |