Index: extensions/browser/process_manager.cc |
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc |
index 7a362e329a387c7b90e8b3776fc65accb7e26723..070cbd78d4c6d957f5c0d3b326709009450b6ce5 100644 |
--- a/extensions/browser/process_manager.cc |
+++ b/extensions/browser/process_manager.cc |
@@ -442,6 +442,11 @@ void ProcessManager::KeepaliveImpulse(const Extension* extension) { |
IncrementLazyKeepaliveCount(extension); |
} |
} |
+ |
+ if (!keepalive_impulse_callback_for_testing_.is_null()) { |
+ if (keepalive_impulse_callback_for_testing_.Run(extension->id())) |
+ keepalive_impulse_callback_for_testing_ = ImpulseCallbackForTesting(); |
+ } |
} |
// DecrementLazyKeepaliveCount is called when no calls to KeepaliveImpulse |
@@ -454,8 +459,14 @@ 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()) { |
+ if (keepalive_impulse_decrement_callback_for_testing_.Run(i->first)) |
+ keepalive_impulse_decrement_callback_for_testing_ = |
+ ImpulseCallbackForTesting(); |
+ } |
+ } |
i->second.previous_keepalive_impulse = i->second.keepalive_impulse; |
i->second.keepalive_impulse = false; |
@@ -576,6 +587,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) { |