OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_MESSAGE_PIPE_DISPATCHER_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ | 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "mojo/edk/system/dispatcher.h" | 9 #include "mojo/edk/system/dispatcher.h" |
10 #include "mojo/edk/system/memory.h" | 10 #include "mojo/edk/system/memory.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 // Validates and/or sets default options for |MojoCreateMessagePipeOptions|. | 35 // Validates and/or sets default options for |MojoCreateMessagePipeOptions|. |
36 // If non-null, |in_options| must point to a struct of at least | 36 // If non-null, |in_options| must point to a struct of at least |
37 // |in_options->struct_size| bytes. |out_options| must point to a (current) | 37 // |in_options->struct_size| bytes. |out_options| must point to a (current) |
38 // |MojoCreateMessagePipeOptions| and will be entirely overwritten on success | 38 // |MojoCreateMessagePipeOptions| and will be entirely overwritten on success |
39 // (it may be partly overwritten on failure). | 39 // (it may be partly overwritten on failure). |
40 static MojoResult ValidateCreateOptions( | 40 static MojoResult ValidateCreateOptions( |
41 UserPointer<const MojoCreateMessagePipeOptions> in_options, | 41 UserPointer<const MojoCreateMessagePipeOptions> in_options, |
42 MojoCreateMessagePipeOptions* out_options); | 42 MojoCreateMessagePipeOptions* out_options); |
43 | 43 |
44 // Must be called before any other methods. (This method is not thread-safe.) | 44 // Must be called before any other methods. (This method is not thread-safe.) |
45 void Init(scoped_refptr<MessagePipe> message_pipe, | 45 void Init(RefPtr<MessagePipe>&& message_pipe, |
46 unsigned port) MOJO_NOT_THREAD_SAFE; | 46 unsigned port) MOJO_NOT_THREAD_SAFE; |
47 | 47 |
48 // |Dispatcher| public methods: | 48 // |Dispatcher| public methods: |
49 Type GetType() const override; | 49 Type GetType() const override; |
50 | 50 |
51 // Creates a |MessagePipe| with a local endpoint (at port 0) and a proxy | 51 // Creates a |MessagePipe| with a local endpoint (at port 0) and a proxy |
52 // endpoint, and creates/initializes a |MessagePipeDispatcher| (attached to | 52 // endpoint, and creates/initializes a |MessagePipeDispatcher| (attached to |
53 // the message pipe, port 0). | 53 // the message pipe, port 0). |
54 // TODO(vtl): This currently uses |kDefaultCreateOptions|, which is okay since | 54 // TODO(vtl): This currently uses |kDefaultCreateOptions|, which is okay since |
55 // there aren't any options, but eventually options should be plumbed through. | 55 // there aren't any options, but eventually options should be plumbed through. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 size_t* max_platform_handles) override | 103 size_t* max_platform_handles) override |
104 MOJO_NOT_THREAD_SAFE; | 104 MOJO_NOT_THREAD_SAFE; |
105 bool EndSerializeAndCloseImplNoLock( | 105 bool EndSerializeAndCloseImplNoLock( |
106 Channel* channel, | 106 Channel* channel, |
107 void* destination, | 107 void* destination, |
108 size_t* actual_size, | 108 size_t* actual_size, |
109 embedder::PlatformHandleVector* platform_handles) override | 109 embedder::PlatformHandleVector* platform_handles) override |
110 MOJO_NOT_THREAD_SAFE; | 110 MOJO_NOT_THREAD_SAFE; |
111 | 111 |
112 // This will be null if closed. | 112 // This will be null if closed. |
113 scoped_refptr<MessagePipe> message_pipe_ MOJO_GUARDED_BY(mutex()); | 113 RefPtr<MessagePipe> message_pipe_ MOJO_GUARDED_BY(mutex()); |
114 unsigned port_ MOJO_GUARDED_BY(mutex()); | 114 unsigned port_ MOJO_GUARDED_BY(mutex()); |
115 | 115 |
116 MOJO_DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher); | 116 MOJO_DISALLOW_COPY_AND_ASSIGN(MessagePipeDispatcher); |
117 }; | 117 }; |
118 | 118 |
119 class MessagePipeDispatcherTransport : public DispatcherTransport { | 119 class MessagePipeDispatcherTransport : public DispatcherTransport { |
120 public: | 120 public: |
121 explicit MessagePipeDispatcherTransport(DispatcherTransport transport); | 121 explicit MessagePipeDispatcherTransport(DispatcherTransport transport); |
122 | 122 |
123 MessagePipe* GetMessagePipe() { | 123 MessagePipe* GetMessagePipe() { |
124 return message_pipe_dispatcher()->GetMessagePipeNoLock(); | 124 return message_pipe_dispatcher()->GetMessagePipeNoLock(); |
125 } | 125 } |
126 unsigned GetPort() { return message_pipe_dispatcher()->GetPortNoLock(); } | 126 unsigned GetPort() { return message_pipe_dispatcher()->GetPortNoLock(); } |
127 | 127 |
128 private: | 128 private: |
129 MessagePipeDispatcher* message_pipe_dispatcher() { | 129 MessagePipeDispatcher* message_pipe_dispatcher() { |
130 return static_cast<MessagePipeDispatcher*>(dispatcher()); | 130 return static_cast<MessagePipeDispatcher*>(dispatcher()); |
131 } | 131 } |
132 | 132 |
133 // Copy and assign allowed. | 133 // Copy and assign allowed. |
134 }; | 134 }; |
135 | 135 |
136 } // namespace system | 136 } // namespace system |
137 } // namespace mojo | 137 } // namespace mojo |
138 | 138 |
139 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ | 139 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_DISPATCHER_H_ |
OLD | NEW |