OLD | NEW |
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" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { | 92 scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) { |
93 if (handle == MOJO_HANDLE_INVALID) | 93 if (handle == MOJO_HANDLE_INVALID) |
94 return nullptr; | 94 return nullptr; |
95 | 95 |
96 base::AutoLock locker(handle_table_lock_); | 96 base::AutoLock locker(handle_table_lock_); |
97 return handle_table_.GetDispatcher(handle); | 97 return handle_table_.GetDispatcher(handle); |
98 } | 98 } |
99 | 99 |
| 100 MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle, |
| 101 scoped_refptr<Dispatcher>* dispatcher) { |
| 102 if (handle == MOJO_HANDLE_INVALID) |
| 103 return MOJO_RESULT_INVALID_ARGUMENT; |
| 104 |
| 105 base::AutoLock locker(handle_table_lock_); |
| 106 return handle_table_.GetAndRemoveDispatcher(handle, dispatcher); |
| 107 } |
| 108 |
100 MojoResult Core::AsyncWait(MojoHandle handle, | 109 MojoResult Core::AsyncWait(MojoHandle handle, |
101 MojoHandleSignals signals, | 110 MojoHandleSignals signals, |
102 const base::Callback<void(MojoResult)>& callback) { | 111 const base::Callback<void(MojoResult)>& callback) { |
103 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle); | 112 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle); |
104 DCHECK(dispatcher); | 113 DCHECK(dispatcher); |
105 | 114 |
106 scoped_ptr<AsyncWaiter> waiter = make_scoped_ptr(new AsyncWaiter(callback)); | 115 scoped_ptr<AsyncWaiter> waiter = make_scoped_ptr(new AsyncWaiter(callback)); |
107 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr); | 116 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr); |
108 if (rv == MOJO_RESULT_OK) | 117 if (rv == MOJO_RESULT_OK) |
109 ignore_result(waiter.release()); | 118 ignore_result(waiter.release()); |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 if (signals_states) { | 608 if (signals_states) { |
600 for (; i < num_handles; i++) | 609 for (; i < num_handles; i++) |
601 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 610 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
602 } | 611 } |
603 | 612 |
604 return rv; | 613 return rv; |
605 } | 614 } |
606 | 615 |
607 } // namespace system | 616 } // namespace system |
608 } // namespace mojo | 617 } // namespace mojo |
OLD | NEW |