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_SYSTEM_MESSAGE_PIPE_H_ | 5 #ifndef MOJO_SYSTEM_MESSAGE_PIPE_H_ |
6 #define MOJO_SYSTEM_MESSAGE_PIPE_H_ | 6 #define MOJO_SYSTEM_MESSAGE_PIPE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // |MessagePipe| is the secondary object implementing a message pipe (see the | 31 // |MessagePipe| is the secondary object implementing a message pipe (see the |
32 // explanatory comment in core.cc). It is typically owned by the dispatcher(s) | 32 // explanatory comment in core.cc). It is typically owned by the dispatcher(s) |
33 // corresponding to the local endpoints. This class is thread-safe. | 33 // corresponding to the local endpoints. This class is thread-safe. |
34 class MOJO_SYSTEM_IMPL_EXPORT MessagePipe | 34 class MOJO_SYSTEM_IMPL_EXPORT MessagePipe |
35 : public base::RefCountedThreadSafe<MessagePipe> { | 35 : public base::RefCountedThreadSafe<MessagePipe> { |
36 public: | 36 public: |
37 MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, | 37 MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, |
38 scoped_ptr<MessagePipeEndpoint> endpoint1); | 38 scoped_ptr<MessagePipeEndpoint> endpoint1); |
39 | 39 |
40 // Convenience constructor that constructs a |MessagePipe| with two new | 40 // Creates a |MessagePipe| with two new |LocalMessagePipeEndpoint|s. |
41 // |LocalMessagePipeEndpoint|s. | 41 static MessagePipe* CreateLocalLocal(); |
42 MessagePipe(); | 42 |
| 43 // Creates a |MessagePipe| with a |LocalMessagePipeEndpoint| on port 0 and a |
| 44 // |ProxyMessagePipeEndpoint| on port 1. |
| 45 static MessagePipe* CreateLocalProxy(); |
| 46 |
| 47 // Creates a |MessagePipe| with a |ProxyMessagePipeEndpoint| on port 0 and a |
| 48 // |LocalMessagePipeEndpoint| on port 1. |
| 49 // Note: This is really only needed in tests (outside of tests, this |
| 50 // configuration arises from a local message pipe having its port 0 |
| 51 // "converted" using |ConvertLocalToProxy()|). |
| 52 static MessagePipe* CreateProxyLocal(); |
43 | 53 |
44 // Gets the other port number (i.e., 0 -> 1, 1 -> 0). | 54 // Gets the other port number (i.e., 0 -> 1, 1 -> 0). |
45 static unsigned GetPeerPort(unsigned port); | 55 static unsigned GetPeerPort(unsigned port); |
46 | 56 |
47 // Gets the type of the endpoint (used for assertions, etc.). | 57 // Gets the type of the endpoint (used for assertions, etc.). |
48 MessagePipeEndpoint::Type GetType(unsigned port); | 58 MessagePipeEndpoint::Type GetType(unsigned port); |
49 | 59 |
50 // These are called by the dispatcher to implement its methods of | 60 // These are called by the dispatcher to implement its methods of |
51 // corresponding names. In all cases, the port |port| must be open. | 61 // corresponding names. In all cases, the port |port| must be open. |
52 void CancelAllWaiters(unsigned port); | 62 void CancelAllWaiters(unsigned port); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 base::Lock lock_; // Protects the following members. | 127 base::Lock lock_; // Protects the following members. |
118 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; | 128 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; |
119 | 129 |
120 DISALLOW_COPY_AND_ASSIGN(MessagePipe); | 130 DISALLOW_COPY_AND_ASSIGN(MessagePipe); |
121 }; | 131 }; |
122 | 132 |
123 } // namespace system | 133 } // namespace system |
124 } // namespace mojo | 134 } // namespace mojo |
125 | 135 |
126 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ | 136 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ |
OLD | NEW |