| 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/component_updater/component_updater_service.h" | 5 #include "chrome/browser/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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 id.append(1, val + 'a'); | 66 id.append(1, val + 'a'); |
| 67 } else { | 67 } else { |
| 68 id.append(1, 'a'); | 68 id.append(1, 'a'); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 DCHECK(extensions::Extension::IdIsValid(id)); | 71 DCHECK(extensions::Extension::IdIsValid(id)); |
| 72 return id; | 72 return id; |
| 73 } | 73 } |
| 74 | 74 |
| 75 // Returns true if the |proposed| version is newer than |current| version. | 75 // Returns true if the |proposed| version is newer than |current| version. |
| 76 bool IsVersionNewer(const Version& current, const std::string& proposed) { | 76 bool IsVersionNewer(const base::Version& current, const std::string& proposed) { |
| 77 Version proposed_ver(proposed); | 77 base::Version proposed_ver(proposed); |
| 78 return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; | 78 return proposed_ver.IsValid() && current.CompareTo(proposed_ver) < 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Helper template class that allows our main class to have separate | 81 // Helper template class that allows our main class to have separate |
| 82 // OnURLFetchComplete() callbacks for different types of url requests | 82 // OnURLFetchComplete() callbacks for different types of url requests |
| 83 // they are differentiated by the |Ctx| type. | 83 // they are differentiated by the |Ctx| type. |
| 84 template <typename Del, typename Ctx> | 84 template <typename Del, typename Ctx> |
| 85 class DelegateWithContext : public net::URLFetcherDelegate { | 85 class DelegateWithContext : public net::URLFetcherDelegate { |
| 86 public: | 86 public: |
| 87 DelegateWithContext(Del* delegate, Ctx* context) | 87 DelegateWithContext(Del* delegate, Ctx* context) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 scoped_ptr<CrxDownloader> crx_downloader_; | 322 scoped_ptr<CrxDownloader> crx_downloader_; |
| 323 | 323 |
| 324 // A collection of every work item. | 324 // A collection of every work item. |
| 325 typedef std::vector<CrxUpdateItem*> UpdateItems; | 325 typedef std::vector<CrxUpdateItem*> UpdateItems; |
| 326 UpdateItems work_items_; | 326 UpdateItems work_items_; |
| 327 | 327 |
| 328 base::OneShotTimer<CrxUpdateService> timer_; | 328 base::OneShotTimer<CrxUpdateService> timer_; |
| 329 | 329 |
| 330 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 330 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
| 331 | 331 |
| 332 const Version chrome_version_; | 332 const base::Version chrome_version_; |
| 333 | 333 |
| 334 bool running_; | 334 bool running_; |
| 335 | 335 |
| 336 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); | 336 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); |
| 337 }; | 337 }; |
| 338 | 338 |
| 339 ////////////////////////////////////////////////////////////////////////////// | 339 ////////////////////////////////////////////////////////////////////////////// |
| 340 | 340 |
| 341 CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config) | 341 CrxUpdateService::CrxUpdateService(ComponentUpdateService::Configurator* config) |
| 342 : config_(config), | 342 : config_(config), |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 app_attributes.c_str(), | 731 app_attributes.c_str(), |
| 732 item->component.fingerprint.c_str()); | 732 item->component.fingerprint.c_str()); |
| 733 | 733 |
| 734 update_check_items->append(app); | 734 update_check_items->append(app); |
| 735 | 735 |
| 736 ChangeItemState(item, CrxUpdateItem::kChecking); | 736 ChangeItemState(item, CrxUpdateItem::kChecking); |
| 737 item->last_check = base::Time::Now(); | 737 item->last_check = base::Time::Now(); |
| 738 item->crx_urls.clear(); | 738 item->crx_urls.clear(); |
| 739 item->crx_diffurls.clear(); | 739 item->crx_diffurls.clear(); |
| 740 item->previous_version = item->component.version; | 740 item->previous_version = item->component.version; |
| 741 item->next_version = Version(); | 741 item->next_version = base::Version(); |
| 742 item->previous_fp = item->component.fingerprint; | 742 item->previous_fp = item->component.fingerprint; |
| 743 item->next_fp.clear(); | 743 item->next_fp.clear(); |
| 744 item->diff_update_failed = false; | 744 item->diff_update_failed = false; |
| 745 item->error_category = 0; | 745 item->error_category = 0; |
| 746 item->error_code = 0; | 746 item->error_code = 0; |
| 747 item->extra_code1 = 0; | 747 item->extra_code1 = 0; |
| 748 item->diff_error_category = 0; | 748 item->diff_error_category = 0; |
| 749 item->diff_error_code = 0; | 749 item->diff_error_code = 0; |
| 750 item->diff_extra_code1 = 0; | 750 item->diff_extra_code1 = 0; |
| 751 item->download_metrics.clear(); | 751 item->download_metrics.clear(); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 } | 842 } |
| 843 } | 843 } |
| 844 | 844 |
| 845 if (it->manifest.packages.size() != 1) { | 845 if (it->manifest.packages.size() != 1) { |
| 846 // Assume one and only one package per component. | 846 // Assume one and only one package per component. |
| 847 ChangeItemState(crx, CrxUpdateItem::kNoUpdate); | 847 ChangeItemState(crx, CrxUpdateItem::kNoUpdate); |
| 848 continue; | 848 continue; |
| 849 } | 849 } |
| 850 | 850 |
| 851 // Parse the members of the result and queue an upgrade for this component. | 851 // Parse the members of the result and queue an upgrade for this component. |
| 852 crx->next_version = Version(it->manifest.version); | 852 crx->next_version = base::Version(it->manifest.version); |
| 853 | 853 |
| 854 typedef component_updater:: | 854 typedef component_updater:: |
| 855 UpdateResponse::Result::Manifest::Package Package; | 855 UpdateResponse::Result::Manifest::Package Package; |
| 856 const Package& package(it->manifest.packages[0]); | 856 const Package& package(it->manifest.packages[0]); |
| 857 crx->next_fp = package.fingerprint; | 857 crx->next_fp = package.fingerprint; |
| 858 | 858 |
| 859 // Resolve the urls by combining the base urls with the package names. | 859 // Resolve the urls by combining the base urls with the package names. |
| 860 for (size_t i = 0; i != it->crx_urls.size(); ++i) { | 860 for (size_t i = 0; i != it->crx_urls.size(); ++i) { |
| 861 const GURL url(it->crx_urls[i].Resolve(package.name)); | 861 const GURL url(it->crx_urls[i].Resolve(package.name)); |
| 862 if (url.is_valid()) | 862 if (url.is_valid()) |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 // The component update factory. Using the component updater as a singleton | 1107 // The component update factory. Using the component updater as a singleton |
| 1108 // is the job of the browser process. | 1108 // is the job of the browser process. |
| 1109 ComponentUpdateService* ComponentUpdateServiceFactory( | 1109 ComponentUpdateService* ComponentUpdateServiceFactory( |
| 1110 ComponentUpdateService::Configurator* config) { | 1110 ComponentUpdateService::Configurator* config) { |
| 1111 DCHECK(config); | 1111 DCHECK(config); |
| 1112 return new CrxUpdateService(config); | 1112 return new CrxUpdateService(config); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| OLD | NEW |