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

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: yoyo 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
« no previous file with comments | « chrome/browser/extensions/extension_event_router.h ('k') | chrome/browser/extensions/extension_function.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0b957df105e5dda66627ed0d1aa6ffd1a9a4f785 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -405,20 +405,27 @@ void ExtensionEventRouter::MaybeLoadLazyBackgroundPage(
void ExtensionEventRouter::IncrementInFlightEvents(
Profile* profile, const Extension* extension) {
+ // Only increment in-flight events if the lazy background page is active,
+ // because that's the only time we'll get an ACK.
if (extension->has_lazy_background_page()) {
- profile->GetExtensionProcessManager()->IncrementLazyKeepaliveCount(
- extension);
+ ExtensionProcessManager* pm =
+ ExtensionSystem::Get(profile)->process_manager();
+ ExtensionHost* host = pm->GetBackgroundHostForExtension(extension->id());
+ if (host)
+ 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(
« no previous file with comments | « chrome/browser/extensions/extension_event_router.h ('k') | chrome/browser/extensions/extension_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698