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

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

Issue 10114015: Fix bug where transient pages would miss events dispatched while it was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 908c06c49e977666fc967c3287820c5ea7e0af65..33979efc88c07200eeea643007c97d027d7713f2 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -405,20 +405,25 @@ void ExtensionEventRouter::MaybeLoadLazyBackgroundPage(
void ExtensionEventRouter::IncrementInFlightEvents(
Profile* profile, const Extension* extension) {
- if (extension->has_lazy_background_page()) {
- profile->GetExtensionProcessManager()->IncrementLazyKeepaliveCount(
- extension);
- }
+ // Only increment in-flight events if the lazy background page is active,
+ // because that's the only time we'll get an ACK.
+ ExtensionProcessManager* pm =
+ ExtensionSystem::Get(profile)->process_manager();
+ ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id());
Yoyo Zhou 2012/04/19 21:47:13 You could put this inside has_lazy_background_page
Matt Perry 2012/04/19 22:21:53 Done.
+ if (host && extension->has_lazy_background_page())
+ pm->IncrementLazyKeepaliveCount(extension);
}
-void ExtensionEventRouter::OnExtensionEventAck(
+void ExtensionEventRouter::OnEventAck(
Profile* profile, const std::string& extension_id) {
- const Extension* extension = profile->GetExtensionService()->extensions()->
- GetByID(extension_id);
- if (extension && extension->has_lazy_background_page()) {
- profile->GetExtensionProcessManager()->DecrementLazyKeepaliveCount(
- extension);
- }
+ ExtensionProcessManager* pm =
+ ExtensionSystem::Get(profile)->process_manager();
+ ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id);
+ // The event ACK is routed to the background host, so this should never be
+ // NULL.
+ CHECK(host);
+ CHECK(host->extension()->has_lazy_background_page());
+ pm->DecrementLazyKeepaliveCount(host->extension());
}
void ExtensionEventRouter::DispatchPendingEvent(

Powered by Google App Engine
This is Rietveld 408576698