Commit c4b4cfa1 authored by bartekn@chromium.org's avatar bartekn@chromium.org

Revert of Randomize order in which ready component updates are applied. On...

Revert of Randomize order in which ready component updates are applied. On demand updates (https://codereview.chromium.org/144523004/)

Reason for revert:
We need to guarantee that specific security components (i.e. CRLSet, Flash, and Recovery) always come first.

Original issue's description:
> Randomize order in which ready component updates are applied. On demand updates still take precedence.
> 
> BUG=343686
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=255832

TBR=sorin@chromium.org,bartekn@google.com
NOTREECHECKS=true
NOTRY=true
BUG=343686

Review URL: https://codereview.chromium.org/192283003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256001 0039d316-1c4b-4281-b951-d872f2087c98
parent 042f7313
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/rand_util.h"
#include "base/sequenced_task_runner.h" #include "base/sequenced_task_runner.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/threading/sequenced_worker_pool.h" #include "base/threading/sequenced_worker_pool.h"
...@@ -575,26 +574,23 @@ void CrxUpdateService::ProcessPendingItems() { ...@@ -575,26 +574,23 @@ void CrxUpdateService::ProcessPendingItems() {
} }
CrxUpdateItem* CrxUpdateService::FindReadyComponent() const { CrxUpdateItem* CrxUpdateService::FindReadyComponent() const {
std::vector<CrxUpdateItem*> ready; class Helper {
std::vector<CrxUpdateItem*> ready_on_demand; public:
for (std::vector<CrxUpdateItem*>::const_iterator it = work_items_.begin(); static bool IsReadyOnDemand(CrxUpdateItem* item) {
it != work_items_.end(); return item->on_demand && IsReady(item);
++it) {
CrxUpdateItem* item = *it;
if (item->status == CrxUpdateItem::kCanUpdate) {
if (item->on_demand)
ready_on_demand.push_back(item);
else
ready.push_back(item);
} }
} static bool IsReady(CrxUpdateItem* item) {
return item->status == CrxUpdateItem::kCanUpdate;
}
};
if (ready_on_demand.size() > 0) { std::vector<CrxUpdateItem*>::const_iterator it = std::find_if(
return ready_on_demand[base::RandInt(0, ready_on_demand.size() - 1)]; work_items_.begin(), work_items_.end(), Helper::IsReadyOnDemand);
} if (it != work_items_.end())
if (ready.size() > 0) { return *it;
return ready[base::RandInt(0, ready.size() - 1)]; it = std::find_if(work_items_.begin(), work_items_.end(), Helper::IsReady);
} if (it != work_items_.end())
return *it;
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment