OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MojoWatcher_h |
| 6 #define MojoWatcher_h |
| 7 |
| 8 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 9 #include "bindings/core/v8/ScriptWrappable.h" |
| 10 #include "bindings/core/v8/TraceWrapperMember.h" |
| 11 #include "core/dom/ContextLifecycleObserver.h" |
| 12 #include "mojo/public/cpp/system/handle.h" |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class ExecutionContext; |
| 17 class MojoHandleSignals; |
| 18 class MojoWatchCallback; |
| 19 |
| 20 class MojoWatcher final : public GarbageCollectedFinalized<MojoWatcher>, |
| 21 public ActiveScriptWrappable<MojoWatcher>, |
| 22 public ScriptWrappable, |
| 23 public ContextLifecycleObserver { |
| 24 DEFINE_WRAPPERTYPEINFO(); |
| 25 USING_GARBAGE_COLLECTED_MIXIN(MojoWatcher); |
| 26 |
| 27 public: |
| 28 static MojoWatcher* create(mojo::Handle, |
| 29 const MojoHandleSignals&, |
| 30 MojoWatchCallback*, |
| 31 ExecutionContext*); |
| 32 ~MojoWatcher(); |
| 33 |
| 34 MojoResult cancel(); |
| 35 |
| 36 DECLARE_TRACE(); |
| 37 DECLARE_TRACE_WRAPPERS(); |
| 38 |
| 39 // ActiveScriptWrappable |
| 40 bool hasPendingActivity() const final; |
| 41 |
| 42 // ContextLifecycleObserver |
| 43 void contextDestroyed(ExecutionContext*) final; |
| 44 |
| 45 private: |
| 46 friend class V8MojoWatcher; |
| 47 |
| 48 MojoWatcher(ExecutionContext*, MojoWatchCallback*); |
| 49 MojoResult watch(mojo::Handle, const MojoHandleSignals&); |
| 50 |
| 51 static void onHandleReady(uintptr_t context, |
| 52 MojoResult, |
| 53 MojoHandleSignalsState, |
| 54 MojoWatchNotificationFlags); |
| 55 void runReadyCallback(MojoResult); |
| 56 |
| 57 RefPtr<WebTaskRunner> m_taskRunner; |
| 58 TraceWrapperMember<MojoWatchCallback> m_callback; |
| 59 mojo::Handle m_handle; |
| 60 }; |
| 61 |
| 62 } // namespace blink |
| 63 |
| 64 #endif // MojoWatcher_h |
OLD | NEW |