Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: mojo/system/message_pipe.h

Issue 505863002: Mojo: Add static factory functions to MessagePipe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // Constructs a |MessagePipe| with two new |LocalMessagePipeEndpoint|s.
41 // |LocalMessagePipeEndpoint|s. 41 struct LocalLocal {};
42 MessagePipe(); 42 explicit MessagePipe(LocalLocal);
43
44 // Constructs a |MessagePipe| with a |LocalMessagePipeEndpoint| on port 0 and
45 // a |ProxyMessagePipeEndpoint| on port 1.
46 struct LocalProxy {};
47 explicit MessagePipe(LocalProxy);
48
49 // Constructs a |MessagePipe| with a |ProxyMessagePipeEndpoint| on port 0 and
50 // a |LocalMessagePipeEndpoint| on port 1.
51 // Note: This is really only needed in tests (outside of tests, this
52 // configuration arises from a local message pipe having its port 0
53 // "converted" using |ConvertLocalToProxy()|).
54 struct ProxyLocal {};
55 explicit MessagePipe(ProxyLocal);
43 56
44 // Gets the other port number (i.e., 0 -> 1, 1 -> 0). 57 // Gets the other port number (i.e., 0 -> 1, 1 -> 0).
45 static unsigned GetPeerPort(unsigned port); 58 static unsigned GetPeerPort(unsigned port);
46 59
47 // Gets the type of the endpoint (used for assertions, etc.). 60 // Gets the type of the endpoint (used for assertions, etc.).
48 MessagePipeEndpoint::Type GetType(unsigned port); 61 MessagePipeEndpoint::Type GetType(unsigned port);
49 62
50 // These are called by the dispatcher to implement its methods of 63 // These are called by the dispatcher to implement its methods of
51 // corresponding names. In all cases, the port |port| must be open. 64 // corresponding names. In all cases, the port |port| must be open.
52 void CancelAllWaiters(unsigned port); 65 void CancelAllWaiters(unsigned port);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 base::Lock lock_; // Protects the following members. 130 base::Lock lock_; // Protects the following members.
118 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; 131 scoped_ptr<MessagePipeEndpoint> endpoints_[2];
119 132
120 DISALLOW_COPY_AND_ASSIGN(MessagePipe); 133 DISALLOW_COPY_AND_ASSIGN(MessagePipe);
121 }; 134 };
122 135
123 } // namespace system 136 } // namespace system
124 } // namespace mojo 137 } // namespace mojo
125 138
126 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ 139 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698