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