| 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 #ifndef MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ |
| 6 #define MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include "mojo/edk/embedder/scoped_platform_handle.h" | 8 #include <vector> |
| 9 |
| 10 #include "mojo/edk/platform/scoped_platform_handle.h" |
| 9 #include "mojo/edk/system/simple_dispatcher.h" | 11 #include "mojo/edk/system/simple_dispatcher.h" |
| 10 #include "mojo/edk/util/ref_ptr.h" | 12 #include "mojo/edk/util/ref_ptr.h" |
| 11 #include "mojo/edk/util/thread_annotations.h" | 13 #include "mojo/edk/util/thread_annotations.h" |
| 12 #include "mojo/public/cpp/system/macros.h" | 14 #include "mojo/public/cpp/system/macros.h" |
| 13 | 15 |
| 14 namespace mojo { | 16 namespace mojo { |
| 15 namespace system { | 17 namespace system { |
| 16 | 18 |
| 17 // A dispatcher that simply wraps/transports a |PlatformHandle| (only for use by | 19 // A dispatcher that simply wraps/transports a |PlatformHandle| (only for use by |
| 18 // the embedder). | 20 // the embedder). |
| 19 class PlatformHandleDispatcher final : public SimpleDispatcher { | 21 class PlatformHandleDispatcher final : public SimpleDispatcher { |
| 20 public: | 22 public: |
| 21 static util::RefPtr<PlatformHandleDispatcher> Create( | 23 static util::RefPtr<PlatformHandleDispatcher> Create( |
| 22 embedder::ScopedPlatformHandle platform_handle) { | 24 platform::ScopedPlatformHandle platform_handle) { |
| 23 return AdoptRef(new PlatformHandleDispatcher(platform_handle.Pass())); | 25 return AdoptRef(new PlatformHandleDispatcher(platform_handle.Pass())); |
| 24 } | 26 } |
| 25 | 27 |
| 26 embedder::ScopedPlatformHandle PassPlatformHandle(); | 28 platform::ScopedPlatformHandle PassPlatformHandle(); |
| 27 | 29 |
| 28 // |Dispatcher| public methods: | 30 // |Dispatcher| public methods: |
| 29 Type GetType() const override; | 31 Type GetType() const override; |
| 30 | 32 |
| 31 // The "opposite" of |SerializeAndClose()|. (Typically this is called by | 33 // The "opposite" of |SerializeAndClose()|. (Typically this is called by |
| 32 // |Dispatcher::Deserialize()|.) | 34 // |Dispatcher::Deserialize()|.) |
| 33 static util::RefPtr<PlatformHandleDispatcher> Deserialize( | 35 static util::RefPtr<PlatformHandleDispatcher> Deserialize( |
| 34 Channel* channel, | 36 Channel* channel, |
| 35 const void* source, | 37 const void* source, |
| 36 size_t size, | 38 size_t size, |
| 37 std::vector<embedder::ScopedPlatformHandle>* platform_handles); | 39 std::vector<platform::ScopedPlatformHandle>* platform_handles); |
| 38 | 40 |
| 39 private: | 41 private: |
| 40 explicit PlatformHandleDispatcher( | 42 explicit PlatformHandleDispatcher( |
| 41 embedder::ScopedPlatformHandle platform_handle); | 43 platform::ScopedPlatformHandle platform_handle); |
| 42 ~PlatformHandleDispatcher() override; | 44 ~PlatformHandleDispatcher() override; |
| 43 | 45 |
| 44 // |Dispatcher| protected methods: | 46 // |Dispatcher| protected methods: |
| 45 void CloseImplNoLock() override; | 47 void CloseImplNoLock() override; |
| 46 util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() | 48 util::RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() |
| 47 override; | 49 override; |
| 48 void StartSerializeImplNoLock(Channel* channel, | 50 void StartSerializeImplNoLock(Channel* channel, |
| 49 size_t* max_size, | 51 size_t* max_size, |
| 50 size_t* max_platform_handles) override | 52 size_t* max_platform_handles) override |
| 51 MOJO_NOT_THREAD_SAFE; | 53 MOJO_NOT_THREAD_SAFE; |
| 52 bool EndSerializeAndCloseImplNoLock( | 54 bool EndSerializeAndCloseImplNoLock( |
| 53 Channel* channel, | 55 Channel* channel, |
| 54 void* destination, | 56 void* destination, |
| 55 size_t* actual_size, | 57 size_t* actual_size, |
| 56 std::vector<embedder::ScopedPlatformHandle>* platform_handles) override | 58 std::vector<platform::ScopedPlatformHandle>* platform_handles) override |
| 57 MOJO_NOT_THREAD_SAFE; | 59 MOJO_NOT_THREAD_SAFE; |
| 58 | 60 |
| 59 embedder::ScopedPlatformHandle platform_handle_ MOJO_GUARDED_BY(mutex()); | 61 platform::ScopedPlatformHandle platform_handle_ MOJO_GUARDED_BY(mutex()); |
| 60 | 62 |
| 61 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformHandleDispatcher); | 63 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformHandleDispatcher); |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 } // namespace system | 66 } // namespace system |
| 65 } // namespace mojo | 67 } // namespace mojo |
| 66 | 68 |
| 67 #endif // MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ | 69 #endif // MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ |
| OLD | NEW |