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
3 // found in the LICENSE file.
5 #include "mojo/environment/default_async_waiter_impl.h"
8 #include "mojo/common/handle_watcher.h"
14 void OnHandleReady(common::HandleWatcher
* watcher
,
15 MojoAsyncWaitCallback callback
,
19 callback(closure
, result
);
22 MojoAsyncWaitID
AsyncWait(MojoHandle handle
,
23 MojoHandleSignals signals
,
24 MojoDeadline deadline
,
25 MojoAsyncWaitCallback callback
,
27 // This instance will be deleted when done or cancelled.
28 common::HandleWatcher
* watcher
= new common::HandleWatcher();
29 watcher
->Start(Handle(handle
), signals
, deadline
,
30 base::Bind(&OnHandleReady
, watcher
, callback
, closure
));
31 return reinterpret_cast<MojoAsyncWaitID
>(watcher
);
34 void CancelWait(MojoAsyncWaitID wait_id
) {
35 delete reinterpret_cast<common::HandleWatcher
*>(wait_id
);
38 const MojoAsyncWaiter kDefaultAsyncWaiter
= {
45 const MojoAsyncWaiter
* GetDefaultAsyncWaiterImpl() {
46 return &kDefaultAsyncWaiter
;
49 } // namespace internal