| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/mojo/MojoWatcher.h" | 5 #include "core/mojo/MojoWatcher.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/MojoWatchCallback.h" | 7 #include "bindings/core/v8/MojoWatchCallback.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/dom/TaskRunnerHelper.h" | 9 #include "core/dom/TaskRunnerHelper.h" |
| 10 #include "core/mojo/MojoHandleSignals.h" | 10 #include "core/mojo/MojoHandleSignals.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 163 } |
| 164 return; | 164 return; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Ignore callbacks if not watching. | 167 // Ignore callbacks if not watching. |
| 168 if (!watcher_handle_.is_valid()) | 168 if (!watcher_handle_.is_valid()) |
| 169 return; | 169 return; |
| 170 | 170 |
| 171 RunWatchCallback(callback_, this, result); | 171 RunWatchCallback(callback_, this, result); |
| 172 | 172 |
| 173 // The user callback may have canceled watching. |
| 174 if (!watcher_handle_.is_valid()) |
| 175 return; |
| 176 |
| 173 // Rearm the watcher so another notification can fire. | 177 // Rearm the watcher so another notification can fire. |
| 174 // | 178 // |
| 175 // TODO(rockot): MojoWatcher should expose some better approximation of the | 179 // TODO(rockot): MojoWatcher should expose some better approximation of the |
| 176 // new watcher API, including explicit add and removal of handles from the | 180 // new watcher API, including explicit add and removal of handles from the |
| 177 // watcher, as well as explicit arming. | 181 // watcher, as well as explicit arming. |
| 178 MojoResult ready_result; | 182 MojoResult ready_result; |
| 179 MojoResult arm_result = Arm(&ready_result); | 183 MojoResult arm_result = Arm(&ready_result); |
| 180 if (arm_result == MOJO_RESULT_OK) | 184 if (arm_result == MOJO_RESULT_OK) |
| 181 return; | 185 return; |
| 182 | 186 |
| 183 DCHECK_EQ(MOJO_RESULT_FAILED_PRECONDITION, arm_result); | 187 DCHECK_EQ(MOJO_RESULT_FAILED_PRECONDITION, arm_result); |
| 184 | 188 |
| 185 task_runner_->PostTask(BLINK_FROM_HERE, | 189 task_runner_->PostTask(BLINK_FROM_HERE, |
| 186 WTF::Bind(&MojoWatcher::RunReadyCallback, | 190 WTF::Bind(&MojoWatcher::RunReadyCallback, |
| 187 WrapWeakPersistent(this), ready_result)); | 191 WrapWeakPersistent(this), ready_result)); |
| 188 } | 192 } |
| 189 | 193 |
| 190 } // namespace blink | 194 } // namespace blink |
| OLD | NEW |