| 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" |
| 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 Loading... |
| 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, |
| 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) |
| 110 ignore_result(waiter.release()); |
| 111 return rv; |
| 112 } |
| 113 |
| 100 MojoTimeTicks Core::GetTimeTicksNow() { | 114 MojoTimeTicks Core::GetTimeTicksNow() { |
| 101 return base::TimeTicks::Now().ToInternalValue(); | 115 return base::TimeTicks::Now().ToInternalValue(); |
| 102 } | 116 } |
| 103 | 117 |
| 104 MojoResult Core::Close(MojoHandle handle) { | 118 MojoResult Core::Close(MojoHandle handle) { |
| 105 if (handle == MOJO_HANDLE_INVALID) | 119 if (handle == MOJO_HANDLE_INVALID) |
| 106 return MOJO_RESULT_INVALID_ARGUMENT; | 120 return MOJO_RESULT_INVALID_ARGUMENT; |
| 107 | 121 |
| 108 scoped_refptr<Dispatcher> dispatcher; | 122 scoped_refptr<Dispatcher> dispatcher; |
| 109 { | 123 { |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 if (signals_states) { | 600 if (signals_states) { |
| 587 for (; i < num_handles; i++) | 601 for (; i < num_handles; i++) |
| 588 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); | 602 signals_states[i] = dispatchers[i]->GetHandleSignalsState(); |
| 589 } | 603 } |
| 590 | 604 |
| 591 return rv; | 605 return rv; |
| 592 } | 606 } |
| 593 | 607 |
| 594 } // namespace system | 608 } // namespace system |
| 595 } // namespace mojo | 609 } // namespace mojo |
| OLD | NEW |