OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 } | 123 } |
124 | 124 |
125 // static | 125 // static |
126 void Watcher::CallOnHandleReady(uintptr_t context, | 126 void Watcher::CallOnHandleReady(uintptr_t context, |
127 MojoResult result, | 127 MojoResult result, |
128 MojoHandleSignalsState signals_state, | 128 MojoHandleSignalsState signals_state, |
129 MojoWatchNotificationFlags flags) { | 129 MojoWatchNotificationFlags flags) { |
130 // NOTE: It is safe to assume the Watcher still exists because this callback | 130 // NOTE: It is safe to assume the Watcher still exists because this callback |
131 // will never be run after the Watcher's destructor. | 131 // will never be run after the Watcher's destructor. |
132 // | 132 // |
133 // TODO: Maybe we should also expose |signals_state| throught he Watcher API. | 133 // TODO: Maybe we should also expose |signals_state| through the Watcher API. |
134 // Current HandleWatcher users have no need for it, so it's omitted here. | 134 // Current HandleWatcher users have no need for it, so it's omitted here. |
135 Watcher* watcher = reinterpret_cast<Watcher*>(context); | 135 Watcher* watcher = reinterpret_cast<Watcher*>(context); |
136 if ((flags & MOJO_WATCH_NOTIFICATION_FLAG_FROM_SYSTEM) && | 136 if ((flags & MOJO_WATCH_NOTIFICATION_FLAG_FROM_SYSTEM) && |
137 watcher->task_runner_->RunsTasksOnCurrentThread() && | 137 watcher->task_runner_->RunsTasksOnCurrentThread() && |
138 watcher->is_default_task_runner_) { | 138 watcher->is_default_task_runner_) { |
139 // System notifications will trigger from the task runner passed to | 139 // System notifications will trigger from the task runner passed to |
140 // mojo::edk::InitIPCSupport(). In Chrome this happens to always be the | 140 // mojo::edk::InitIPCSupport(). In Chrome this happens to always be the |
141 // default task runner for the IO thread. | 141 // default task runner for the IO thread. |
142 watcher->OnHandleReady(result); | 142 watcher->OnHandleReady(result); |
143 } else { | 143 } else { |
144 watcher->task_runner_->PostTask( | 144 watcher->task_runner_->PostTask( |
145 FROM_HERE, | 145 FROM_HERE, |
146 base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result)); | 146 base::Bind(&Watcher::OnHandleReady, watcher->weak_self_, result)); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 } // namespace mojo | 150 } // namespace mojo |
OLD | NEW |