| 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 scoped_refptr<Dispatcher> Core::PopDispatcher(MojoHandle handle) { |
| 101 if (handle == MOJO_HANDLE_INVALID) |
| 102 return nullptr; |
| 103 |
| 104 scoped_refptr<Dispatcher> dispatcher; |
| 105 { |
| 106 base::AutoLock locker(handle_table_lock_); |
| 107 MojoResult result = |
| 108 handle_table_.GetAndRemoveDispatcher(handle, &dispatcher); |
| 109 if (result != MOJO_RESULT_OK) |
| 110 return nullptr; |
| 111 } |
| 112 return dispatcher; |
| 113 } |
| 114 |
| 100 MojoResult Core::AsyncWait(MojoHandle handle, | 115 MojoResult Core::AsyncWait(MojoHandle handle, |
| 101 MojoHandleSignals signals, | 116 MojoHandleSignals signals, |
| 102 const base::Callback<void(MojoResult)>& callback) { | 117 const base::Callback<void(MojoResult)>& callback) { |
| 103 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle); | 118 scoped_refptr<Dispatcher> dispatcher = GetDispatcher(handle); |
| 104 DCHECK(dispatcher); | 119 DCHECK(dispatcher); |
| 105 | 120 |
| 106 scoped_ptr<AsyncWaiter> waiter = make_scoped_ptr(new AsyncWaiter(callback)); | 121 scoped_ptr<AsyncWaiter> waiter = make_scoped_ptr(new AsyncWaiter(callback)); |
| 107 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr); | 122 MojoResult rv = dispatcher->AddAwakable(waiter.get(), signals, 0, nullptr); |
| 108 if (rv == MOJO_RESULT_OK) | 123 if (rv == MOJO_RESULT_OK) |
| 109 ignore_result(waiter.release()); | 124 ignore_result(waiter.release()); |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 if (signals_states) { | 614 if (signals_states) { |
| 600 for (; i < num_handles; i++) | 615 for (; i < num_handles; i++) |
| 601 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 616 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
| 602 } | 617 } |
| 603 | 618 |
| 604 return rv; | 619 return rv; |
| 605 } | 620 } |
| 606 | 621 |
| 607 } // namespace system | 622 } // namespace system |
| 608 } // namespace mojo | 623 } // namespace mojo |
| OLD | NEW |