Index: mojo/edk/system/shared_buffer_dispatcher.cc |
diff --git a/third_party/mojo/src/mojo/edk/system/shared_buffer_dispatcher.cc b/mojo/edk/system/shared_buffer_dispatcher.cc |
similarity index 96% |
copy from third_party/mojo/src/mojo/edk/system/shared_buffer_dispatcher.cc |
copy to mojo/edk/system/shared_buffer_dispatcher.cc |
index caf8e0b64bfb313975c6cdef71a6a4d3e283ca34..76139e61c107793529e606b6ebb29b81355b4b6b 100644 |
--- a/third_party/mojo/src/mojo/edk/system/shared_buffer_dispatcher.cc |
+++ b/mojo/edk/system/shared_buffer_dispatcher.cc |
@@ -8,8 +8,8 @@ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
+#include "mojo/edk/embedder/embedder_internal.h" |
#include "mojo/edk/embedder/platform_support.h" |
-#include "mojo/edk/system/channel.h" |
#include "mojo/edk/system/configuration.h" |
#include "mojo/edk/system/memory.h" |
#include "mojo/edk/system/options_validation.h" |
@@ -20,7 +20,7 @@ namespace system { |
namespace { |
-struct SerializedSharedBufferDispatcher { |
+struct MOJO_ALIGNAS(8) SerializedSharedBufferDispatcher { |
size_t num_bytes; |
size_t platform_handle_index; |
}; |
@@ -87,11 +87,9 @@ Dispatcher::Type SharedBufferDispatcher::GetType() const { |
// static |
scoped_refptr<SharedBufferDispatcher> SharedBufferDispatcher::Deserialize( |
- Channel* channel, |
const void* source, |
size_t size, |
embedder::PlatformHandleVector* platform_handles) { |
- DCHECK(channel); |
if (size != sizeof(SerializedSharedBufferDispatcher)) { |
LOG(ERROR) << "Invalid serialized shared buffer dispatcher (bad size)"; |
@@ -124,7 +122,7 @@ scoped_refptr<SharedBufferDispatcher> SharedBufferDispatcher::Deserialize( |
// Wrapping |platform_handle| in a |ScopedPlatformHandle| means that it'll be |
// closed even if creation fails. |
scoped_refptr<embedder::PlatformSharedBuffer> shared_buffer( |
- channel->platform_support()->CreateSharedBufferFromHandle( |
+ embedder::internal::g_platform_support->CreateSharedBufferFromHandle( |
num_bytes, embedder::ScopedPlatformHandle(platform_handle))); |
if (!shared_buffer) { |
LOG(ERROR) |
@@ -177,14 +175,14 @@ MojoResult SharedBufferDispatcher::ValidateDuplicateOptions( |
} |
void SharedBufferDispatcher::CloseImplNoLock() { |
- mutex().AssertHeld(); |
+ lock().AssertAcquired(); |
DCHECK(shared_buffer_); |
shared_buffer_ = nullptr; |
} |
scoped_refptr<Dispatcher> |
SharedBufferDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
- mutex().AssertHeld(); |
+ lock().AssertAcquired(); |
DCHECK(shared_buffer_); |
return CreateInternal(shared_buffer_.Pass()); |
} |
@@ -192,7 +190,7 @@ SharedBufferDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
MojoResult SharedBufferDispatcher::DuplicateBufferHandleImplNoLock( |
UserPointer<const MojoDuplicateBufferHandleOptions> options, |
scoped_refptr<Dispatcher>* new_dispatcher) { |
- mutex().AssertHeld(); |
+ lock().AssertAcquired(); |
MojoDuplicateBufferHandleOptions validated_options; |
MojoResult result = ValidateDuplicateOptions(options, &validated_options); |
@@ -209,7 +207,7 @@ MojoResult SharedBufferDispatcher::MapBufferImplNoLock( |
uint64_t num_bytes, |
MojoMapBufferFlags flags, |
scoped_ptr<embedder::PlatformSharedBufferMapping>* mapping) { |
- mutex().AssertHeld(); |
+ lock().AssertAcquired(); |
DCHECK(shared_buffer_); |
if (offset > static_cast<uint64_t>(std::numeric_limits<size_t>::max())) |
@@ -231,7 +229,6 @@ MojoResult SharedBufferDispatcher::MapBufferImplNoLock( |
} |
void SharedBufferDispatcher::StartSerializeImplNoLock( |
- Channel* /*channel*/, |
size_t* max_size, |
size_t* max_platform_handles) { |
DCHECK(HasOneRef()); // Only one ref => no need to take the lock. |
@@ -240,7 +237,6 @@ void SharedBufferDispatcher::StartSerializeImplNoLock( |
} |
bool SharedBufferDispatcher::EndSerializeAndCloseImplNoLock( |
- Channel* /*channel*/, |
void* destination, |
size_t* actual_size, |
embedder::PlatformHandleVector* platform_handles) { |
@@ -270,5 +266,6 @@ bool SharedBufferDispatcher::EndSerializeAndCloseImplNoLock( |
return true; |
} |
+ |
} // namespace system |
} // namespace mojo |