Flutter Engine
handle_waiter.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter 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 FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_PKG_ZIRCON_SDK_EXT_HANDLE_WAITER_H_
6 #define FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_PKG_ZIRCON_SDK_EXT_HANDLE_WAITER_H_
7 
8 #include <lib/async/cpp/wait.h>
9 #include <lib/zx/handle.h>
10 
11 #include "flutter/fml/memory/ref_counted.h"
13 
14 namespace tonic {
15 class DartLibraryNatives;
16 } // namespace tonic
17 
18 namespace zircon {
19 namespace dart {
20 
21 class Handle;
22 
23 class HandleWaiter : public fml::RefCountedThreadSafe<HandleWaiter>,
24  public tonic::DartWrappable {
28 
29  public:
30  static fml::RefPtr<HandleWaiter> Create(Handle* handle,
31  zx_signals_t signals,
32  Dart_Handle callback);
33 
34  void Cancel();
35 
36  bool is_pending() { return wait_.is_pending(); }
37 
38  static void RegisterNatives(tonic::DartLibraryNatives* natives);
39 
40  private:
41  explicit HandleWaiter(Handle* handle,
42  zx_signals_t signals,
43  Dart_Handle callback);
44  ~HandleWaiter();
45 
46  void OnWaitComplete(async_dispatcher_t* dispatcher,
47  async::WaitBase* wait,
48  zx_status_t status,
49  const zx_packet_signal_t* signal);
50 
51  void RetainDartWrappableReference() const override { AddRef(); }
52 
53  void ReleaseDartWrappableReference() const override { Release(); }
54 
55  async::WaitMethod<HandleWaiter, &HandleWaiter::OnWaitComplete> wait_;
56  Handle* handle_;
58 };
59 
60 } // namespace dart
61 } // namespace zircon
62 
63 #endif // FLUTTER_SHELL_PLATFORM_FUCHSIA_DART_PKG_ZIRCON_SDK_EXT_HANDLE_WAITER_H_
Definition: handle.cc:14
#define FML_FRIEND_REF_COUNTED_THREAD_SAFE(T)
Definition: ref_counted.h:125
#define DEFINE_WRAPPERTYPEINFO()
Definition: dart_vm.cc:38
#define FML_FRIEND_MAKE_REF_COUNTED(T)
Definition: ref_counted.h:131