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

Unified Diff: extensions/browser/process_manager.cc

Issue 1096313003: Create interface "EventPageTracker" for checking an extension's (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix IWYU linter error while I'm at it. Created 5 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 | « extensions/browser/process_manager.h ('k') | extensions/extensions.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/process_manager.cc
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc
index 47f7b191e004da8dccf2a6179c9a17a73471752f..98e72aa30c2e2c88a3bcf331d7936b57dde91129 100644
--- a/extensions/browser/process_manager.cc
+++ b/extensions/browser/process_manager.cc
@@ -4,6 +4,8 @@
#include "extensions/browser/process_manager.h"
+#include <vector>
+
#include "base/bind.h"
#include "base/logging.h"
#include "base/message_loop/message_loop.h"
@@ -23,6 +25,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 +110,11 @@ static void CreateBackgroundHostForExtensionLoad(
BackgroundInfo::GetBackgroundURL(extension));
}
+void PropagateExtensionWakeResult(const base::Callback<void(bool)>& callback,
+ extensions::ExtensionHost* host) {
+ callback.Run(host != nullptr);
+}
+
} // namespace
struct ProcessManager::BackgroundPageData {
@@ -406,6 +414,23 @@ ExtensionHost* ProcessManager::GetBackgroundHostForExtension(
return nullptr;
}
+bool ProcessManager::IsEventPageSuspended(const std::string& extension_id) {
+ return GetBackgroundHostForExtension(extension_id) == nullptr;
+}
+
+bool ProcessManager::WakeEventPage(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.
+ return false;
+ }
+ LazyBackgroundTaskQueue* queue =
+ ExtensionSystem::Get(browser_context_)->lazy_background_task_queue();
+ queue->AddPendingTask(browser_context_, extension_id,
+ base::Bind(&PropagateExtensionWakeResult, callback));
+ return true;
+}
+
bool ProcessManager::IsBackgroundHostClosing(const std::string& extension_id) {
ExtensionHost* host = GetBackgroundHostForExtension(extension_id);
return (host && background_page_data_[extension_id].is_closing);
« no previous file with comments | « extensions/browser/process_manager.h ('k') | extensions/extensions.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698