Index: mojo/edk/system/async_waiter.h |
diff --git a/mojo/edk/system/async_waiter.h b/mojo/edk/system/async_waiter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..da412c032659f7bc9c36d2fe8a194c3a4014a7af |
--- /dev/null |
+++ b/mojo/edk/system/async_waiter.h |
@@ -0,0 +1,38 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ |
+#define MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ |
+ |
+#include "base/callback.h" |
+#include "base/macros.h" |
+#include "mojo/edk/system/awakable.h" |
+#include "mojo/edk/system/system_impl_export.h" |
+#include "mojo/public/c/system/types.h" |
+ |
+namespace mojo { |
+namespace system { |
+ |
+// An |Awakable| implementation that just calls a given callback object. |
+class MOJO_SYSTEM_IMPL_EXPORT AsyncWaiter final : public Awakable { |
+ public: |
+ typedef base::Callback<void(MojoResult)> AwakeCallback; |
+ |
+ // |callback| must satisfy the same contract as |Awakable::Awake()|. |
+ explicit AsyncWaiter(AwakeCallback callback); |
+ virtual ~AsyncWaiter(); |
+ |
+ private: |
+ // |Awakable| implementation: |
+ bool Awake(MojoResult result, uintptr_t context) override; |
+ |
+ AwakeCallback callback_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AsyncWaiter); |
+}; |
+ |
+} // namespace system |
+} // namespace mojo |
+ |
+#endif // MOJO_EDK_SYSTEM_ASYNC_WAITER_H_ |