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

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

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add comments Created 8 years, 5 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 a1f637a7e1df05d93a3f34823c9352cd429b31ee..6188dad566e5f8eebf64a3808c5280cfa341ee49 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -414,22 +414,13 @@ int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
}
int ExtensionProcessManager::IncrementLazyKeepaliveCount(
- const Extension* extension, ShouldCancelSuspend should_cancel_suspend) {
+ const Extension* extension) {
if (!extension->has_lazy_background_page())
return 0;
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
- bool& is_closing = background_page_data_[extension->id()].is_closing;
- if (++count == 1) {
- if (should_cancel_suspend == CANCEL_SUSPEND && is_closing) {
- is_closing = false;
- ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
- if (host)
- host->render_view_host()->Send(
- new ExtensionMsg_CancelUnload(extension->id()));
- }
+ if (++count == 1)
OnLazyBackgroundPageActive(extension->id());
- }
return count;
}
@@ -463,7 +454,7 @@ void ExtensionProcessManager::IncrementLazyKeepaliveCountForView(
const Extension* extension = GetExtensionForRenderViewHost(
render_view_host);
if (extension)
- IncrementLazyKeepaliveCount(extension, DONT_CANCEL_SUSPEND);
+ IncrementLazyKeepaliveCount(extension);
}
}
@@ -528,7 +519,7 @@ void ExtensionProcessManager::OnNetworkRequestStarted(
ExtensionHost* host = GetBackgroundHostForExtension(
GetExtensionID(render_view_host));
if (host && host->render_view_host() == render_view_host)
- IncrementLazyKeepaliveCount(host->extension(), DONT_CANCEL_SUSPEND);
+ IncrementLazyKeepaliveCount(host->extension());
}
void ExtensionProcessManager::OnNetworkRequestDone(
@@ -539,6 +530,18 @@ void ExtensionProcessManager::OnNetworkRequestDone(
DecrementLazyKeepaliveCount(host->extension());
}
+void ExtensionProcessManager::CancelSuspend(const Extension* extension) {
+ bool& is_closing = background_page_data_[extension->id()].is_closing;
+ ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
+ if (host && is_closing) {
+ is_closing = false;
+ host->render_view_host()->Send(
+ new ExtensionMsg_CancelUnload(extension->id()));
+ }
+ IncrementLazyKeepaliveCount(extension);
+ DecrementLazyKeepaliveCount(extension);
Matt Perry 2012/07/25 19:21:55 Could you add a comment why this is necessary? (T
koz (OOO until 15th September) 2012/07/26 00:40:08 I've added a comment and will leave it this way, b
+}
+
void ExtensionProcessManager::Observe(
int type,
const content::NotificationSource& source,
@@ -624,7 +627,7 @@ void ExtensionProcessManager::Observe(
const Extension* extension = GetExtensionForRenderViewHost(
render_view_host);
if (extension)
- IncrementLazyKeepaliveCount(extension, CANCEL_SUSPEND);
+ IncrementLazyKeepaliveCount(extension);
}
break;
}
« 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