Index: extensions/browser/process_manager.cc |
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc |
index 47f7b191e004da8dccf2a6179c9a17a73471752f..8f11eae63cf139782cc10ede9960b22baabb6f17 100644 |
--- a/extensions/browser/process_manager.cc |
+++ b/extensions/browser/process_manager.cc |
@@ -23,6 +23,7 @@ |
#include "extensions/browser/extension_registry.h" |
#include "extensions/browser/extension_system.h" |
#include "extensions/browser/extensions_browser_client.h" |
+#include "extensions/browser/lazy_background_task_queue.h" |
#include "extensions/browser/notification_types.h" |
#include "extensions/browser/process_manager_delegate.h" |
#include "extensions/browser/process_manager_factory.h" |
@@ -107,6 +108,11 @@ static void CreateBackgroundHostForExtensionLoad( |
BackgroundInfo::GetBackgroundURL(extension)); |
} |
+void OnExtensionLoad(const base::Callback<void(bool)>& callback, |
+ extensions::ExtensionHost* host) { |
+ callback.Run(host != nullptr); |
+} |
+ |
} // namespace |
struct ProcessManager::BackgroundPageData { |
@@ -406,6 +412,18 @@ ExtensionHost* ProcessManager::GetBackgroundHostForExtension( |
return nullptr; |
} |
+void ProcessManager::WakeExtension(const std::string& extension_id, |
+ const base::Callback<void(bool)>& callback) { |
+ if (GetBackgroundHostForExtension(extension_id)) { |
+ // Run the callback immediately if the extension is already awake. |
+ callback.Run(true); |
not at google - send to devlin
2015/04/24 20:05:08
Re-entrant callbacks lead to insidious bugs. Eithe
Kevin Marshall
2015/04/24 21:04:53
Good point, using return value. Updated docs.
|
+ } |
+ LazyBackgroundTaskQueue* queue = |
+ ExtensionSystem::Get(browser_context_)->lazy_background_task_queue(); |
+ queue->AddPendingTask(browser_context_, extension_id, |
+ base::Bind(&OnExtensionLoad, callback)); |
not at google - send to devlin
2015/04/24 20:05:08
Is there a better / more descriptive name than jus
Kevin Marshall
2015/04/24 21:04:53
How's this? "PropagateExtensionWakeResult"
|
+} |
+ |
bool ProcessManager::IsBackgroundHostClosing(const std::string& extension_id) { |
ExtensionHost* host = GetBackgroundHostForExtension(extension_id); |
return (host && background_page_data_[extension_id].is_closing); |