Index: extensions/browser/process_manager.cc |
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc |
index 6a57d8e600ac1eba65ec9eeef9d6c5b582c08baf..1eb2903d2b7e774ead5524b8e343e111b394d24d 100644 |
--- a/extensions/browser/process_manager.cc |
+++ b/extensions/browser/process_manager.cc |
@@ -203,6 +203,8 @@ ProcessManager::ProcessManager(BrowserContext* context, |
content::Source<BrowserContext>(original_context)); |
} |
+ // Note: event_page_idle_time_ must be sufficiently larger (e.g. 2x) than |
+ // kKeepaliveThrottleIntervalInSeconds in ppapi/proxy/plugin_globals. |
event_page_idle_time_ = base::TimeDelta::FromSeconds(10); |
unsigned idle_time_msec = 0; |
if (base::StringToUint(CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
@@ -419,6 +421,9 @@ void ProcessManager::KeepaliveImpulse(const Extension* extension) { |
IncrementLazyKeepaliveCount(extension); |
} |
} |
+ |
+ if (!keepalive_impulse_callback_for_testing_.is_null()) |
+ keepalive_impulse_callback_for_testing_.Run(extension->id()); |
} |
// DecrementLazyKeepaliveCount is called when no calls to KeepaliveImpulse |
@@ -431,8 +436,11 @@ void ProcessManager::OnKeepaliveImpulseCheck() { |
for (BackgroundPageDataMap::iterator i = background_page_data_.begin(); |
i != background_page_data_.end(); |
++i) { |
- if (i->second.previous_keepalive_impulse && !i->second.keepalive_impulse) |
+ if (i->second.previous_keepalive_impulse && !i->second.keepalive_impulse) { |
DecrementLazyKeepaliveCount(i->first); |
+ if (!keepalive_impulse_decrement_callback_for_testing_.is_null()) |
+ keepalive_impulse_decrement_callback_for_testing_.Run(i->first); |
+ } |
i->second.previous_keepalive_impulse = i->second.keepalive_impulse; |
i->second.keepalive_impulse = false; |
@@ -551,6 +559,16 @@ content::BrowserContext* ProcessManager::GetBrowserContext() const { |
return site_instance_->GetBrowserContext(); |
} |
+void ProcessManager::SetKeepaliveImpulseCallbackForTesting( |
+ const ImpulseCallbackForTesting& callback) { |
+ keepalive_impulse_callback_for_testing_ = callback; |
+} |
+ |
+void ProcessManager::SetKeepaliveImpulseDecrementCallbackForTesting( |
+ const ImpulseCallbackForTesting& callback) { |
+ keepalive_impulse_decrement_callback_for_testing_ = callback; |
+} |
+ |
void ProcessManager::Observe(int type, |
const content::NotificationSource& source, |
const content::NotificationDetails& details) { |