| 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_H_ | 5 #ifndef MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ |
| 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ | 6 #define MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "mojo/edk/system/system_impl_export.h" | 24 #include "mojo/edk/system/system_impl_export.h" |
| 25 #include "mojo/public/c/system/message_pipe.h" | 25 #include "mojo/public/c/system/message_pipe.h" |
| 26 #include "mojo/public/c/system/types.h" | 26 #include "mojo/public/c/system/types.h" |
| 27 | 27 |
| 28 namespace mojo { | 28 namespace mojo { |
| 29 namespace system { | 29 namespace system { |
| 30 | 30 |
| 31 class Awakable; | 31 class Awakable; |
| 32 class Channel; | 32 class Channel; |
| 33 class ChannelEndpoint; | 33 class ChannelEndpoint; |
| 34 class MessageInTransitQueue; |
| 34 | 35 |
| 35 // |MessagePipe| is the secondary object implementing a message pipe (see the | 36 // |MessagePipe| is the secondary object implementing a message pipe (see the |
| 36 // explanatory comment in core.cc). It is typically owned by the dispatcher(s) | 37 // explanatory comment in core.cc). It is typically owned by the dispatcher(s) |
| 37 // corresponding to the local endpoints. This class is thread-safe. | 38 // corresponding to the local endpoints. This class is thread-safe. |
| 38 class MOJO_SYSTEM_IMPL_EXPORT MessagePipe : public ChannelEndpointClient { | 39 class MOJO_SYSTEM_IMPL_EXPORT MessagePipe : public ChannelEndpointClient { |
| 39 public: | 40 public: |
| 40 // Creates a |MessagePipe| with two new |LocalMessagePipeEndpoint|s. | 41 // Creates a |MessagePipe| with two new |LocalMessagePipeEndpoint|s. |
| 41 static MessagePipe* CreateLocalLocal(); | 42 static MessagePipe* CreateLocalLocal(); |
| 42 | 43 |
| 43 // Creates a |MessagePipe| with a |LocalMessagePipeEndpoint| on port 0 and a | 44 // Creates a |MessagePipe| with a |LocalMessagePipeEndpoint| on port 0 and a |
| 44 // |ProxyMessagePipeEndpoint| on port 1. |*channel_endpoint| is set to the | 45 // |ProxyMessagePipeEndpoint| on port 1. |*channel_endpoint| is set to the |
| 45 // (newly-created) |ChannelEndpoint| for the latter. | 46 // (newly-created) |ChannelEndpoint| for the latter. |
| 46 static MessagePipe* CreateLocalProxy( | 47 static MessagePipe* CreateLocalProxy( |
| 47 scoped_refptr<ChannelEndpoint>* channel_endpoint); | 48 scoped_refptr<ChannelEndpoint>* channel_endpoint); |
| 48 | 49 |
| 50 // Similar to |CreateLocalProxy()|, except that it'll do so from an existing |
| 51 // |ChannelEndpoint| (whose |ReplaceClient()| it'll call) and take |
| 52 // |message_queue|'s contents as already-received incoming messages. If |
| 53 // |channel_endpoint| is null, this will create a "half-open" message pipe. |
| 54 static MessagePipe* CreateLocalProxyFromExisting( |
| 55 MessageInTransitQueue* message_queue, |
| 56 ChannelEndpoint* channel_endpoint); |
| 57 |
| 49 // Creates a |MessagePipe| with a |ProxyMessagePipeEndpoint| on port 0 and a | 58 // Creates a |MessagePipe| with a |ProxyMessagePipeEndpoint| on port 0 and a |
| 50 // |LocalMessagePipeEndpoint| on port 1. |*channel_endpoint| is set to the | 59 // |LocalMessagePipeEndpoint| on port 1. |*channel_endpoint| is set to the |
| 51 // (newly-created) |ChannelEndpoint| for the former. | 60 // (newly-created) |ChannelEndpoint| for the former. |
| 52 // Note: This is really only needed in tests (outside of tests, this | 61 // Note: This is really only needed in tests (outside of tests, this |
| 53 // configuration arises from a local message pipe having its port 0 | 62 // configuration arises from a local message pipe having its port 0 |
| 54 // "converted" using |ConvertLocalToProxy()|). | 63 // "converted" using |ConvertLocalToProxy()|). |
| 55 static MessagePipe* CreateProxyLocal( | 64 static MessagePipe* CreateProxyLocal( |
| 56 scoped_refptr<ChannelEndpoint>* channel_endpoint); | 65 scoped_refptr<ChannelEndpoint>* channel_endpoint); |
| 57 | 66 |
| 58 // Gets the other port number (i.e., 0 -> 1, 1 -> 0). | 67 // Gets the other port number (i.e., 0 -> 1, 1 -> 0). |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 base::Lock lock_; // Protects the following members. | 139 base::Lock lock_; // Protects the following members. |
| 131 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; | 140 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; |
| 132 | 141 |
| 133 DISALLOW_COPY_AND_ASSIGN(MessagePipe); | 142 DISALLOW_COPY_AND_ASSIGN(MessagePipe); |
| 134 }; | 143 }; |
| 135 | 144 |
| 136 } // namespace system | 145 } // namespace system |
| 137 } // namespace mojo | 146 } // namespace mojo |
| 138 | 147 |
| 139 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ | 148 #endif // MOJO_EDK_SYSTEM_MESSAGE_PIPE_H_ |
| OLD | NEW |