Chromium Code Reviews| 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( |