Make BackgroundContentsService start up BackgroundContents with a delay, as for ExtensionHosts.

extensions::ProcessManager starts ExtensionHosts asynchronously with a queue to avoid using too much resources at startup; make BackgroundContentsService use the same queue implementation. (ExtensionHostQueue now accepts an interface that both BackgroundContentsService and ExtensionHost share.)

This significantly reduces the time BackgroundContentsService contributes to ExtensionService startup (75th percentile was ~300ms, according to Extensions.BackgroundContentsServiceStartupTime).

BUG=47236

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

Cr-Commit-Position: refs/heads/master@{#317480}
diff --git a/chrome/browser/extensions/chrome_extension_host_delegate.cc b/chrome/browser/extensions/chrome_extension_host_delegate.cc
index 8cb4ec6..6a1af5e 100644
--- a/chrome/browser/extensions/chrome_extension_host_delegate.cc
+++ b/chrome/browser/extensions/chrome_extension_host_delegate.cc
@@ -4,6 +4,7 @@
 
 #include "chrome/browser/extensions/chrome_extension_host_delegate.h"
 
+#include "base/lazy_instance.h"
 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
 #include "chrome/browser/extensions/extension_service.h"
 #include "chrome/browser/extensions/extension_tab_util.h"
@@ -12,6 +13,7 @@
 #include "components/app_modal/javascript_dialog_manager.h"
 #include "extensions/browser/extension_host.h"
 #include "extensions/browser/extension_system.h"
+#include "extensions/browser/serial_extension_host_queue.h"
 
 namespace extensions {
 
@@ -66,4 +68,11 @@
           web_contents, security_origin, type, extension);
 }
 
+static base::LazyInstance<SerialExtensionHostQueue> g_queue =
+    LAZY_INSTANCE_INITIALIZER;
+
+ExtensionHostQueue* ChromeExtensionHostDelegate::GetExtensionHostQueue() const {
+  return g_queue.Pointer();
+}
+
 }  // namespace extensions