| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/platform_handle_dispatcher.h" | 5 #include "mojo/edk/system/platform_handle_dispatcher.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 ScopedPlatformHandle PlatformHandleDispatcher::PassPlatformHandle() { | 29 ScopedPlatformHandle PlatformHandleDispatcher::PassPlatformHandle() { |
| 30 MutexLocker locker(&mutex()); | 30 MutexLocker locker(&mutex()); |
| 31 return platform_handle_.Pass(); | 31 return platform_handle_.Pass(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 Dispatcher::Type PlatformHandleDispatcher::GetType() const { | 34 Dispatcher::Type PlatformHandleDispatcher::GetType() const { |
| 35 return Type::PLATFORM_HANDLE; | 35 return Type::PLATFORM_HANDLE; |
| 36 } | 36 } |
| 37 | 37 |
| 38 bool PlatformHandleDispatcher::SupportsEntrypointClass( |
| 39 EntrypointClass entrypoint_class) const { |
| 40 return false; |
| 41 } |
| 42 |
| 38 // static | 43 // static |
| 39 RefPtr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize( | 44 RefPtr<PlatformHandleDispatcher> PlatformHandleDispatcher::Deserialize( |
| 40 Channel* channel, | 45 Channel* channel, |
| 41 const void* source, | 46 const void* source, |
| 42 size_t size, | 47 size_t size, |
| 43 std::vector<ScopedPlatformHandle>* platform_handles) { | 48 std::vector<ScopedPlatformHandle>* platform_handles) { |
| 44 if (size != sizeof(SerializedPlatformHandleDispatcher)) { | 49 if (size != sizeof(SerializedPlatformHandleDispatcher)) { |
| 45 LOG(ERROR) << "Invalid serialized platform handle dispatcher (bad size)"; | 50 LOG(ERROR) << "Invalid serialized platform handle dispatcher (bad size)"; |
| 46 return nullptr; | 51 return nullptr; |
| 47 } | 52 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 66 std::swap(platform_handle, (*platform_handles)[platform_handle_index]); | 71 std::swap(platform_handle, (*platform_handles)[platform_handle_index]); |
| 67 } | 72 } |
| 68 | 73 |
| 69 return Create(std::move(platform_handle)); | 74 return Create(std::move(platform_handle)); |
| 70 } | 75 } |
| 71 | 76 |
| 72 PlatformHandleDispatcher::PlatformHandleDispatcher( | 77 PlatformHandleDispatcher::PlatformHandleDispatcher( |
| 73 ScopedPlatformHandle platform_handle) | 78 ScopedPlatformHandle platform_handle) |
| 74 : platform_handle_(platform_handle.Pass()) {} | 79 : platform_handle_(platform_handle.Pass()) {} |
| 75 | 80 |
| 76 PlatformHandleDispatcher::~PlatformHandleDispatcher() { | 81 PlatformHandleDispatcher::~PlatformHandleDispatcher() {} |
| 77 } | |
| 78 | 82 |
| 79 void PlatformHandleDispatcher::CloseImplNoLock() { | 83 void PlatformHandleDispatcher::CloseImplNoLock() { |
| 80 mutex().AssertHeld(); | 84 mutex().AssertHeld(); |
| 81 platform_handle_.reset(); | 85 platform_handle_.reset(); |
| 82 } | 86 } |
| 83 | 87 |
| 84 RefPtr<Dispatcher> | 88 RefPtr<Dispatcher> |
| 85 PlatformHandleDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { | 89 PlatformHandleDispatcher::CreateEquivalentDispatcherAndCloseImplNoLock() { |
| 86 mutex().AssertHeld(); | 90 mutex().AssertHeld(); |
| 87 return Create(platform_handle_.Pass()); | 91 return Create(platform_handle_.Pass()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 111 } else { | 115 } else { |
| 112 serialization->platform_handle_index = kInvalidPlatformHandleIndex; | 116 serialization->platform_handle_index = kInvalidPlatformHandleIndex; |
| 113 } | 117 } |
| 114 | 118 |
| 115 *actual_size = sizeof(SerializedPlatformHandleDispatcher); | 119 *actual_size = sizeof(SerializedPlatformHandleDispatcher); |
| 116 return true; | 120 return true; |
| 117 } | 121 } |
| 118 | 122 |
| 119 } // namespace system | 123 } // namespace system |
| 120 } // namespace mojo | 124 } // namespace mojo |
| OLD | NEW |