| Index: mojo/edk/system/core.cc
|
| diff --git a/third_party/mojo/src/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
|
| similarity index 94%
|
| copy from third_party/mojo/src/mojo/edk/system/core.cc
|
| copy to mojo/edk/system/core.cc
|
| index fbb6cf1fbf9e7c0f204a34f468e6aa3987719dfd..251b126b7761a60842e4829f4430ce1245006ed6 100644
|
| --- a/third_party/mojo/src/mojo/edk/system/core.cc
|
| +++ b/mojo/edk/system/core.cc
|
| @@ -8,6 +8,7 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/time/time.h"
|
| +#include "mojo/edk/embedder/platform_channel_pair.h"
|
| #include "mojo/edk/embedder/platform_shared_buffer.h"
|
| #include "mojo/edk/embedder/platform_support.h"
|
| #include "mojo/edk/system/async_waiter.h"
|
| @@ -18,7 +19,6 @@
|
| #include "mojo/edk/system/dispatcher.h"
|
| #include "mojo/edk/system/handle_signals_state.h"
|
| #include "mojo/edk/system/memory.h"
|
| -#include "mojo/edk/system/message_pipe.h"
|
| #include "mojo/edk/system/message_pipe_dispatcher.h"
|
| #include "mojo/edk/system/shared_buffer_dispatcher.h"
|
| #include "mojo/edk/system/waiter.h"
|
| @@ -26,7 +26,7 @@
|
| #include "mojo/public/cpp/system/macros.h"
|
|
|
| namespace mojo {
|
| -namespace system {
|
| +namespace edk {
|
|
|
| // Implementation notes
|
| //
|
| @@ -78,7 +78,7 @@ namespace system {
|
| // held.
|
|
|
| // TODO(vtl): This should take a |scoped_ptr<PlatformSupport>| as a parameter.
|
| -Core::Core(embedder::PlatformSupport* platform_support)
|
| +Core::Core(PlatformSupport* platform_support)
|
| : platform_support_(platform_support) {
|
| }
|
|
|
| @@ -86,7 +86,7 @@ Core::~Core() {
|
| }
|
|
|
| MojoHandle Core::AddDispatcher(const scoped_refptr<Dispatcher>& dispatcher) {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| return handle_table_.AddDispatcher(dispatcher);
|
| }
|
|
|
| @@ -94,7 +94,7 @@ scoped_refptr<Dispatcher> Core::GetDispatcher(MojoHandle handle) {
|
| if (handle == MOJO_HANDLE_INVALID)
|
| return nullptr;
|
|
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| return handle_table_.GetDispatcher(handle);
|
| }
|
|
|
| @@ -103,7 +103,7 @@ MojoResult Core::GetAndRemoveDispatcher(MojoHandle handle,
|
| if (handle == MOJO_HANDLE_INVALID)
|
| return MOJO_RESULT_INVALID_ARGUMENT;
|
|
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| return handle_table_.GetAndRemoveDispatcher(handle, dispatcher);
|
| }
|
|
|
| @@ -130,7 +130,7 @@ MojoResult Core::Close(MojoHandle handle) {
|
|
|
| scoped_refptr<Dispatcher> dispatcher;
|
| {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| MojoResult result =
|
| handle_table_.GetAndRemoveDispatcher(handle, &dispatcher);
|
| if (result != MOJO_RESULT_OK)
|
| @@ -138,7 +138,7 @@ MojoResult Core::Close(MojoHandle handle) {
|
| }
|
|
|
| // The dispatcher doesn't have a say in being closed, but gets notified of it.
|
| - // Note: This is done outside of |handle_table_mutex_|. As a result, there's a
|
| + // Note: This is done outside of |handle_table_lock_|. As a result, there's a
|
| // race condition that the dispatcher must handle; see the comment in
|
| // |Dispatcher| in dispatcher.h.
|
| return dispatcher->Close();
|
| @@ -211,7 +211,7 @@ MojoResult Core::CreateMessagePipe(
|
|
|
| std::pair<MojoHandle, MojoHandle> handle_pair;
|
| {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| handle_pair = handle_table_.AddDispatcherPair(dispatcher0, dispatcher1);
|
| }
|
| if (handle_pair.first == MOJO_HANDLE_INVALID) {
|
| @@ -222,9 +222,9 @@ MojoResult Core::CreateMessagePipe(
|
| return MOJO_RESULT_RESOURCE_EXHAUSTED;
|
| }
|
|
|
| - scoped_refptr<MessagePipe> message_pipe(MessagePipe::CreateLocalLocal());
|
| - dispatcher0->Init(message_pipe, 0);
|
| - dispatcher1->Init(message_pipe, 1);
|
| + PlatformChannelPair channel_pair;
|
| + dispatcher0->Init(channel_pair.PassServerHandle());
|
| + dispatcher1->Init(channel_pair.PassClientHandle());
|
|
|
| message_pipe_handle0.Put(handle_pair.first);
|
| message_pipe_handle1.Put(handle_pair.second);
|
| @@ -276,7 +276,7 @@ MojoResult Core::WriteMessage(MojoHandle message_pipe_handle,
|
| // and mark the handles as busy. If the call succeeds, we then remove the
|
| // handles from the handle table.
|
| {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| MojoResult result = handle_table_.MarkBusyAndStartTransport(
|
| message_pipe_handle, handles_reader.GetPointer(), num_handles,
|
| &transports);
|
| @@ -293,7 +293,7 @@ MojoResult Core::WriteMessage(MojoHandle message_pipe_handle,
|
| transports[i].End();
|
|
|
| {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| if (rv == MOJO_RESULT_OK) {
|
| handle_table_.RemoveBusyHandles(handles_reader.GetPointer(), num_handles);
|
| } else {
|
| @@ -335,7 +335,7 @@ MojoResult Core::ReadMessage(MojoHandle message_pipe_handle,
|
| UserPointer<MojoHandle>::Writer handles_writer(handles,
|
| dispatchers.size());
|
| {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| success = handle_table_.AddDispatcherVector(
|
| dispatchers, handles_writer.GetPointer());
|
| }
|
| @@ -371,13 +371,13 @@ MojoResult Core::CreateDataPipe(
|
| return result;
|
|
|
| scoped_refptr<DataPipeProducerDispatcher> producer_dispatcher =
|
| - DataPipeProducerDispatcher::Create();
|
| + DataPipeProducerDispatcher::Create(validated_options);
|
| scoped_refptr<DataPipeConsumerDispatcher> consumer_dispatcher =
|
| - DataPipeConsumerDispatcher::Create();
|
| + DataPipeConsumerDispatcher::Create(validated_options);
|
|
|
| std::pair<MojoHandle, MojoHandle> handle_pair;
|
| {
|
| - MutexLocker locker(&handle_table_mutex_);
|
| + base::AutoLock locker(handle_table_lock_);
|
| handle_pair = handle_table_.AddDispatcherPair(producer_dispatcher,
|
| consumer_dispatcher);
|
| }
|
| @@ -390,9 +390,9 @@ MojoResult Core::CreateDataPipe(
|
| }
|
| DCHECK_NE(handle_pair.second, MOJO_HANDLE_INVALID);
|
|
|
| - scoped_refptr<DataPipe> data_pipe(DataPipe::CreateLocal(validated_options));
|
| - producer_dispatcher->Init(data_pipe);
|
| - consumer_dispatcher->Init(data_pipe);
|
| + PlatformChannelPair channel_pair;
|
| + producer_dispatcher->Init(channel_pair.PassServerHandle());
|
| + consumer_dispatcher->Init(channel_pair.PassClientHandle());
|
|
|
| data_pipe_producer_handle.Put(handle_pair.first);
|
| data_pipe_consumer_handle.Put(handle_pair.second);
|
| @@ -531,7 +531,7 @@ MojoResult Core::MapBuffer(MojoHandle buffer_handle,
|
| if (!dispatcher)
|
| return MOJO_RESULT_INVALID_ARGUMENT;
|
|
|
| - scoped_ptr<embedder::PlatformSharedBufferMapping> mapping;
|
| + scoped_ptr<PlatformSharedBufferMapping> mapping;
|
| MojoResult result = dispatcher->MapBuffer(offset, num_bytes, flags, &mapping);
|
| if (result != MOJO_RESULT_OK)
|
| return result;
|
| @@ -539,7 +539,7 @@ MojoResult Core::MapBuffer(MojoHandle buffer_handle,
|
| DCHECK(mapping);
|
| void* address = mapping->GetBase();
|
| {
|
| - MutexLocker locker(&mapping_table_mutex_);
|
| + base::AutoLock locker(mapping_table_lock_);
|
| result = mapping_table_.AddMapping(mapping.Pass());
|
| }
|
| if (result != MOJO_RESULT_OK)
|
| @@ -550,7 +550,7 @@ MojoResult Core::MapBuffer(MojoHandle buffer_handle,
|
| }
|
|
|
| MojoResult Core::UnmapBuffer(UserPointer<void> buffer) {
|
| - MutexLocker locker(&mapping_table_mutex_);
|
| + base::AutoLock locker(mapping_table_lock_);
|
| return mapping_table_.RemoveMapping(buffer.GetPointerValue());
|
| }
|
|
|
| @@ -614,5 +614,5 @@ MojoResult Core::WaitManyInternal(const MojoHandle* handles,
|
| return rv;
|
| }
|
|
|
| -} // namespace system
|
| +} // namespace edk
|
| } // namespace mojo
|
|
|