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

Unified Diff: extensions/browser/event_router.h

Issue 2943583002: [extension SW] Support lazy events from extension service workers. (Closed)
Patch Set: 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
Index: extensions/browser/event_router.h
diff --git a/extensions/browser/event_router.h b/extensions/browser/event_router.h
index 25933c08bfe35a887dbe21b93fc77b7276730cca..45964d16c776ebd204f0266d4964ea7ffc12b542 100644
--- a/extensions/browser/event_router.h
+++ b/extensions/browser/event_router.h
@@ -24,6 +24,7 @@
#include "extensions/browser/events/lazy_event_dispatch_util.h"
#include "extensions/browser/extension_event_histogram_value.h"
#include "extensions/browser/extension_registry_observer.h"
+#include "extensions/browser/lazy_context_task_queue.h"
#include "extensions/common/constants.h"
#include "extensions/common/event_filtering_info.h"
#include "ipc/ipc_sender.h"
@@ -38,7 +39,6 @@ class RenderProcessHost;
namespace extensions {
class Extension;
-class ExtensionHost;
class ExtensionPrefs;
class ExtensionRegistry;
@@ -126,6 +126,7 @@ class EventRouter : public KeyedService,
void AddServiceWorkerEventListener(const std::string& event_name,
content::RenderProcessHost* process,
const ExtensionId& extension_id,
+ const GURL& service_worker_scope,
int worker_thread_id);
void RemoveEventListener(const std::string& event_name,
content::RenderProcessHost* process,
@@ -133,6 +134,7 @@ class EventRouter : public KeyedService,
void RemoveServiceWorkerEventListener(const std::string& event_name,
content::RenderProcessHost* process,
const ExtensionId& extension_id,
+ const GURL& service_worker_scope,
int worker_thread_id);
// Add or remove a URL as an event listener for |event_name|.
@@ -165,10 +167,10 @@ class EventRouter : public KeyedService,
// workers.
void AddLazyServiceWorkerEventListener(const std::string& event_name,
const ExtensionId& extension_id,
- int worker_thread_id);
+ const GURL& service_worker_scope);
void RemoveLazyServiceWorkerEventListener(const std::string& event_name,
const ExtensionId& extension_id,
- int worker_thread_id);
+ const GURL& service_worker_scope);
// If |add_lazy_listener| is true also add the lazy version of this listener.
void AddFilteredEventListener(const std::string& event_name,
@@ -274,12 +276,10 @@ class EventRouter : public KeyedService,
const Extension* extension,
UnloadedExtensionReason reason) override;
- void AddLazyEventListenerImpl(const std::string& event_name,
- const ExtensionId& extension_id,
- int worker_thread_id);
- void RemoveLazyEventListenerImpl(const std::string& event_name,
- const ExtensionId& extension_id,
- int worker_thread_id);
+ void AddLazyEventListenerImpl(std::unique_ptr<EventListener> listener,
+ RegisteredEventType type);
+ void RemoveLazyEventListenerImpl(std::unique_ptr<EventListener> listener,
+ RegisteredEventType type);
// Shared by all event dispatch methods. If |restrict_to_extension_id| is
// empty, the event is broadcast. An event that just came off the pending
@@ -287,15 +287,6 @@ class EventRouter : public KeyedService,
void DispatchEventImpl(const std::string& restrict_to_extension_id,
const linked_ptr<Event>& event);
- // Ensures that all lazy background pages that are interested in the given
Devlin 2017/06/16 02:34:42 These are gone now, right? Can you rebase?
lazyboy 2017/06/16 18:48:05 Yes, Done. (The CQ was taking long time to submit
- // event are loaded, and queues the event if the page is not ready yet.
- // Inserts an EventDispatchIdentifier into |already_dispatched| for each lazy
- // event dispatch that is queued.
- void DispatchLazyEvent(const std::string& extension_id,
- const linked_ptr<Event>& event,
- std::set<EventDispatchIdentifier>* already_dispatched,
- const base::DictionaryValue* listener_filter);
-
// Dispatches the event to the specified extension or URL running in
// |process|.
void DispatchEventToProcess(const std::string& extension_id,
@@ -306,15 +297,6 @@ class EventRouter : public KeyedService,
const base::DictionaryValue* listener_filter,
bool did_enqueue);
- // Possibly loads given extension's background page in preparation to
- // dispatch an event. Returns true if the event was queued for subsequent
- // dispatch, false otherwise.
- bool MaybeLoadLazyBackgroundPageToDispatchEvent(
- content::BrowserContext* context,
- const Extension* extension,
- const linked_ptr<Event>& event,
- const base::DictionaryValue* listener_filter);
-
// Adds a filter to an event.
void AddFilterToEvent(const std::string& event_name,
const std::string& extension_id,
@@ -345,8 +327,9 @@ class EventRouter : public KeyedService,
events::HistogramValue histogram_value,
const std::string& event_name);
- void DispatchPendingEvent(const linked_ptr<Event>& event,
- ExtensionHost* host);
+ void DispatchPendingEvent(
+ const linked_ptr<Event>& event,
+ std::unique_ptr<LazyContextTaskQueue::ContextInfo> params);
// Implementation of EventListenerMap::Delegate.
void OnListenerAdded(const EventListener* listener) override;

Powered by Google App Engine
This is Rietveld 408576698