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

Side by Side Diff: mojo/environment/default_async_waiter_impl.cc

Issue 134253004: Mojo: AsyncWaiter and mojo/public/environment (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing files Created 6 years, 11 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 | Annotate | Revision Log
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 "mojo/environment/default_async_waiter_impl.h"
6
7 #include "base/bind.h"
8 #include "mojo/common/handle_watcher.h"
9
10 namespace mojo {
11 namespace internal {
12 namespace {
13
14 void OnHandleReady(common::HandleWatcher* watcher,
15 MojoAsyncWaitCallback callback,
16 void* closure,
17 MojoResult result) {
18 delete watcher;
19 callback(closure, result);
20 }
21
22 MojoAsyncWaitID AsyncWait(MojoAsyncWaiter* waiter,
23 MojoHandle handle,
24 MojoWaitFlags flags,
25 MojoDeadline deadline,
26 MojoAsyncWaitCallback callback,
27 void* closure) {
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);
33 }
34
35 void CancelWait(MojoAsyncWaiter* waiter, MojoAsyncWaitID wait_id) {
36 delete reinterpret_cast<common::HandleWatcher*>(wait_id);
37 }
38
39 MojoAsyncWaiter s_default_async_waiter = {
40 AsyncWait,
41 CancelWait
42 };
43
44 } // namespace
45
46 MojoAsyncWaiter* GetDefaultAsyncWaiterImpl() {
47 return &s_default_async_waiter;
48 }
49
50 } // namespace internal
51 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698