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

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
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 callback = callback_;
35 callback.Run(result);
raymes 2014/08/05 06:26:44 Why not just make the member non-const and call ca
Sam McNally 2014/08/05 07:26:33 Done.
36 }
37
38 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698