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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 running_ = true; | 322 running_ = true; |
323 if (work_items_.empty()) | 323 if (work_items_.empty()) |
324 return kOk; | 324 return kOk; |
325 | 325 |
326 NotificationService::current()->Notify( | 326 NotificationService::current()->Notify( |
327 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, | 327 chrome::NOTIFICATION_COMPONENT_UPDATER_STARTED, |
328 Source<ComponentUpdateService>(this), | 328 Source<ComponentUpdateService>(this), |
329 NotificationService::NoDetails()); | 329 NotificationService::NoDetails()); |
330 | 330 |
331 timer_.Start(base::TimeDelta::FromSeconds(config_->InitialDelay()), | 331 timer_.Start(base::TimeDelta::FromSeconds(config_->InitialDelay()), |
332 this, &CrxUpdateService::ProcessPendingItems); | 332 this, &CrxUpdateService::ProcessPendingItems, FROM_HERE); |
333 return kOk; | 333 return kOk; |
334 } | 334 } |
335 | 335 |
336 // Stop the main check + update loop. In flight operations will be | 336 // Stop the main check + update loop. In flight operations will be |
337 // completed. | 337 // completed. |
338 ComponentUpdateService::Status CrxUpdateService::Stop() { | 338 ComponentUpdateService::Status CrxUpdateService::Stop() { |
339 running_ = false; | 339 running_ = false; |
340 timer_.Stop(); | 340 timer_.Stop(); |
341 return kOk; | 341 return kOk; |
342 } | 342 } |
(...skipping 17 matching lines...) Expand all Loading... |
360 NotificationService::current()->Notify( | 360 NotificationService::current()->Notify( |
361 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, | 361 chrome::NOTIFICATION_COMPONENT_UPDATER_SLEEPING, |
362 Source<ComponentUpdateService>(this), | 362 Source<ComponentUpdateService>(this), |
363 NotificationService::NoDetails()); | 363 NotificationService::NoDetails()); |
364 // Zero is only used for unit tests. | 364 // Zero is only used for unit tests. |
365 if (0 == delay) | 365 if (0 == delay) |
366 return; | 366 return; |
367 } | 367 } |
368 | 368 |
369 timer_.Start(base::TimeDelta::FromSeconds(delay), | 369 timer_.Start(base::TimeDelta::FromSeconds(delay), |
370 this, &CrxUpdateService::ProcessPendingItems); | 370 this, &CrxUpdateService::ProcessPendingItems, FROM_HERE); |
371 } | 371 } |
372 | 372 |
373 // Given a extension-like component id, find the associated component. | 373 // Given a extension-like component id, find the associated component. |
374 CrxUpdateItem* CrxUpdateService::FindUpdateItemById(const std::string& id) { | 374 CrxUpdateItem* CrxUpdateService::FindUpdateItemById(const std::string& id) { |
375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
376 CrxUpdateItem::FindById finder(id); | 376 CrxUpdateItem::FindById finder(id); |
377 UpdateItems::iterator it = std::find_if(work_items_.begin(), | 377 UpdateItems::iterator it = std::find_if(work_items_.begin(), |
378 work_items_.end(), | 378 work_items_.end(), |
379 finder); | 379 finder); |
380 if (it == work_items_.end()) | 380 if (it == work_items_.end()) |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 ScheduleNextRun(false); | 699 ScheduleNextRun(false); |
700 } | 700 } |
701 | 701 |
702 // The component update factory. Using the component updater as a singleton | 702 // The component update factory. Using the component updater as a singleton |
703 // is the job of the browser process. | 703 // is the job of the browser process. |
704 ComponentUpdateService* ComponentUpdateServiceFactory( | 704 ComponentUpdateService* ComponentUpdateServiceFactory( |
705 ComponentUpdateService::Configurator* config) { | 705 ComponentUpdateService::Configurator* config) { |
706 DCHECK(config); | 706 DCHECK(config); |
707 return new CrxUpdateService(config); | 707 return new CrxUpdateService(config); |
708 } | 708 } |
OLD | NEW |