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

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

Issue 1841863002: Update monet. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Created 4 years, 8 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 | « mojo/environment/default_async_waiter.h ('k') | mojo/environment/default_async_waiter_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/environment/default_async_waiter_impl.h" 5 #include "mojo/environment/default_async_waiter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "mojo/common/handle_watcher.h" 8 #include "mojo/message_pump/handle_watcher.h"
9 #include "mojo/public/c/environment/async_waiter.h"
9 10
10 namespace mojo { 11 namespace mojo {
11 namespace internal { 12 namespace internal {
12 namespace { 13 namespace {
13 14
14 void OnHandleReady(common::HandleWatcher* watcher, 15 void OnHandleReady(common::HandleWatcher* watcher,
15 MojoAsyncWaitCallback callback, 16 MojoAsyncWaitCallback callback,
16 void* closure, 17 void* closure,
17 MojoResult result) { 18 MojoResult result) {
18 delete watcher; 19 delete watcher;
19 callback(closure, result); 20 callback(closure, result);
20 } 21 }
21 22
22 MojoAsyncWaitID AsyncWait(MojoHandle handle, 23 MojoAsyncWaitID AsyncWait(MojoHandle handle,
23 MojoHandleSignals signals, 24 MojoHandleSignals signals,
24 MojoDeadline deadline, 25 MojoDeadline deadline,
25 MojoAsyncWaitCallback callback, 26 MojoAsyncWaitCallback callback,
26 void* closure) { 27 void* closure) {
27 // This instance will be deleted when done or cancelled. 28 // This instance will be deleted when done or cancelled.
28 common::HandleWatcher* watcher = new common::HandleWatcher(); 29 common::HandleWatcher* watcher = new common::HandleWatcher();
29 watcher->Start(Handle(handle), signals, deadline, 30 watcher->Start(Handle(handle), signals, deadline,
30 base::Bind(&OnHandleReady, watcher, callback, closure)); 31 base::Bind(&OnHandleReady, watcher, callback, closure));
31 return reinterpret_cast<MojoAsyncWaitID>(watcher); 32 return reinterpret_cast<MojoAsyncWaitID>(watcher);
32 } 33 }
33 34
34 void CancelWait(MojoAsyncWaitID wait_id) { 35 void CancelWait(MojoAsyncWaitID wait_id) {
35 delete reinterpret_cast<common::HandleWatcher*>(wait_id); 36 delete reinterpret_cast<common::HandleWatcher*>(wait_id);
36 } 37 }
37 38
38 const MojoAsyncWaiter kDefaultAsyncWaiter = {
39 AsyncWait,
40 CancelWait
41 };
42
43 } // namespace 39 } // namespace
44 40
45 const MojoAsyncWaiter* GetDefaultAsyncWaiterImpl() { 41 const MojoAsyncWaiter kDefaultAsyncWaiter = {AsyncWait, CancelWait};
46 return &kDefaultAsyncWaiter;
47 }
48 42
49 } // namespace internal 43 } // namespace internal
50 } // namespace mojo 44 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/environment/default_async_waiter.h ('k') | mojo/environment/default_async_waiter_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698