summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 20:22:43 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-05 20:22:43 +0000
commited51dfedc9f4a074bbcf76bb6d8161d1cd983e7e (patch)
treee048f4a4aa566acdb9f12ddde9e4c969cf337fac /chrome/browser/extensions
parent68eb756608afa95ad18ab4285b2d494431d1c43b (diff)
downloadchromium_src-ed51dfedc9f4a074bbcf76bb6d8161d1cd983e7e.zip
chromium_src-ed51dfedc9f4a074bbcf76bb6d8161d1cd983e7e.tar.gz
chromium_src-ed51dfedc9f4a074bbcf76bb6d8161d1cd983e7e.tar.bz2
Fix a bug where calling window.close() from a transient page with an open
message port would result in an inconsistent lazy keepalive count. BUG=no TEST=no Review URL: https://chromiumcodereview.appspot.com/9961020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131000 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_event_router.cc13
-rw-r--r--chrome/browser/extensions/extension_process_manager.cc10
2 files changed, 14 insertions, 9 deletions
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc
index 32206f4..21c315c 100644
--- a/chrome/browser/extensions/extension_event_router.cc
+++ b/chrome/browser/extensions/extension_event_router.cc
@@ -414,16 +414,11 @@ void ExtensionEventRouter::IncrementInFlightEvents(
void ExtensionEventRouter::OnExtensionEventAck(
Profile* profile, const std::string& extension_id) {
- // Don't decrement the count if the background page has gone away. This can
- // happen if the event was dispatched while unloading the page.
- // TODO(mpcomplete): This might be insufficient.. what if the page goes away
- // and comes back before we get the ack? Then we'll have an imbalanced
- // keepalive count.
- ExtensionHost* host = profile->GetExtensionProcessManager()->
- GetBackgroundHostForExtension(extension_id);
- if (host && host->extension()->has_lazy_background_page()) {
+ const Extension* extension = profile->GetExtensionService()->extensions()->
+ GetByID(extension_id);
+ if (extension && extension->has_lazy_background_page()) {
profile->GetExtensionProcessManager()->DecrementLazyKeepaliveCount(
- host->extension());
+ extension);
}
}
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 782f642..30fcb4d 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -397,6 +397,16 @@ int ExtensionProcessManager::DecrementLazyKeepaliveCount(
if (!extension->has_lazy_background_page())
return 0;
+ // Don't decrement the count if the background page has gone away. This can
+ // happen e.g. if an event was dispatched while unloading the page, or if
+ // the process is killed/closed while a message port remains open.
+ // TODO(mpcomplete): This might be insufficient.. what if the page goes away
+ // and comes back before we get here? Then we'll have an imbalanced
+ // keepalive count.
+ ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
+ if (!host)
+ return 0;
+
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
DCHECK_GT(count, 0);
if (--count == 0)