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

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

Issue 10272019: Add an arbitrary delay before unloading lazy background pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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_process_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 47ec735fa0fbc35f8d94e5b215075fd02b9d84c9..642379f7c42e2cf94aaf48ad9bedc215336cec17 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -5,6 +5,8 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
+#include "base/message_loop.h"
+#include "base/time.h"
#include "chrome/browser/extensions/extension_event_router.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_host.h"
@@ -125,7 +127,8 @@ ExtensionProcessManager* ExtensionProcessManager::Create(Profile* profile) {
}
ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
- : site_instance_(SiteInstance::Create(profile)) {
+ : site_instance_(SiteInstance::Create(profile)),
+ weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
Profile* original_profile = profile->GetOriginalProfile();
registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
content::Source<Profile>(original_profile));
@@ -414,14 +417,22 @@ int ExtensionProcessManager::DecrementLazyKeepaliveCount(
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
DCHECK_GT(count, 0);
- if (--count == 0)
- OnLazyBackgroundPageIdle(extension->id());
+ if (--count == 0) {
+ VLOG(1) << "delaying post for " << extension->id();
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&ExtensionProcessManager::OnLazyBackgroundPageIdle,
+ weak_ptr_factory_.GetWeakPtr(), extension->id(),
+ ++background_page_data_[extension->id()].close_sequence_id),
+ base::TimeDelta::FromSeconds(10));
Yoyo Zhou 2012/04/30 21:34:09 I'm not sure if this should be a constant defined
Aaron Boodman 2012/04/30 21:47:13 Let's do a command-line flag so that we can experi
Matt Perry 2012/04/30 21:58:45 I think we should have 2 timeouts, like I describe
Yoyo Zhou 2012/05/01 22:15:13 This is the first one then. As for the second case
+ }
return count;
}
void ExtensionProcessManager::OnLazyBackgroundPageIdle(
- const std::string& extension_id) {
+ const std::string& extension_id, int close_sequence_id) {
+ VLOG(1) << "onlazybgpidle " << extension_id;
ExtensionHost* host = GetBackgroundHostForExtension(extension_id);
if (host && !background_page_data_[extension_id].is_closing) {
Matt Perry 2012/04/30 21:58:45 We should check whether close_sequence_id has chan
Yoyo Zhou 2012/05/01 22:15:13 True.
// Tell the renderer we are about to close. This is a simple ping that the
@@ -429,7 +440,7 @@ void ExtensionProcessManager::OnLazyBackgroundPageIdle(
// extension remains idle until the renderer responds with an ACK, then we
// know that the extension process is ready to shut down.
host->render_view_host()->Send(new ExtensionMsg_ShouldUnload(
- extension_id, ++background_page_data_[extension_id].close_sequence_id));
+ extension_id, close_sequence_id));
}
}
« no previous file with comments | « chrome/browser/extensions/extension_process_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698