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