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

Side by Side Diff: mojo/edk/system/core.cc

Issue 798993003: Add embedder::AsyncWait() (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
« mojo/edk/system/async_waiter.cc ('K') | « mojo/edk/system/core.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/edk/system/core.h" 5 #include "mojo/edk/system/core.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "mojo/edk/embedder/platform_shared_buffer.h" 11 #include "mojo/edk/embedder/platform_shared_buffer.h"
12 #include "mojo/edk/embedder/platform_support.h" 12 #include "mojo/edk/embedder/platform_support.h"
13 #include "mojo/edk/system/async_waiter.h"
13 #include "mojo/edk/system/configuration.h" 14 #include "mojo/edk/system/configuration.h"
14 #include "mojo/edk/system/data_pipe.h" 15 #include "mojo/edk/system/data_pipe.h"
15 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h" 16 #include "mojo/edk/system/data_pipe_consumer_dispatcher.h"
16 #include "mojo/edk/system/data_pipe_producer_dispatcher.h" 17 #include "mojo/edk/system/data_pipe_producer_dispatcher.h"
17 #include "mojo/edk/system/dispatcher.h" 18 #include "mojo/edk/system/dispatcher.h"
18 #include "mojo/edk/system/handle_signals_state.h" 19 #include "mojo/edk/system/handle_signals_state.h"
19 #include "mojo/edk/system/local_data_pipe.h" 20 #include "mojo/edk/system/local_data_pipe.h"
20 #include "mojo/edk/system/memory.h" 21 #include "mojo/edk/system/memory.h"
21 #include "mojo/edk/system/message_pipe.h" 22 #include "mojo/edk/system/message_pipe.h"
22 #include "mojo/edk/system/message_pipe_dispatcher.h" 23 #include "mojo/edk/system/message_pipe_dispatcher.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 91 }
91 92
92 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { 93 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) {
93 if (handle == MOJO_HANDLE_INVALID) 94 if (handle == MOJO_HANDLE_INVALID)
94 return nullptr; 95 return nullptr;
95 96
96 base::AutoLock locker(handle_table_lock_); 97 base::AutoLock locker(handle_table_lock_);
97 return handle_table_.GetDispatcher(handle); 98 return handle_table_.GetDispatcher(handle);
98 } 99 }
99 100
101 MojoResult Core::AsyncWait(MojoHandle handle,
viettrungluu 2014/12/12 21:39:31 You should add a test in core_unittest.cc for this
102 MojoHandleSignals signals,
103 base::Callback<void(MojoResult)> callback) {
104 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle);
105 DCHECK(dispatcher);
106
107 scoped_ptr<AsyncWaiter> waiter = make_scoped_ptr(new AsyncWaiter(callback));
108 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr);
109 if (rv != MOJO_RESULT_OK)
viettrungluu 2014/12/12 21:39:31 Probably: if (rv == MOJO_RESULT_OK) ignore_resu
gmorrita 2014/12/12 22:56:28 Done.
110 return rv;
111
112 ignore_result(waiter.release());
113 return MOJO_RESULT_OK;
114 }
115
100 MojoTimeTicks Core::GetTimeTicksNow() { 116 MojoTimeTicks Core::GetTimeTicksNow() {
101 return base::TimeTicks::Now().ToInternalValue(); 117 return base::TimeTicks::Now().ToInternalValue();
102 } 118 }
103 119
104 MojoResult Core::Close(MojoHandle handle) { 120 MojoResult Core::Close(MojoHandle handle) {
105 if (handle == MOJO_HANDLE_INVALID) 121 if (handle == MOJO_HANDLE_INVALID)
106 return MOJO_RESULT_INVALID_ARGUMENT; 122 return MOJO_RESULT_INVALID_ARGUMENT;
107 123
108 scoped_refptr<Dispatcher> dispatcher; 124 scoped_refptr<Dispatcher> dispatcher;
109 { 125 {
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 if (signals_states) { 602 if (signals_states) {
587 for (; i < num_handles; i++) 603 for (; i < num_handles; i++)
588 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); 604 signals_states[i] = dispatchers[i]->GetHandleSignalsState();
589 } 605 }
590 606
591 return rv; 607 return rv;
592 } 608 }
593 609
594 } // namespace system 610 } // namespace system
595 } // namespace mojo 611 } // namespace mojo
OLDNEW
« mojo/edk/system/async_waiter.cc ('K') | « mojo/edk/system/core.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698