Allow BITS downloads of components only in certain cases.

agl@, I need an owner review for the crlset change.

BITS download is broken when the download is hosted by certain serving backends. Until the range support is improved, BITS can be used only in some cases.

For full downloads, everything uses BITS but CRLSet.
For diff downloads, nothing uses BITS

BUG=340450

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248946 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 920871d2..780354b 100644
--- a/chrome/browser/component_updater/component_updater_service.cc
+++ b/chrome/browser/component_updater/component_updater_service.cc
@@ -84,7 +84,8 @@
 
 CrxComponent::CrxComponent()
     : installer(NULL),
-      observer(NULL) {
+      observer(NULL),
+      allow_background_download(true) {
 }
 
 CrxComponent::~CrxComponent() {
@@ -646,17 +647,22 @@
   crx_context->installer = workitem->component.installer;
   crx_context->fingerprint = workitem->next_fp;
   const std::vector<GURL>* urls = NULL;
+  bool allow_background_download = false;
   if (CanTryDiffUpdate(workitem, *config_)) {
     urls = &workitem->crx_diffurls;
     ChangeItemState(workitem, CrxUpdateItem::kDownloadingDiff);
   } else {
+    // Background downloads are enabled only for selected components and
+    // only for full downloads (see issue 340448).
+    allow_background_download = workitem->component.allow_background_download;
     urls = &workitem->crx_urls;
     ChangeItemState(workitem, CrxUpdateItem::kDownloading);
   }
 
   // On demand component updates are always downloaded in foreground.
-  const bool is_background_download = !workitem->on_demand &&
-                                       config_->UseBackgroundDownloader();
+  const bool is_background_download =
+      !workitem->on_demand && allow_background_download &&
+      config_->UseBackgroundDownloader();
 
   crx_downloader_.reset(CrxDownloader::Create(
       is_background_download,