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(MojoAsyncWaiter
* waiter
,
25 MojoDeadline deadline
,
26 MojoAsyncWaitCallback callback
,
28 // This instance will be deleted when done or cancelled.
29 common::HandleWatcher
* watcher
= new common::HandleWatcher();
30 watcher
->Start(Handle(handle
), flags
, deadline
,
31 base::Bind(&OnHandleReady
, watcher
, callback
, closure
));
32 return reinterpret_cast<MojoAsyncWaitID
>(watcher
);
35 void CancelWait(MojoAsyncWaiter
* waiter
, MojoAsyncWaitID wait_id
) {
36 delete reinterpret_cast<common::HandleWatcher
*>(wait_id
);
39 MojoAsyncWaiter s_default_async_waiter
= {
46 MojoAsyncWaiter
* GetDefaultAsyncWaiterImpl() {
47 return &s_default_async_waiter
;
50 } // namespace internal