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 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 if (uit) { | 482 if (uit) { |
483 uit->component = component; | 483 uit->component = component; |
484 return kReplaced; | 484 return kReplaced; |
485 } | 485 } |
486 | 486 |
487 uit = new CrxUpdateItem; | 487 uit = new CrxUpdateItem; |
488 uit->id.swap(id); | 488 uit->id.swap(id); |
489 uit->component = component; | 489 uit->component = component; |
490 | 490 |
491 work_items_.push_back(uit); | 491 work_items_.push_back(uit); |
| 492 |
492 // If this is the first component registered we call Start to | 493 // If this is the first component registered we call Start to |
493 // schedule the first timer. | 494 // schedule the first timer. Otherwise, reset the timer to trigger another |
494 if (running_ && (work_items_.size() == 1)) | 495 // pass over the work items, if the component updater is sleeping, fact |
495 Start(); | 496 // indicated by a running timer. If the timer is not running, it means that |
| 497 // the service is busy updating something, and in that case, this component |
| 498 // will be picked up at the next pass. |
| 499 if (running_) { |
| 500 if (work_items_.size() == 1) { |
| 501 Start(); |
| 502 } else if (timer_.IsRunning()) { |
| 503 timer_.Start(FROM_HERE, |
| 504 base::TimeDelta::FromSeconds(config_->InitialDelay()), |
| 505 this, |
| 506 &CrxUpdateService::ProcessPendingItems); |
| 507 } |
| 508 } |
496 | 509 |
497 return kOk; | 510 return kOk; |
498 } | 511 } |
499 | 512 |
500 std::vector<std::string> CrxUpdateService::GetComponentIDs() const { | 513 std::vector<std::string> CrxUpdateService::GetComponentIDs() const { |
501 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 514 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
502 std::vector<std::string> component_ids; | 515 std::vector<std::string> component_ids; |
503 for (UpdateItems::const_iterator it = work_items_.begin(); | 516 for (UpdateItems::const_iterator it = work_items_.begin(); |
504 it != work_items_.end(); | 517 it != work_items_.end(); |
505 ++it) { | 518 ++it) { |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 | 1088 |
1076 // The component update factory. Using the component updater as a singleton | 1089 // The component update factory. Using the component updater as a singleton |
1077 // is the job of the browser process. | 1090 // is the job of the browser process. |
1078 ComponentUpdateService* ComponentUpdateServiceFactory( | 1091 ComponentUpdateService* ComponentUpdateServiceFactory( |
1079 ComponentUpdateService::Configurator* config) { | 1092 ComponentUpdateService::Configurator* config) { |
1080 DCHECK(config); | 1093 DCHECK(config); |
1081 return new CrxUpdateService(config); | 1094 return new CrxUpdateService(config); |
1082 } | 1095 } |
1083 | 1096 |
1084 } // namespace component_updater | 1097 } // namespace component_updater |
OLD | NEW |