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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
16 #include "mojo/public/c/system/message_pipe.h" | 16 #include "mojo/public/c/system/message_pipe.h" |
17 #include "mojo/public/c/system/types.h" | 17 #include "mojo/public/c/system/types.h" |
18 #include "mojo/system/dispatcher.h" | 18 #include "mojo/system/dispatcher.h" |
19 #include "mojo/system/handle_signals_state.h" | 19 #include "mojo/system/handle_signals_state.h" |
20 #include "mojo/system/memory.h" | 20 #include "mojo/system/memory.h" |
21 #include "mojo/system/message_in_transit.h" | 21 #include "mojo/system/message_in_transit.h" |
22 #include "mojo/system/message_pipe_endpoint.h" | 22 #include "mojo/system/message_pipe_endpoint.h" |
23 #include "mojo/system/system_impl_export.h" | 23 #include "mojo/system/system_impl_export.h" |
24 | 24 |
25 namespace mojo { | 25 namespace mojo { |
26 namespace system { | 26 namespace system { |
27 | 27 |
28 class Channel; | 28 class Channel; |
| 29 class ChannelEndpoint; |
29 class Waiter; | 30 class Waiter; |
30 | 31 |
31 // |MessagePipe| is the secondary object implementing a message pipe (see the | 32 // |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) | 33 // explanatory comment in core.cc). It is typically owned by the dispatcher(s) |
33 // corresponding to the local endpoints. This class is thread-safe. | 34 // corresponding to the local endpoints. This class is thread-safe. |
34 class MOJO_SYSTEM_IMPL_EXPORT MessagePipe | 35 class MOJO_SYSTEM_IMPL_EXPORT MessagePipe |
35 : public base::RefCountedThreadSafe<MessagePipe> { | 36 : public base::RefCountedThreadSafe<MessagePipe> { |
36 public: | 37 public: |
37 MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, | 38 MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, |
38 scoped_ptr<MessagePipeEndpoint> endpoint1); | 39 scoped_ptr<MessagePipeEndpoint> endpoint1); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 void ConvertLocalToProxy(unsigned port); | 90 void ConvertLocalToProxy(unsigned port); |
90 | 91 |
91 // This is used by |Channel| to enqueue messages (typically to a | 92 // This is used by |Channel| to enqueue messages (typically to a |
92 // |LocalMessagePipeEndpoint|). Unlike |WriteMessage()|, |port| is the | 93 // |LocalMessagePipeEndpoint|). Unlike |WriteMessage()|, |port| is the |
93 // *destination* port. | 94 // *destination* port. |
94 MojoResult EnqueueMessage(unsigned port, | 95 MojoResult EnqueueMessage(unsigned port, |
95 scoped_ptr<MessageInTransit> message); | 96 scoped_ptr<MessageInTransit> message); |
96 | 97 |
97 // These are used by |Channel|. | 98 // These are used by |Channel|. |
98 bool Attach(unsigned port, | 99 bool Attach(unsigned port, |
99 scoped_refptr<Channel> channel, | 100 ChannelEndpoint* channel_endpoint, |
| 101 Channel* channel, |
100 MessageInTransit::EndpointId local_id); | 102 MessageInTransit::EndpointId local_id); |
101 void Run(unsigned port, MessageInTransit::EndpointId remote_id); | 103 void Run(unsigned port, MessageInTransit::EndpointId remote_id); |
102 void OnRemove(unsigned port); | 104 void OnRemove(unsigned port); |
103 | 105 |
104 private: | 106 private: |
105 friend class base::RefCountedThreadSafe<MessagePipe>; | 107 friend class base::RefCountedThreadSafe<MessagePipe>; |
106 virtual ~MessagePipe(); | 108 virtual ~MessagePipe(); |
107 | 109 |
108 // This is used internally by |WriteMessage()| and by |EnqueueMessage()|. | 110 // This is used internally by |WriteMessage()| and by |EnqueueMessage()|. |
109 // |transports| may be non-null only if it's nonempty and |message| has no | 111 // |transports| may be non-null only if it's nonempty and |message| has no |
(...skipping 17 matching lines...) Expand all Loading... |
127 base::Lock lock_; // Protects the following members. | 129 base::Lock lock_; // Protects the following members. |
128 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; | 130 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; |
129 | 131 |
130 DISALLOW_COPY_AND_ASSIGN(MessagePipe); | 132 DISALLOW_COPY_AND_ASSIGN(MessagePipe); |
131 }; | 133 }; |
132 | 134 |
133 } // namespace system | 135 } // namespace system |
134 } // namespace mojo | 136 } // namespace mojo |
135 | 137 |
136 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ | 138 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ |
OLD | NEW |