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