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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/public/cpp/system/watcher.h" 5 #include "mojo/public/cpp/system/watcher.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 // NOTE: It's legal for |callback| to delete |this|. 116 // NOTE: It's legal for |callback| to delete |this|.
117 if (!callback.is_null()) 117 if (!callback.is_null())
118 callback.Run(result); 118 callback.Run(result);
119 } 119 }
120 120
121 // static 121 // static
122 void Watcher::CallOnHandleReady(uintptr_t context, 122 void Watcher::CallOnHandleReady(uintptr_t context,
123 MojoResult result, 123 MojoResult result,
124 MojoHandleSignalsState signals_state) { 124 MojoHandleSignalsState signals_state,
125 MojoWatchNotificationFlags flags) {
125 // NOTE: It is safe to assume the Watcher still exists because this callback 126 // NOTE: It is safe to assume the Watcher still exists because this callback
126 // will never be run after the Watcher's destructor. 127 // will never be run after the Watcher's destructor.
127 // 128 //
128 // TODO: Maybe we should also expose |signals_state| throught he Watcher API. 129 // TODO: Maybe we should also expose |signals_state| throught he Watcher API.
129 // Current HandleWatcher users have no need for it, so it's omitted here. 130 // Current HandleWatcher users have no need for it, so it's omitted here.
130 Watcher* watcher = reinterpret_cast<Watcher*>(context); 131 Watcher* watcher = reinterpret_cast<Watcher*>(context);
131 watcher->task_runner_->PostTask( 132 if ((flags & MOJO_WATCH_NOTIFICATION_FLAG_EXTERNAL_PROCESS) &&
132 FROM_HERE, 133 watcher->task_runner_->RunsTasksOnCurrentThread()) {
133 base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result)); 134 watcher->OnHandleReady(result);
135 } else {
136 watcher->task_runner_->PostTask(
137 FROM_HERE,
138 base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result));
139 }
134 } 140 }
135 141
136 } // namespace mojo 142 } // namespace mojo
OLDNEW
« mojo/public/c/system/types.h ('K') | « mojo/public/cpp/system/watcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698