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 ac453d6182d0aec5ae03f332171aeadcec37c91a..c847308cbf5f560a590fdc82427b93b48aed1f3f 100644 |
--- a/chrome/browser/extensions/extension_process_manager.cc |
+++ b/chrome/browser/extensions/extension_process_manager.cc |
@@ -112,9 +112,9 @@ struct ExtensionProcessManager::BackgroundPageData { |
int close_sequence_id; |
// True if the page responded to the ShouldUnload message and is currently |
- // dispatching the unload event. We use this to ignore any activity |
- // generated during the unload event that would otherwise keep the |
- // extension alive. |
+ // dispatching the unload event. During this time any events that arrive will |
+ // cancel the unload process and an onSuspendCanceled event will be dispatched |
+ // to the page. |
bool is_closing; |
benwells
2012/07/19 04:01:21
Can we change this name too?
koz (OOO until 15th September)
2012/07/19 06:52:11
See previous comment.
|
// Keeps track of when this page was last unloaded. Used for perf metrics. |
@@ -417,6 +417,7 @@ int ExtensionProcessManager::IncrementLazyKeepaliveCount( |
if (!extension->has_lazy_background_page()) |
return 0; |
+ background_page_data_[extension->id()].is_closing = false; |
int& count = background_page_data_[extension->id()].lazy_keepalive_count; |
if (++count == 1) |
OnLazyBackgroundPageActive(extension->id()); |
@@ -492,19 +493,24 @@ void ExtensionProcessManager::OnShouldUnloadAck( |
} |
void ExtensionProcessManager::OnUnloadAck(const std::string& extension_id) { |
+ background_page_data_[extension_id].is_closing = true; |
+ int sequence_id = background_page_data_[extension_id].close_sequence_id; |
MessageLoop::current()->PostDelayedTask( |
FROM_HERE, |
base::Bind(&ExtensionProcessManager::CloseLazyBackgroundPageNow, |
- weak_ptr_factory_.GetWeakPtr(), extension_id), |
+ weak_ptr_factory_.GetWeakPtr(), extension_id, sequence_id), |
event_page_unloading_time_); |
} |
void ExtensionProcessManager::CloseLazyBackgroundPageNow( |
- const std::string& extension_id) { |
- background_page_data_[extension_id].is_closing = true; |
+ const std::string& extension_id, int sequence_id) { |
ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
- if (host) |
- CloseBackgroundHost(host); |
+ if (host && |
+ sequence_id == background_page_data_[extension_id].close_sequence_id) { |
benwells
2012/07/19 04:01:21
Any change to sequence_id will cancel the unload.
koz (OOO until 15th September)
2012/07/19 06:52:11
Good point. I've changed it so that only dispatchi
|
+ ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
+ if (host) |
+ CloseBackgroundHost(host); |
+ } |
} |
void ExtensionProcessManager::OnNetworkRequestStarted( |