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" |
9 #include "mojo/edk/system/simple_dispatcher.h" | 10 #include "mojo/edk/system/simple_dispatcher.h" |
10 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
11 | 12 |
12 namespace mojo { | 13 namespace mojo { |
13 namespace system { | 14 namespace system { |
14 | 15 |
15 // 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 |
16 // the embedder). | 17 // the embedder). |
17 class PlatformHandleDispatcher final : public SimpleDispatcher { | 18 class PlatformHandleDispatcher final : public SimpleDispatcher { |
18 public: | 19 public: |
19 static scoped_refptr<PlatformHandleDispatcher> Create( | 20 static RefPtr<PlatformHandleDispatcher> Create( |
20 embedder::ScopedPlatformHandle platform_handle) { | 21 embedder::ScopedPlatformHandle platform_handle) { |
21 return make_scoped_refptr( | 22 return AdoptRef(new PlatformHandleDispatcher(platform_handle.Pass())); |
22 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 scoped_refptr<PlatformHandleDispatcher> Deserialize( | 32 static 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 scoped_refptr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() | 45 RefPtr<Dispatcher> CreateEquivalentDispatcherAndCloseImplNoLock() override; |
46 override; | |
47 void StartSerializeImplNoLock(Channel* channel, | 46 void StartSerializeImplNoLock(Channel* channel, |
48 size_t* max_size, | 47 size_t* max_size, |
49 size_t* max_platform_handles) override | 48 size_t* max_platform_handles) override |
50 MOJO_NOT_THREAD_SAFE; | 49 MOJO_NOT_THREAD_SAFE; |
51 bool EndSerializeAndCloseImplNoLock( | 50 bool EndSerializeAndCloseImplNoLock( |
52 Channel* channel, | 51 Channel* channel, |
53 void* destination, | 52 void* destination, |
54 size_t* actual_size, | 53 size_t* actual_size, |
55 embedder::PlatformHandleVector* platform_handles) override | 54 embedder::PlatformHandleVector* platform_handles) override |
56 MOJO_NOT_THREAD_SAFE; | 55 MOJO_NOT_THREAD_SAFE; |
57 | 56 |
58 embedder::ScopedPlatformHandle platform_handle_ MOJO_GUARDED_BY(mutex()); | 57 embedder::ScopedPlatformHandle platform_handle_ MOJO_GUARDED_BY(mutex()); |
59 | 58 |
60 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformHandleDispatcher); | 59 MOJO_DISALLOW_COPY_AND_ASSIGN(PlatformHandleDispatcher); |
61 }; | 60 }; |
62 | 61 |
63 } // namespace system | 62 } // namespace system |
64 } // namespace mojo | 63 } // namespace mojo |
65 | 64 |
66 #endif // MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ | 65 #endif // MOJO_EDK_SYSTEM_PLATFORM_HANDLE_DISPATCHER_H_ |
OLD | NEW |