| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 // we avoid scheduling the timer if there is no work to do. | 329 // we avoid scheduling the timer if there is no work to do. |
| 330 running_ = true; | 330 running_ = true; |
| 331 if (work_items_.empty()) | 331 if (work_items_.empty()) |
| 332 return kOk; | 332 return kOk; |
| 333 | 333 |
| 334 NotificationService::current()->Notify( | 334 NotificationService::current()->Notify( |
| 335 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, | 335 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, |
| 336 Source<ComponentUpdateService>(this), | 336 Source<ComponentUpdateService>(this), |
| 337 NotificationService::NoDetails()); | 337 NotificationService::NoDetails()); |
| 338 | 338 |
| 339 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(config_->InitialDelay()), | 339 timer_.Start(base::TimeDelta::FromSeconds(config_->InitialDelay()), |
| 340 this, &CrxUpdateService::ProcessPendingItems); | 340 this, &CrxUpdateService::ProcessPendingItems); |
| 341 return kOk; | 341 return kOk; |
| 342 } | 342 } |
| 343 | 343 |
| 344 // Stop the main check + update loop. In flight operations will be | 344 // Stop the main check + update loop. In flight operations will be |
| 345 // completed. | 345 // completed. |
| 346 ComponentUpdateService::Status CrxUpdateService::Stop() { | 346 ComponentUpdateService::Status CrxUpdateService::Stop() { |
| 347 running_ = false; | 347 running_ = false; |
| 348 timer_.Stop(); | 348 timer_.Stop(); |
| 349 return kOk; | 349 return kOk; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 367 if (!step_delay) { | 367 if (!step_delay) { |
| 368 NotificationService::current()->Notify( | 368 NotificationService::current()->Notify( |
| 369 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, | 369 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, |
| 370 Source<ComponentUpdateService>(this), | 370 Source<ComponentUpdateService>(this), |
| 371 NotificationService::NoDetails()); | 371 NotificationService::NoDetails()); |
| 372 // Zero is only used for unit tests. | 372 // Zero is only used for unit tests. |
| 373 if (0 == delay) | 373 if (0 == delay) |
| 374 return; | 374 return; |
| 375 } | 375 } |
| 376 | 376 |
| 377 timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(delay), | 377 timer_.Start(base::TimeDelta::FromSeconds(delay), |
| 378 this, &CrxUpdateService::ProcessPendingItems); | 378 this, &CrxUpdateService::ProcessPendingItems); |
| 379 } | 379 } |
| 380 | 380 |
| 381 // Given a extension-like component id, find the associated component. | 381 // Given a extension-like component id, find the associated component. |
| 382 CrxUpdateItem* CrxUpdateService::FindUpdateItemById(const std::string& id) { | 382 CrxUpdateItem* CrxUpdateService::FindUpdateItemById(const std::string& id) { |
| 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 384 CrxUpdateItem::FindById finder(id); | 384 CrxUpdateItem::FindById finder(id); |
| 385 UpdateItems::iterator it = std::find_if(work_items_.begin(), | 385 UpdateItems::iterator it = std::find_if(work_items_.begin(), |
| 386 work_items_.end(), | 386 work_items_.end(), |
| 387 finder); | 387 finder); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 ScheduleNextRun(false); | 725 ScheduleNextRun(false); |
| 726 } | 726 } |
| 727 | 727 |
| 728 // The component update factory. Using the component updater as a singleton | 728 // The component update factory. Using the component updater as a singleton |
| 729 // is the job of the browser process. | 729 // is the job of the browser process. |
| 730 ComponentUpdateService* ComponentUpdateServiceFactory( | 730 ComponentUpdateService* ComponentUpdateServiceFactory( |
| 731 ComponentUpdateService::Configurator* config) { | 731 ComponentUpdateService::Configurator* config) { |
| 732 DCHECK(config); | 732 DCHECK(config); |
| 733 return new CrxUpdateService(config); | 733 return new CrxUpdateService(config); |
| 734 } | 734 } |
| OLD | NEW |