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

Unified Diff: chrome/browser/extensions/event_router.cc

Issue 10804020: Introduce runtime.onSuspendCanceled() event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: respond to comments Created 8 years, 5 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 | « no previous file | chrome/browser/extensions/extension_process_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/event_router.cc
diff --git a/chrome/browser/extensions/event_router.cc b/chrome/browser/extensions/event_router.cc
index ea91880174165c740dc5121e17c8f44af81f6392..bdb00c3a38dbf26cc2ba8bd3a250730641e4623f 100644
--- a/chrome/browser/extensions/event_router.cc
+++ b/chrome/browser/extensions/event_router.cc
@@ -357,6 +357,23 @@ void EventRouter::DispatchEventImpl(const std::string& restrict_to_extension_id,
std::set<const EventListener*> listeners(
listeners_.GetEventListeners(*event));
+
+ // We dispatch events for lazy background pages first because attempting to do
+ // so will cause those that are being suspended to cancel that suspension.
+ // As canceling a suspension entails sending an event to the affected
+ // background page, and as that event needs to be delivered before we dispatch
+ // the event we are dispatching here, we dispatch to the lazy listeners here
+ // first.
+ for (std::set<const EventListener*>::iterator it = listeners.begin();
+ it != listeners.end(); it++) {
+ const EventListener* listener = *it;
+ if (restrict_to_extension_id.empty() ||
+ restrict_to_extension_id == listener->extension_id) {
+ if (!listener->process)
+ DispatchLazyEvent(listener->extension_id, event);
+ }
+ }
+
for (std::set<const EventListener*>::iterator it = listeners.begin();
it != listeners.end(); it++) {
const EventListener* listener = *it;
@@ -365,8 +382,6 @@ void EventRouter::DispatchEventImpl(const std::string& restrict_to_extension_id,
if (listener->process) {
DispatchEventToProcess(listener->extension_id, listener->process,
event);
- } else {
- DispatchLazyEvent(listener->extension_id, event);
}
}
}
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698