Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(950)

Side by Side Diff: device/serial/async_waiter.cc

Issue 437933002: Add data pipe wrappers to be used to implement serial receive. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@serial-buffer
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/serial/async_waiter.h ('k') | device/serial/data_receiver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "device/serial/async_waiter.h"
6
7 namespace device {
8
9 AsyncWaiter::AsyncWaiter(mojo::Handle handle,
10 MojoHandleSignals signals,
11 const Callback& callback)
12 : waiter_(mojo::Environment::GetDefaultAsyncWaiter()),
13 id_(0),
14 callback_(callback) {
15 id_ = waiter_->AsyncWait(handle.value(),
16 signals,
17 MOJO_DEADLINE_INDEFINITE,
18 &AsyncWaiter::WaitComplete,
19 this);
20 }
21
22 AsyncWaiter::~AsyncWaiter() {
23 if (id_)
24 waiter_->CancelWait(id_);
25 }
26
27 // static
28 void AsyncWaiter::WaitComplete(void* waiter, MojoResult result) {
29 static_cast<AsyncWaiter*>(waiter)->WaitCompleteInternal(result);
30 }
31
32 void AsyncWaiter::WaitCompleteInternal(MojoResult result) {
33 id_ = 0;
34 callback_.Run(result);
35 }
36
37 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/async_waiter.h ('k') | device/serial/data_receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698