Index: extensions/browser/extension_host.cc |
diff --git a/extensions/browser/extension_host.cc b/extensions/browser/extension_host.cc |
index 0eac1fbbf30b12e227cdc6c143db6f2423bec3a5..13c7758049e662a1f32f25207d4e1edd61cc0505 100644 |
--- a/extensions/browser/extension_host.cc |
+++ b/extensions/browser/extension_host.cc |
@@ -173,17 +173,29 @@ bool ExtensionHost::IsRenderViewLive() const { |
return render_view_host()->IsRenderViewLive(); |
} |
-void ExtensionHost::CreateRenderViewSoon() { |
+void ExtensionHost::CreateRenderViewSoon(const base::Closure& continuation) { |
if ((render_process_host() && render_process_host()->HasConnection())) { |
// If the process is already started, go ahead and initialize the RenderView |
// synchronously. The process creation is the real meaty part that we want |
// to defer. |
CreateRenderViewNow(); |
+ if (!continuation.is_null()) |
+ continuation.Run(); |
} else { |
+ if (!continuation.is_null()) |
+ when_render_view_created_.push_back(continuation); |
ProcessCreationQueue::GetInstance()->CreateSoon(this); |
} |
} |
+static void RunAll(const std::vector<base::Closure>& callbacks) { |
+ for (std::vector<base::Closure>::const_iterator it = callbacks.begin(); |
+ it != callbacks.end(); |
+ ++it) { |
+ it->Run(); |
+ } |
+} |
+ |
void ExtensionHost::CreateRenderViewNow() { |
LoadInitialURL(); |
if (IsBackgroundPage()) { |
@@ -191,6 +203,12 @@ void ExtensionHost::CreateRenderViewNow() { |
// Connect orphaned dev-tools instances. |
delegate_->OnRenderViewCreatedForBackgroundPage(this); |
} |
+ std::vector<base::Closure> running; |
+ running.swap(when_render_view_created_); |
+ base::MessageLoop::current()->PostDelayedTask( |
+ FROM_HERE, |
+ base::Bind(&RunAll, running), |
+ base::TimeDelta::FromMilliseconds(10)); |
} |
const GURL& ExtensionHost::GetURL() const { |