| 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 "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/dom/ExecutionContextTask.h" | 10 #include "core/dom/ExecutionContextTask.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // TODO(alokp): Consider raising an exception. | 29 // TODO(alokp): Consider raising an exception. |
| 30 // Current clients expect to recieve the initial error returned by MojoWatch | 30 // Current clients expect to recieve the initial error returned by MojoWatch |
| 31 // via watch callback. | 31 // via watch callback. |
| 32 // | 32 // |
| 33 // Note that the usage of wrapPersistent is intentional so that the intial | 33 // Note that the usage of wrapPersistent is intentional so that the intial |
| 34 // error is guaranteed to be reported to the client in case where the given | 34 // error is guaranteed to be reported to the client in case where the given |
| 35 // handle is invalid and garbage collection happens before the callback | 35 // handle is invalid and garbage collection happens before the callback |
| 36 // is scheduled. | 36 // is scheduled. |
| 37 if (result != MOJO_RESULT_OK) { | 37 if (result != MOJO_RESULT_OK) { |
| 38 watcher->m_taskRunner->postTask( | 38 watcher->m_taskRunner->postTask( |
| 39 BLINK_FROM_HERE, WTF::bind(&runWatchCallback, wrapPersistent(callback), | 39 BLINK_FROM_HERE, |
| 40 wrapPersistent(watcher), result)); | 40 WTF::bind(&runWatchCallback, wrapPersistent(callback), |
| 41 wrapPersistent(watcher), result)); |
| 41 } | 42 } |
| 42 return watcher; | 43 return watcher; |
| 43 } | 44 } |
| 44 | 45 |
| 45 MojoWatcher::MojoWatcher(ExecutionContext* context, MojoWatchCallback* callback) | 46 MojoWatcher::MojoWatcher(ExecutionContext* context, MojoWatchCallback* callback) |
| 46 : ContextLifecycleObserver(context), | 47 : ContextLifecycleObserver(context), |
| 47 m_taskRunner(TaskRunnerHelper::get(TaskType::UnspecedTimer, context)), | 48 m_taskRunner(TaskRunnerHelper::get(TaskType::UnspecedTimer, context)), |
| 48 m_callback(this, callback) {} | 49 m_callback(this, callback) {} |
| 49 | 50 |
| 50 MojoWatcher::~MojoWatcher() { | 51 MojoWatcher::~MojoWatcher() { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // MOJO_RESULT_CANCELLED indicates that the handle has been closed, in which | 120 // MOJO_RESULT_CANCELLED indicates that the handle has been closed, in which |
| 120 // case watch has been implicitly cancelled. There is no need to explicitly | 121 // case watch has been implicitly cancelled. There is no need to explicitly |
| 121 // cancel the watch. | 122 // cancel the watch. |
| 122 if (result == MOJO_RESULT_CANCELLED) | 123 if (result == MOJO_RESULT_CANCELLED) |
| 123 m_handle = mojo::Handle(); | 124 m_handle = mojo::Handle(); |
| 124 | 125 |
| 125 runWatchCallback(m_callback, this, result); | 126 runWatchCallback(m_callback, this, result); |
| 126 } | 127 } |
| 127 | 128 |
| 128 } // namespace blink | 129 } // namespace blink |
| OLD | NEW |