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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // This is used internally by |WriteMessage()| and by |Channel| to enqueue | 74 // This is used internally by |WriteMessage()| and by |Channel| to enqueue |
75 // messages (typically to a |LocalMessagePipeEndpoint|). Unlike | 75 // messages (typically to a |LocalMessagePipeEndpoint|). Unlike |
76 // |WriteMessage()|, |port| is the *destination* port. |transports| should be | 76 // |WriteMessage()|, |port| is the *destination* port. |transports| should be |
77 // non-null only if it's nonempty, and only if |message| has no dispatchers | 77 // non-null only if it's nonempty, and only if |message| has no dispatchers |
78 // attached. | 78 // attached. |
79 MojoResult EnqueueMessage(unsigned port, | 79 MojoResult EnqueueMessage(unsigned port, |
80 scoped_ptr<MessageInTransit> message, | 80 scoped_ptr<MessageInTransit> message, |
81 std::vector<DispatcherTransport>* transports); | 81 std::vector<DispatcherTransport>* transports); |
82 | 82 |
83 // These are used by |Channel|. | 83 // These are used by |Channel|. |
84 void Attach(unsigned port, | 84 bool Attach(unsigned port, |
85 scoped_refptr<Channel> channel, | 85 scoped_refptr<Channel> channel, |
86 MessageInTransit::EndpointId local_id); | 86 MessageInTransit::EndpointId local_id); |
87 void Run(unsigned port, MessageInTransit::EndpointId remote_id); | 87 void Run(unsigned port, MessageInTransit::EndpointId remote_id); |
| 88 void OnRemove(unsigned port); |
88 | 89 |
89 private: | 90 private: |
90 friend class base::RefCountedThreadSafe<MessagePipe>; | 91 friend class base::RefCountedThreadSafe<MessagePipe>; |
91 virtual ~MessagePipe(); | 92 virtual ~MessagePipe(); |
92 | 93 |
93 // Used by |EnqueueMessage()| to handle control messages that are actually | 94 // Used by |EnqueueMessage()| to handle control messages that are actually |
94 // meant for us. | 95 // meant for us. |
95 MojoResult HandleControlMessage(unsigned port, | 96 MojoResult HandleControlMessage(unsigned port, |
96 scoped_ptr<MessageInTransit> message); | 97 scoped_ptr<MessageInTransit> message); |
97 | 98 |
98 base::Lock lock_; // Protects the following members. | 99 base::Lock lock_; // Protects the following members. |
99 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; | 100 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; |
100 | 101 |
101 DISALLOW_COPY_AND_ASSIGN(MessagePipe); | 102 DISALLOW_COPY_AND_ASSIGN(MessagePipe); |
102 }; | 103 }; |
103 | 104 |
104 } // namespace system | 105 } // namespace system |
105 } // namespace mojo | 106 } // namespace mojo |
106 | 107 |
107 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ | 108 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ |
OLD | NEW |