| Index: chrome/browser/component_updater/component_updater_service.cc
|
| diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
|
| index fa04986f6829511953201f2f4fcabcf416b4cc2b..fcda0ca48e1dfcd689451e0d6d6c84b57a294e45 100644
|
| --- a/chrome/browser/component_updater/component_updater_service.cc
|
| +++ b/chrome/browser/component_updater/component_updater_service.cc
|
| @@ -16,6 +16,7 @@
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/memory/weak_ptr.h"
|
| +#include "base/rand_util.h"
|
| #include "base/sequenced_task_runner.h"
|
| #include "base/stl_util.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| @@ -574,23 +575,26 @@ void CrxUpdateService::ProcessPendingItems() {
|
| }
|
|
|
| CrxUpdateItem* CrxUpdateService::FindReadyComponent() const {
|
| - class Helper {
|
| - public:
|
| - static bool IsReadyOnDemand(CrxUpdateItem* item) {
|
| - return item->on_demand && IsReady(item);
|
| - }
|
| - static bool IsReady(CrxUpdateItem* item) {
|
| - return item->status == CrxUpdateItem::kCanUpdate;
|
| + std::vector<CrxUpdateItem*> ready;
|
| + std::vector<CrxUpdateItem*> ready_on_demand;
|
| + for (std::vector<CrxUpdateItem*>::const_iterator it = work_items_.begin();
|
| + it != work_items_.end();
|
| + ++it) {
|
| + CrxUpdateItem* item = *it;
|
| + if (item->status == CrxUpdateItem::kCanUpdate) {
|
| + if (item->on_demand)
|
| + ready_on_demand.push_back(item);
|
| + else
|
| + ready.push_back(item);
|
| }
|
| - };
|
| + }
|
|
|
| - std::vector<CrxUpdateItem*>::const_iterator it = std::find_if(
|
| - work_items_.begin(), work_items_.end(), Helper::IsReadyOnDemand);
|
| - if (it != work_items_.end())
|
| - return *it;
|
| - it = std::find_if(work_items_.begin(), work_items_.end(), Helper::IsReady);
|
| - if (it != work_items_.end())
|
| - return *it;
|
| + if (ready_on_demand.size() > 0) {
|
| + return ready_on_demand[base::RandInt(0, ready_on_demand.size() - 1)];
|
| + }
|
| + if (ready.size() > 0) {
|
| + return ready[base::RandInt(0, ready.size() - 1)];
|
| + }
|
| return NULL;
|
| }
|
|
|
|
|