OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ |
6 #define MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ | 6 #define MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "mojo/edk/system/awakable.h" | 9 #include "mojo/edk/system/awakable.h" |
10 #include "mojo/edk/system/system_impl_export.h" | |
11 #include "mojo/public/c/system/types.h" | 10 #include "mojo/public/c/system/types.h" |
12 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
13 | 12 |
14 namespace mojo { | 13 namespace mojo { |
15 namespace system { | 14 namespace system { |
16 | 15 |
17 // An |Awakable| implementation that just calls a given callback object. | 16 // An |Awakable| implementation that just calls a given callback object. |
18 class MOJO_SYSTEM_IMPL_EXPORT AsyncWaiter final : public Awakable { | 17 class AsyncWaiter final : public Awakable { |
19 public: | 18 public: |
20 using AwakeCallback = base::Callback<void(MojoResult)>; | 19 using AwakeCallback = base::Callback<void(MojoResult)>; |
21 | 20 |
22 // |callback| must satisfy the same contract as |Awakable::Awake()|. | 21 // |callback| must satisfy the same contract as |Awakable::Awake()|. |
23 explicit AsyncWaiter(const AwakeCallback& callback); | 22 explicit AsyncWaiter(const AwakeCallback& callback); |
24 virtual ~AsyncWaiter(); | 23 ~AsyncWaiter() override; |
25 | 24 |
26 private: | 25 private: |
27 // |Awakable| implementation: | 26 // |Awakable| implementation: |
28 bool Awake(MojoResult result, uintptr_t context) override; | 27 bool Awake(MojoResult result, uintptr_t context) override; |
29 | 28 |
30 AwakeCallback callback_; | 29 AwakeCallback callback_; |
31 | 30 |
32 MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaiter); | 31 MOJO_DISALLOW_COPY_AND_ASSIGN(AsyncWaiter); |
33 }; | 32 }; |
34 | 33 |
35 } // namespace system | 34 } // namespace system |
36 } // namespace mojo | 35 } // namespace mojo |
37 | 36 |
38 #endif // MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ | 37 #endif // MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ |
OLD | NEW |