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

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: Code review feedback. 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
Index: extensions/browser/process_manager.cc
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc
index 47f7b191e004da8dccf2a6179c9a17a73471752f..ad8adfd6f54bbb064ae575ac06628c6b934c661f 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 PropagateExtensionWakeResult(const base::Callback<void(bool)>& callback,
+ extensions::ExtensionHost* host) {
+ callback.Run(host != nullptr);
+}
+
} // namespace
struct ProcessManager::BackgroundPageData {
@@ -406,6 +412,23 @@ ExtensionHost* ProcessManager::GetBackgroundHostForExtension(
return nullptr;
}
+bool ProcessManager::IsEventPageActive(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 (IsEventPageActive(extension_id)) {
+ 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);

Powered by Google App Engine
This is Rietveld 408576698