Index: mojo/edk/system/platform_handle_dispatcher.cc |
diff --git a/third_party/mojo/src/mojo/edk/system/platform_handle_dispatcher.cc b/mojo/edk/system/platform_handle_dispatcher.cc |
similarity index 81% |
copy from third_party/mojo/src/mojo/edk/system/platform_handle_dispatcher.cc |
copy to mojo/edk/system/platform_handle_dispatcher.cc |
index c440ec06761ad8d74c9c6890d62060ccd252cb8c..f78862631e307f73644586f6cae7c59b1265bb13 100644 |
--- a/third_party/mojo/src/mojo/edk/system/platform_handle_dispatcher.cc |
+++ b/mojo/edk/system/platform_handle_dispatcher.cc |
@@ -2,27 +2,27 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "third_party/mojo/src/mojo/edk/system/platform_handle_dispatcher.h" |
+#include "mojo/edk/system/platform_handle_dispatcher.h" |
#include <algorithm> |
#include "base/logging.h" |
namespace mojo { |
-namespace system { |
+namespace edk { |
namespace { |
const size_t kInvalidPlatformHandleIndex = static_cast<size_t>(-1); |
-struct SerializedPlatformHandleDispatcher { |
+struct MOJO_ALIGNAS(8) SerializedPlatformHandleDispatcher { |
size_t platform_handle_index; // (Or |kInvalidPlatformHandleIndex|.) |
}; |
} // namespace |
-embedder::ScopedPlatformHandle PlatformHandleDispatcher::PassPlatformHandle() { |
- MutexLocker locker(&mutex()); |
+ScopedPlatformHandle PlatformHandleDispatcher::PassPlatformHandle() { |
+ base::AutoLock locker(lock()); |
return platform_handle_.Pass(); |
} |
@@ -32,10 +32,9 @@ Dispatcher::Type PlatformHandleDispatcher::GetType() const { |
// static |
scoped_refptr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize( |
- Channel* channel, |
const void* source, |
size_t size, |
- embedder::PlatformHandleVector* platform_handles) { |
+ PlatformHandleVector* platform_handles) { |
if (size != sizeof(SerializedPlatformHandleDispatcher)) { |
LOG(ERROR) << "Invalid serialized platform handle dispatcher (bad size)"; |
return nullptr; |
@@ -46,7 +45,7 @@ scoped_refptr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize( |
size_t platform_handle_index = serialization->platform_handle_index; |
// Starts off invalid, which is what we want. |
- embedder::PlatformHandle platform_handle; |
+ PlatformHandle platform_handle; |
if (platform_handle_index != kInvalidPlatformHandleIndex) { |
if (!platform_handles || |
@@ -61,11 +60,11 @@ scoped_refptr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize( |
std::swap(platform_handle, (*platform_handles)[platform_handle_index]); |
} |
- return Create(embedder::ScopedPlatformHandle(platform_handle)); |
+ return Create(ScopedPlatformHandle(platform_handle)); |
} |
PlatformHandleDispatcher::PlatformHandleDispatcher( |
- embedder::ScopedPlatformHandle platform_handle) |
+ ScopedPlatformHandle platform_handle) |
: platform_handle_(platform_handle.Pass()) { |
} |
@@ -73,18 +72,17 @@ PlatformHandleDispatcher::~PlatformHandleDispatcher() { |
} |
void PlatformHandleDispatcher::CloseImplNoLock() { |
- mutex().AssertHeld(); |
+ lock().AssertAcquired(); |
platform_handle_.reset(); |
} |
scoped_refptr<Dispatcher> |
PlatformHandleDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
- mutex().AssertHeld(); |
+ lock().AssertAcquired(); |
return Create(platform_handle_.Pass()); |
} |
void PlatformHandleDispatcher::StartSerializeImplNoLock( |
- Channel* /*channel*/, |
size_t* max_size, |
size_t* max_platform_handles) { |
DCHECK(HasOneRef()); // Only one ref => no need to take the lock. |
@@ -93,10 +91,9 @@ void PlatformHandleDispatcher::StartSerializeImplNoLock( |
} |
bool PlatformHandleDispatcher::EndSerializeAndCloseImplNoLock( |
- Channel* /*channel*/, |
void* destination, |
size_t* actual_size, |
- embedder::PlatformHandleVector* platform_handles) { |
+ PlatformHandleVector* platform_handles) { |
DCHECK(HasOneRef()); // Only one ref => no need to take the lock. |
SerializedPlatformHandleDispatcher* serialization = |
@@ -112,5 +109,5 @@ bool PlatformHandleDispatcher::EndSerializeAndCloseImplNoLock( |
return true; |
} |
-} // namespace system |
+} // namespace edk |
} // namespace mojo |