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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // There are no locks in this code, the main structure |work_items_| is mutated | 99 // There are no locks in this code, the main structure |work_items_| is mutated |
100 // only from the main thread. The unpack and installation is done in a blocking | 100 // only from the main thread. The unpack and installation is done in a blocking |
101 // pool thread. The network requests are done in the IO thread or in the file | 101 // pool thread. The network requests are done in the IO thread or in the file |
102 // thread. | 102 // thread. |
103 class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { | 103 class CrxUpdateService : public ComponentUpdateService, public OnDemandUpdater { |
104 public: | 104 public: |
105 explicit CrxUpdateService(Configurator* config); | 105 explicit CrxUpdateService(Configurator* config); |
106 virtual ~CrxUpdateService(); | 106 virtual ~CrxUpdateService(); |
107 | 107 |
108 // Overrides for ComponentUpdateService. | 108 // Overrides for ComponentUpdateService. |
109 virtual void AddObserver(Observer* observer) OVERRIDE; | 109 virtual void AddObserver(Observer* observer) override; |
110 virtual void RemoveObserver(Observer* observer) OVERRIDE; | 110 virtual void RemoveObserver(Observer* observer) override; |
111 virtual Status Start() OVERRIDE; | 111 virtual Status Start() override; |
112 virtual Status Stop() OVERRIDE; | 112 virtual Status Stop() override; |
113 virtual Status RegisterComponent(const CrxComponent& component) OVERRIDE; | 113 virtual Status RegisterComponent(const CrxComponent& component) override; |
114 virtual std::vector<std::string> GetComponentIDs() const OVERRIDE; | 114 virtual std::vector<std::string> GetComponentIDs() const override; |
115 virtual OnDemandUpdater& GetOnDemandUpdater() OVERRIDE; | 115 virtual OnDemandUpdater& GetOnDemandUpdater() override; |
116 virtual void MaybeThrottle(const std::string& crx_id, | 116 virtual void MaybeThrottle(const std::string& crx_id, |
117 const base::Closure& callback) OVERRIDE; | 117 const base::Closure& callback) override; |
118 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() | 118 virtual scoped_refptr<base::SequencedTaskRunner> GetSequencedTaskRunner() |
119 OVERRIDE; | 119 override; |
120 | 120 |
121 // Context for a crx download url request. | 121 // Context for a crx download url request. |
122 struct CRXContext { | 122 struct CRXContext { |
123 ComponentInstaller* installer; | 123 ComponentInstaller* installer; |
124 std::vector<uint8_t> pk_hash; | 124 std::vector<uint8_t> pk_hash; |
125 std::string id; | 125 std::string id; |
126 std::string fingerprint; | 126 std::string fingerprint; |
127 CRXContext() : installer(NULL) {} | 127 CRXContext() : installer(NULL) {} |
128 }; | 128 }; |
129 | 129 |
130 private: | 130 private: |
131 enum ErrorCategory { | 131 enum ErrorCategory { |
132 kErrorNone = 0, | 132 kErrorNone = 0, |
133 kNetworkError, | 133 kNetworkError, |
134 kUnpackError, | 134 kUnpackError, |
135 kInstallError, | 135 kInstallError, |
136 }; | 136 }; |
137 | 137 |
138 enum StepDelayInterval { | 138 enum StepDelayInterval { |
139 kStepDelayShort = 0, | 139 kStepDelayShort = 0, |
140 kStepDelayMedium, | 140 kStepDelayMedium, |
141 kStepDelayLong, | 141 kStepDelayLong, |
142 }; | 142 }; |
143 | 143 |
144 // Overrides for ComponentUpdateService. | 144 // Overrides for ComponentUpdateService. |
145 virtual bool GetComponentDetails(const std::string& component_id, | 145 virtual bool GetComponentDetails(const std::string& component_id, |
146 CrxUpdateItem* item) const OVERRIDE; | 146 CrxUpdateItem* item) const override; |
147 | 147 |
148 // Overrides for OnDemandUpdater. | 148 // Overrides for OnDemandUpdater. |
149 virtual Status OnDemandUpdate(const std::string& component_id) OVERRIDE; | 149 virtual Status OnDemandUpdate(const std::string& component_id) override; |
150 | 150 |
151 void UpdateCheckComplete(const GURL& original_url, | 151 void UpdateCheckComplete(const GURL& original_url, |
152 int error, | 152 int error, |
153 const std::string& error_message, | 153 const std::string& error_message, |
154 const UpdateResponse::Results& results); | 154 const UpdateResponse::Results& results); |
155 void OnUpdateCheckSucceeded(const UpdateResponse::Results& results); | 155 void OnUpdateCheckSucceeded(const UpdateResponse::Results& results); |
156 void OnUpdateCheckFailed(int error, const std::string& error_message); | 156 void OnUpdateCheckFailed(int error, const std::string& error_message); |
157 | 157 |
158 void DownloadProgress(const std::string& component_id, | 158 void DownloadProgress(const std::string& component_id, |
159 const CrxDownloader::Result& download_result); | 159 const CrxDownloader::Result& download_result); |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 /////////////////////////////////////////////////////////////////////////////// | 1014 /////////////////////////////////////////////////////////////////////////////// |
1015 | 1015 |
1016 // The component update factory. Using the component updater as a singleton | 1016 // The component update factory. Using the component updater as a singleton |
1017 // is the job of the browser process. | 1017 // is the job of the browser process. |
1018 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { | 1018 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { |
1019 DCHECK(config); | 1019 DCHECK(config); |
1020 return new CrxUpdateService(config); | 1020 return new CrxUpdateService(config); |
1021 } | 1021 } |
1022 | 1022 |
1023 } // namespace component_updater | 1023 } // namespace component_updater |
OLD | NEW |