| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/component_updater/component_updater_service.h" | 5 #include "components/component_updater/component_updater_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 kStepDelayLong, | 139 kStepDelayLong, |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 // Overrides for ComponentUpdateService. | 142 // Overrides for ComponentUpdateService. |
| 143 virtual bool GetComponentDetails(const std::string& component_id, | 143 virtual bool GetComponentDetails(const std::string& component_id, |
| 144 CrxUpdateItem* item) const OVERRIDE; | 144 CrxUpdateItem* item) const OVERRIDE; |
| 145 | 145 |
| 146 // Overrides for OnDemandUpdater. | 146 // Overrides for OnDemandUpdater. |
| 147 virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE; | 147 virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE; |
| 148 | 148 |
| 149 void UpdateCheckComplete(int error, | 149 void UpdateCheckComplete(const GURL& original_url, |
| 150 int error, |
| 150 const std::string& error_message, | 151 const std::string& error_message, |
| 151 const UpdateResponse::Results& results); | 152 const UpdateResponse::Results& results); |
| 152 void OnUpdateCheckSucceeded(const UpdateResponse::Results& results); | 153 void OnUpdateCheckSucceeded(const UpdateResponse::Results& results); |
| 153 void OnUpdateCheckFailed(int error, const std::string& error_message); | 154 void OnUpdateCheckFailed(int error, const std::string& error_message); |
| 154 | 155 |
| 155 void DownloadProgress(const std::string& component_id, | 156 void DownloadProgress(const std::string& component_id, |
| 156 const CrxDownloader::Result& download_result); | 157 const CrxDownloader::Result& download_result); |
| 157 | 158 |
| 158 void DownloadComplete(scoped_ptr<CRXContext> crx_context, | 159 void DownloadComplete(scoped_ptr<CRXContext> crx_context, |
| 159 const CrxDownloader::Result& download_result); | 160 const CrxDownloader::Result& download_result); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 item->download_metrics.clear(); | 607 item->download_metrics.clear(); |
| 607 | 608 |
| 608 items_to_check.push_back(item); | 609 items_to_check.push_back(item); |
| 609 | 610 |
| 610 ChangeItemState(item, CrxUpdateItem::kChecking); | 611 ChangeItemState(item, CrxUpdateItem::kChecking); |
| 611 } | 612 } |
| 612 | 613 |
| 613 if (items_to_check.empty()) | 614 if (items_to_check.empty()) |
| 614 return false; | 615 return false; |
| 615 | 616 |
| 616 update_checker_ = | 617 update_checker_ = UpdateChecker::Create(*config_).Pass(); |
| 617 UpdateChecker::Create(*config_, | 618 return update_checker_->CheckForUpdates( |
| 618 base::Bind(&CrxUpdateService::UpdateCheckComplete, | 619 items_to_check, |
| 619 base::Unretained(this))).Pass(); | 620 config_->ExtraRequestParams(), |
| 620 return update_checker_->CheckForUpdates(items_to_check, | 621 base::Bind(&CrxUpdateService::UpdateCheckComplete, |
| 621 config_->ExtraRequestParams()); | 622 base::Unretained(this))); |
| 622 } | 623 } |
| 623 | 624 |
| 624 void CrxUpdateService::UpdateComponent(CrxUpdateItem* workitem) { | 625 void CrxUpdateService::UpdateComponent(CrxUpdateItem* workitem) { |
| 625 scoped_ptr<CRXContext> crx_context(new CRXContext); | 626 scoped_ptr<CRXContext> crx_context(new CRXContext); |
| 626 crx_context->pk_hash = workitem->component.pk_hash; | 627 crx_context->pk_hash = workitem->component.pk_hash; |
| 627 crx_context->id = workitem->id; | 628 crx_context->id = workitem->id; |
| 628 crx_context->installer = workitem->component.installer; | 629 crx_context->installer = workitem->component.installer; |
| 629 crx_context->fingerprint = workitem->next_fp; | 630 crx_context->fingerprint = workitem->next_fp; |
| 630 const std::vector<GURL>* urls = NULL; | 631 const std::vector<GURL>* urls = NULL; |
| 631 bool allow_background_download = false; | 632 bool allow_background_download = false; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 654 base::Bind(&CrxUpdateService::DownloadProgress, | 655 base::Bind(&CrxUpdateService::DownloadProgress, |
| 655 base::Unretained(this), | 656 base::Unretained(this), |
| 656 crx_context->id)); | 657 crx_context->id)); |
| 657 crx_downloader_->StartDownload(*urls, | 658 crx_downloader_->StartDownload(*urls, |
| 658 base::Bind(&CrxUpdateService::DownloadComplete, | 659 base::Bind(&CrxUpdateService::DownloadComplete, |
| 659 base::Unretained(this), | 660 base::Unretained(this), |
| 660 base::Passed(&crx_context))); | 661 base::Passed(&crx_context))); |
| 661 } | 662 } |
| 662 | 663 |
| 663 void CrxUpdateService::UpdateCheckComplete( | 664 void CrxUpdateService::UpdateCheckComplete( |
| 665 const GURL& original_url, |
| 664 int error, | 666 int error, |
| 665 const std::string& error_message, | 667 const std::string& error_message, |
| 666 const UpdateResponse::Results& results) { | 668 const UpdateResponse::Results& results) { |
| 667 DCHECK(thread_checker_.CalledOnValidThread()); | 669 DCHECK(thread_checker_.CalledOnValidThread()); |
| 670 VLOG(1) << "Update check completed from: " << original_url.spec(); |
| 668 update_checker_.reset(); | 671 update_checker_.reset(); |
| 669 if (!error) | 672 if (!error) |
| 670 OnUpdateCheckSucceeded(results); | 673 OnUpdateCheckSucceeded(results); |
| 671 else | 674 else |
| 672 OnUpdateCheckFailed(error, error_message); | 675 OnUpdateCheckFailed(error, error_message); |
| 673 } | 676 } |
| 674 | 677 |
| 675 // Handles a valid Omaha update check response by matching the results with | 678 // Handles a valid Omaha update check response by matching the results with |
| 676 // the registered components which were checked for updates. | 679 // the registered components which were checked for updates. |
| 677 // If updates are found, prepare the components for the actual version upgrade. | 680 // If updates are found, prepare the components for the actual version upgrade. |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1009 /////////////////////////////////////////////////////////////////////////////// | 1012 /////////////////////////////////////////////////////////////////////////////// |
| 1010 | 1013 |
| 1011 // The component update factory. Using the component updater as a singleton | 1014 // The component update factory. Using the component updater as a singleton |
| 1012 // is the job of the browser process. | 1015 // is the job of the browser process. |
| 1013 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { | 1016 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { |
| 1014 DCHECK(config); | 1017 DCHECK(config); |
| 1015 return new CrxUpdateService(config); | 1018 return new CrxUpdateService(config); |
| 1016 } | 1019 } |
| 1017 | 1020 |
| 1018 } // namespace component_updater | 1021 } // namespace component_updater |
| OLD | NEW |