Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1167)

Unified Diff: extensions/browser/extension_host.cc

Issue 182253010: Register a Service Worker when an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to r261176 Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 {

Powered by Google App Engine
This is Rietveld 408576698