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

Unified Diff: mojo/public/cpp/system/watcher.cc

Issue 1811433002: [mojo-edk] Expose notification source to MojoWatch callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « mojo/public/cpp/system/watcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/system/watcher.cc
diff --git a/mojo/public/cpp/system/watcher.cc b/mojo/public/cpp/system/watcher.cc
index 57235338fe98c5f58ef05d4c44957dfc95add000..a3a00a9726d691fc2c841a4d248a86a8b69a6a71 100644
--- a/mojo/public/cpp/system/watcher.cc
+++ b/mojo/public/cpp/system/watcher.cc
@@ -121,16 +121,22 @@ void Watcher::OnHandleReady(MojoResult result) {
// static
void Watcher::CallOnHandleReady(uintptr_t context,
MojoResult result,
- MojoHandleSignalsState signals_state) {
+ MojoHandleSignalsState signals_state,
+ MojoWatchNotificationFlags flags) {
// NOTE: It is safe to assume the Watcher still exists because this callback
// will never be run after the Watcher's destructor.
//
// TODO: Maybe we should also expose |signals_state| throught he Watcher API.
// Current HandleWatcher users have no need for it, so it's omitted here.
Watcher* watcher = reinterpret_cast<Watcher*>(context);
- watcher->task_runner_->PostTask(
- FROM_HERE,
- base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result));
+ if ((flags & MOJO_WATCH_NOTIFICATION_FLAG_FROM_SYSTEM) &&
+ watcher->task_runner_->RunsTasksOnCurrentThread()) {
+ watcher->OnHandleReady(result);
+ } else {
+ watcher->task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result));
+ }
}
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/system/watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698