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

Unified Diff: extensions/browser/event_router.cc

Issue 1138643010: Fix a race where backgroud page might ack an event before we're ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/event_router.cc
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index 365cd2f15153234e62d2c675a7e0b04387f8d8d8..a82ed24d2c6e168231f1532ec53ec9f36cdda4bd 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -155,14 +155,12 @@ void EventRouter::DispatchEvent(IPC::Sender* ipc_sender,
const EventFilteringInfo& info) {
int event_id = g_extension_event_id.GetNext();
+ IncrementInFlightEventsOnUI(browser_context_id, extension_id, event_id,
+ event_name);
+
DispatchExtensionMessage(ipc_sender, browser_context_id, extension_id,
event_id, event_name, event_args.get(), user_gesture,
info);
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&EventRouter::IncrementInFlightEventsOnUI, browser_context_id,
- extension_id, event_id, event_name));
}
EventRouter::EventRouter(BrowserContext* browser_context,
@@ -664,6 +662,14 @@ void EventRouter::IncrementInFlightEventsOnUI(void* browser_context_id,
const std::string& extension_id,
int event_id,
const std::string& event_name) {
+ if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
not at google - send to devlin 2015/05/15 21:18:07 For a function called "...OnUI" this line is misle
lazyboy 2015/05/15 21:29:53 I've moved this check to call site. Put the checku
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&EventRouter::IncrementInFlightEventsOnUI,
+ browser_context_id, extension_id, event_id, event_name));
+ return;
+ }
+
DCHECK_CURRENTLY_ON(BrowserThread::UI);
BrowserContext* browser_context =
reinterpret_cast<BrowserContext*>(browser_context_id);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698