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

Unified Diff: chrome/browser/extensions/extension_event_router.cc

Issue 9562017: Keep lazy background page alive while there are pending network requests or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixins Created 8 years, 10 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: chrome/browser/extensions/extension_event_router.cc
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc
index 29d94afe48ace6dea73e3e0ce3583294f2063640..7d8a6c7a43074f3dce3b04d1f9221b93252d07dd 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -382,7 +382,11 @@ void ExtensionEventRouter::LoadLazyBackgroundPagesForEvent(
if (extension && !CanDispatchEventNow(extension)) {
AppendEvent(extension->id(), event);
- pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
+ if (!pm->GetBackgroundHostForExtension(extension->id())) {
+ // Balanced in DispatchPendingEvents, after the page has loaded.
+ pm->IncrementLazyKeepaliveCount(extension);
+ pm->CreateBackgroundHost(extension, extension->GetBackgroundURL());
+ }
}
}
}
@@ -429,14 +433,6 @@ void ExtensionEventRouter::DispatchPendingEvents(
return;
}
- // Temporarily increment the keepalive count while dispatching the events.
- // This also ensures that if no events were dispatched, the extension returns
- // to "idle" and is shut down.
- const Extension* extension =
- profile_->GetExtensionService()->extensions()->GetByID(extension_id);
- ExtensionProcessManager* pm = profile_->GetExtensionProcessManager();
- pm->IncrementLazyKeepaliveCount(extension);
-
PendingEventsList* events_list = map_it->second.get();
for (PendingEventsList::const_iterator it = events_list->begin();
it != events_list->end(); ++it)
@@ -445,6 +441,10 @@ void ExtensionEventRouter::DispatchPendingEvents(
events_list->clear();
pending_events_.erase(extension_id);
+ // Balance the keepalive addref in LoadLazyBackgroundPagesForEvent.
+ const Extension* extension =
+ profile_->GetExtensionService()->extensions()->GetByID(extension_id);
+ ExtensionProcessManager* pm = profile_->GetExtensionProcessManager();
pm->DecrementLazyKeepaliveCount(extension);
}
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_process_manager.h » ('j') | chrome/browser/net/chrome_network_delegate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698