summaryrefslogtreecommitdiff
path: root/chromium/mojo/edk/system/async_waiter.h
blob: 8a1ed1c5db4fb5d7673bdefd7a2f4242385ccf69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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 edk {

// An |Awakable| implementation that just calls a given callback object.
class MOJO_SYSTEM_IMPL_EXPORT AsyncWaiter final : public Awakable {
 public:
  using AwakeCallback = base::Callback<void(MojoResult)>;

  // |callback| must satisfy the same contract as |Awakable::Awake()|.
  explicit AsyncWaiter(const AwakeCallback& callback);
  virtual ~AsyncWaiter();

 private:
  // |Awakable| implementation:
  bool Awake(MojoResult result, uintptr_t context) override;

  AwakeCallback callback_;

  DISALLOW_COPY_AND_ASSIGN(AsyncWaiter);
};

}  // namespace edk
}  // namespace mojo

#endif  // MOJO_EDK_SYSTEM_ASYNC_WAITER_H_