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 "device/serial/async_waiter.h"
9 AsyncWaiter::AsyncWaiter(mojo::Handle handle,
10 MojoHandleSignals signals,
11 const Callback& callback)
12 : waiter_(mojo::Environment::GetDefaultAsyncWaiter()),
15 id_ = waiter_->AsyncWait(handle.value(),
17 MOJO_DEADLINE_INDEFINITE,
18 &AsyncWaiter::WaitComplete,
22 AsyncWaiter::~AsyncWaiter() {
24 waiter_->CancelWait(id_);
28 void AsyncWaiter::WaitComplete(void* waiter, MojoResult result) {
29 static_cast<AsyncWaiter*>(waiter)->WaitCompleteInternal(result);
32 void AsyncWaiter::WaitCompleteInternal(MojoResult result) {
34 callback_.Run(result);