OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 11 matching lines...) Expand all Loading... |
22 #include "base/timer/timer.h" | 22 #include "base/timer/timer.h" |
23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/component_updater/component_unpacker.h" | 24 #include "chrome/browser/component_updater/component_unpacker.h" |
25 #include "chrome/browser/component_updater/component_updater_configurator.h" | 25 #include "chrome/browser/component_updater/component_updater_configurator.h" |
26 #include "chrome/browser/component_updater/component_updater_ping_manager.h" | 26 #include "chrome/browser/component_updater/component_updater_ping_manager.h" |
27 #include "chrome/browser/component_updater/component_updater_utils.h" | 27 #include "chrome/browser/component_updater/component_updater_utils.h" |
28 #include "chrome/browser/component_updater/crx_downloader.h" | 28 #include "chrome/browser/component_updater/crx_downloader.h" |
29 #include "chrome/browser/component_updater/crx_update_item.h" | 29 #include "chrome/browser/component_updater/crx_update_item.h" |
30 #include "chrome/browser/component_updater/update_checker.h" | 30 #include "chrome/browser/component_updater/update_checker.h" |
31 #include "chrome/browser/component_updater/update_response.h" | 31 #include "chrome/browser/component_updater/update_response.h" |
32 #include "chrome/common/chrome_version_info.h" | |
33 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/resource_controller.h" | 33 #include "content/public/browser/resource_controller.h" |
35 #include "content/public/browser/resource_throttle.h" | 34 #include "content/public/browser/resource_throttle.h" |
36 #include "url/gurl.h" | 35 #include "url/gurl.h" |
37 | 36 |
38 using content::BrowserThread; | 37 using content::BrowserThread; |
39 | 38 |
40 namespace component_updater { | 39 namespace component_updater { |
41 | 40 |
42 // The component updater is designed to live until process shutdown, so | 41 // The component updater is designed to live until process shutdown, so |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 scoped_ptr<CrxDownloader> crx_downloader_; | 255 scoped_ptr<CrxDownloader> crx_downloader_; |
257 | 256 |
258 // A collection of every work item. | 257 // A collection of every work item. |
259 typedef std::vector<CrxUpdateItem*> UpdateItems; | 258 typedef std::vector<CrxUpdateItem*> UpdateItems; |
260 UpdateItems work_items_; | 259 UpdateItems work_items_; |
261 | 260 |
262 base::OneShotTimer<CrxUpdateService> timer_; | 261 base::OneShotTimer<CrxUpdateService> timer_; |
263 | 262 |
264 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; | 263 scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_; |
265 | 264 |
266 const Version chrome_version_; | |
267 | |
268 bool running_; | 265 bool running_; |
269 | 266 |
270 ObserverList<Observer> observer_list_; | 267 ObserverList<Observer> observer_list_; |
271 | 268 |
272 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); | 269 DISALLOW_COPY_AND_ASSIGN(CrxUpdateService); |
273 }; | 270 }; |
274 | 271 |
275 ////////////////////////////////////////////////////////////////////////////// | 272 ////////////////////////////////////////////////////////////////////////////// |
276 | 273 |
277 CrxUpdateService::CrxUpdateService(Configurator* config) | 274 CrxUpdateService::CrxUpdateService(Configurator* config) |
278 : config_(config), | 275 : config_(config), |
279 ping_manager_(new PingManager(*config)), | 276 ping_manager_(new PingManager(*config)), |
280 blocking_task_runner_( | 277 blocking_task_runner_( |
281 BrowserThread::GetBlockingPool()-> | 278 BrowserThread::GetBlockingPool()-> |
282 GetSequencedTaskRunnerWithShutdownBehavior( | 279 GetSequencedTaskRunnerWithShutdownBehavior( |
283 BrowserThread::GetBlockingPool()->GetSequenceToken(), | 280 BrowserThread::GetBlockingPool()->GetSequenceToken(), |
284 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), | 281 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)), |
285 chrome_version_(chrome::VersionInfo().Version()), | |
286 running_(false) { | 282 running_(false) { |
287 } | 283 } |
288 | 284 |
289 CrxUpdateService::~CrxUpdateService() { | 285 CrxUpdateService::~CrxUpdateService() { |
290 // Because we are a singleton, at this point only the UI thread should be | 286 // Because we are a singleton, at this point only the UI thread should be |
291 // alive, this simplifies the management of the work that could be in | 287 // alive, this simplifies the management of the work that could be in |
292 // flight in other threads. | 288 // flight in other threads. |
293 Stop(); | 289 Stop(); |
294 STLDeleteElements(&work_items_); | 290 STLDeleteElements(&work_items_); |
295 } | 291 } |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 } | 709 } |
714 | 710 |
715 if (!IsVersionNewer(crx->component.version, it->manifest.version)) { | 711 if (!IsVersionNewer(crx->component.version, it->manifest.version)) { |
716 // The component is up to date. | 712 // The component is up to date. |
717 ChangeItemState(crx, CrxUpdateItem::kUpToDate); | 713 ChangeItemState(crx, CrxUpdateItem::kUpToDate); |
718 VLOG(1) << "Component already up-to-date: " << crx->id; | 714 VLOG(1) << "Component already up-to-date: " << crx->id; |
719 continue; | 715 continue; |
720 } | 716 } |
721 | 717 |
722 if (!it->manifest.browser_min_version.empty()) { | 718 if (!it->manifest.browser_min_version.empty()) { |
723 if (IsVersionNewer(chrome_version_, it->manifest.browser_min_version)) { | 719 if (IsVersionNewer(config_->GetBrowserVersion(), |
| 720 it->manifest.browser_min_version)) { |
724 // The component is not compatible with this Chrome version. | 721 // The component is not compatible with this Chrome version. |
725 VLOG(1) << "Ignoring incompatible component: " << crx->id; | 722 VLOG(1) << "Ignoring incompatible component: " << crx->id; |
726 ChangeItemState(crx, CrxUpdateItem::kNoUpdate); | 723 ChangeItemState(crx, CrxUpdateItem::kNoUpdate); |
727 continue; | 724 continue; |
728 } | 725 } |
729 } | 726 } |
730 | 727 |
731 if (it->manifest.packages.size() != 1) { | 728 if (it->manifest.packages.size() != 1) { |
732 // Assume one and only one package per component. | 729 // Assume one and only one package per component. |
733 VLOG(1) << "Ignoring multiple packages for component: " << crx->id; | 730 VLOG(1) << "Ignoring multiple packages for component: " << crx->id; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 } | 1089 } |
1093 | 1090 |
1094 // The component update factory. Using the component updater as a singleton | 1091 // The component update factory. Using the component updater as a singleton |
1095 // is the job of the browser process. | 1092 // is the job of the browser process. |
1096 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { | 1093 ComponentUpdateService* ComponentUpdateServiceFactory(Configurator* config) { |
1097 DCHECK(config); | 1094 DCHECK(config); |
1098 return new CrxUpdateService(config); | 1095 return new CrxUpdateService(config); |
1099 } | 1096 } |
1100 | 1097 |
1101 } // namespace component_updater | 1098 } // namespace component_updater |
OLD | NEW |