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

Unified Diff: chrome/browser/extensions/extension_process_manager.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
Index: chrome/browser/extensions/extension_process_manager.cc
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 30fcb4d3dcffbdcce9788182e75f4b5cc7055858..100059e601498f4e2641b8fea7b1cb9ce85c0d54 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -373,6 +373,12 @@ bool ExtensionProcessManager::HasExtensionHost(ExtensionHost* host) const {
return all_hosts_.find(host) != all_hosts_.end();
}
+bool ExtensionProcessManager::IsBackgroundHostClosing(
+ const std::string& extension_id) {
+ ExtensionHost* host = GetBackgroundHostForExtension(extension_id);
+ return (host && background_page_data_[extension_id].is_closing);
+}
+
int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
if (!extension->has_lazy_background_page())
return 0;
@@ -397,15 +403,10 @@ 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;
+ // This should never be called if the background page isn't active.
+ // Otherwise, the count can get out of sync, because we reset it when the
+ // page unloads.
+ CHECK(GetBackgroundHostForExtension(extension->id()));
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
DCHECK_GT(count, 0);
« no previous file with comments | « chrome/browser/extensions/extension_process_manager.h ('k') | chrome/browser/extensions/lazy_background_task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698