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

Unified Diff: extensions/browser/lazy_background_task_queue.cc

Issue 2943583002: [extension SW] Support lazy events from extension service workers. (Closed)
Patch Set: sync @tott Created 3 years, 6 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/lazy_background_task_queue.h ('k') | extensions/browser/lazy_context_id.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/lazy_background_task_queue.cc
diff --git a/extensions/browser/lazy_background_task_queue.cc b/extensions/browser/lazy_background_task_queue.cc
index 24031549447207be98aad91f003042bfbb6a2c3a..2e077372dbee6f93ff0367d1d1bc3dc729c30ca8 100644
--- a/extensions/browser/lazy_background_task_queue.cc
+++ b/extensions/browser/lazy_background_task_queue.cc
@@ -16,6 +16,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/lazy_background_task_queue_factory.h"
+#include "extensions/browser/lazy_context_id.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
@@ -25,6 +26,23 @@
namespace extensions {
+namespace {
+
+// Adapts a LazyBackgroundTaskQueue pending task callback to
+// LazyContextTaskQueue's callback.
+void PendingTaskAdapter(const LazyContextTaskQueue::PendingTask& original_task,
+ ExtensionHost* host) {
+ if (!host) {
+ original_task.Run(nullptr);
+ } else {
+ original_task.Run(base::MakeUnique<LazyContextTaskQueue::ContextInfo>(
+ host->extension()->id(), host->render_process_host(),
+ kNonWorkerThreadId, host->GetURL()));
+ }
+}
+
+} // namespace
+
LazyBackgroundTaskQueue::LazyBackgroundTaskQueue(
content::BrowserContext* browser_context)
: browser_context_(browser_context), extension_registry_observer_(this) {
@@ -66,6 +84,13 @@ bool LazyBackgroundTaskQueue::ShouldEnqueueTask(
return false;
}
+void LazyBackgroundTaskQueue::AddPendingTaskToDispatchEvent(
+ LazyContextId* context_id,
+ const LazyContextTaskQueue::PendingTask& task) {
+ AddPendingTask(context_id->browser_context(), context_id->extension_id(),
+ base::Bind(&PendingTaskAdapter, task));
+}
+
void LazyBackgroundTaskQueue::AddPendingTask(
content::BrowserContext* browser_context,
const std::string& extension_id,
« no previous file with comments | « extensions/browser/lazy_background_task_queue.h ('k') | extensions/browser/lazy_context_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698