Remove per-component URL Sources, and add the ability to pass the URL
source as a flag. This flag is necessary for testing differential
updates.

BUG=245318

Review URL: https://chromiumcodereview.appspot.com/17893016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209307 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
index 19e94fa7..6ceb452 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -51,13 +51,6 @@
 
 namespace {
 
-// Manifest sources, from most important to least important.
-const CrxComponent::UrlSource kManifestSources[] = {
-  CrxComponent::BANDAID,
-  CrxComponent::CWS_PUBLIC,
-  CrxComponent::CWS_SANDBOX,
-};
-
 // Extends an omaha compatible update check url |query| string. Does
 // not mutate the string if it would be longer than |limit| chars.
 bool AddQueryString(const std::string& id,
@@ -288,8 +281,7 @@
 }  // namespace.
 
 CrxComponent::CrxComponent()
-    : installer(NULL),
-      source(BANDAID) {
+    : installer(NULL) {
 }
 
 CrxComponent::~CrxComponent() {
@@ -686,73 +678,61 @@
     return;
   }
 
-  for (size_t ix = 0; ix != arraysize(kManifestSources); ++ix) {
-    const CrxComponent::UrlSource manifest_source = kManifestSources[ix];
-
-    std::string query;
-    // If no pending upgrades, we check if there are new components we have not
-    // checked against the server. We can batch some in a single url request.
-    for (UpdateItems::const_iterator it = work_items_.begin();
-         it != work_items_.end(); ++it) {
-      CrxUpdateItem* item = *it;
-      if (item->status != CrxUpdateItem::kNew)
-        continue;
-      if (item->component.source != manifest_source)
-        continue;
-      if (!AddItemToUpdateCheck(item, &query))
-        break;
-      // Requested work items may speed up the update cycle up until
-      // the point that we start an update check. I.e., transition
-      // from kNew -> kChecking.  Since the service doesn't guarantee that
-      // the requested items make it any further than kChecking,
-      // forget them now.
-      requested_work_items_.erase(item);
-    }
-
-    // Next we can go back to components we already checked, here
-    // we can also batch them in a single url request, as long as
-    // we have not checked them recently.
-    const base::TimeDelta min_delta_time =
-        base::TimeDelta::FromSeconds(config_->MinimumReCheckWait());
-
-    for (UpdateItems::const_iterator it = work_items_.begin();
-         it != work_items_.end(); ++it) {
-      CrxUpdateItem* item = *it;
-      if ((item->status != CrxUpdateItem::kNoUpdate) &&
-          (item->status != CrxUpdateItem::kUpToDate))
-        continue;
-      if (item->component.source != manifest_source)
-        continue;
-      base::TimeDelta delta = base::Time::Now() - item->last_check;
-      if (delta < min_delta_time)
-        continue;
-      if (!AddItemToUpdateCheck(item, &query))
-        break;
-    }
-
-    // Finally, we check components that we already updated as long as
-    // we have not checked them recently.
-    for (UpdateItems::const_iterator it = work_items_.begin();
-         it != work_items_.end(); ++it) {
-      CrxUpdateItem* item = *it;
-      if (item->status != CrxUpdateItem::kUpdated)
-        continue;
-      if (item->component.source != manifest_source)
-        continue;
-      base::TimeDelta delta = base::Time::Now() - item->last_check;
-      if (delta < min_delta_time)
-        continue;
-      if (!AddItemToUpdateCheck(item, &query))
-        break;
-    }
-
-    // If no components to update we move down to the next source.
-    if (query.empty())
+  std::string query;
+  // If no pending upgrades, we check if there are new components we have not
+  // checked against the server. We can batch some in a single url request.
+  for (UpdateItems::const_iterator it = work_items_.begin();
+       it != work_items_.end(); ++it) {
+    CrxUpdateItem* item = *it;
+    if (item->status != CrxUpdateItem::kNew)
       continue;
+    if (!AddItemToUpdateCheck(item, &query))
+      break;
+    // Requested work items may speed up the update cycle up until
+    // the point that we start an update check. I.e., transition
+    // from kNew -> kChecking.  Since the service doesn't guarantee that
+    // the requested items make it any further than kChecking,
+    // forget them now.
+    requested_work_items_.erase(item);
+  }
 
+  // Next we can go back to components we already checked, here
+  // we can also batch them in a single url request, as long as
+  // we have not checked them recently.
+  const base::TimeDelta min_delta_time =
+      base::TimeDelta::FromSeconds(config_->MinimumReCheckWait());
+
+  for (UpdateItems::const_iterator it = work_items_.begin();
+       it != work_items_.end(); ++it) {
+    CrxUpdateItem* item = *it;
+    if ((item->status != CrxUpdateItem::kNoUpdate) &&
+        (item->status != CrxUpdateItem::kUpToDate))
+      continue;
+    base::TimeDelta delta = base::Time::Now() - item->last_check;
+    if (delta < min_delta_time)
+      continue;
+    if (!AddItemToUpdateCheck(item, &query))
+      break;
+  }
+
+  // Finally, we check components that we already updated as long as
+  // we have not checked them recently.
+  for (UpdateItems::const_iterator it = work_items_.begin();
+       it != work_items_.end(); ++it) {
+    CrxUpdateItem* item = *it;
+    if (item->status != CrxUpdateItem::kUpdated)
+      continue;
+    base::TimeDelta delta = base::Time::Now() - item->last_check;
+    if (delta < min_delta_time)
+      continue;
+    if (!AddItemToUpdateCheck(item, &query))
+      break;
+  }
+
+  if (!query.empty()) {
     // We got components to check. Start the url request and exit.
     const std::string full_query =
-        MakeFinalQuery(config_->UpdateUrl(manifest_source).spec(),
+        MakeFinalQuery(config_->UpdateUrl().spec(),
                        query,
                        config_->ExtraRequestParams());