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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 MojoResult AddWaiter(unsigned port, | 64 MojoResult AddWaiter(unsigned port, |
65 Waiter* waiter, | 65 Waiter* waiter, |
66 MojoWaitFlags flags, | 66 MojoWaitFlags flags, |
67 MojoResult wake_result); | 67 MojoResult wake_result); |
68 void RemoveWaiter(unsigned port, Waiter* waiter); | 68 void RemoveWaiter(unsigned port, Waiter* waiter); |
69 | 69 |
70 // This is called by the dispatcher to convert a local endpoint to a proxy | 70 // This is called by the dispatcher to convert a local endpoint to a proxy |
71 // endpoint. | 71 // endpoint. |
72 void ConvertLocalToProxy(unsigned port); | 72 void ConvertLocalToProxy(unsigned port); |
73 | 73 |
74 // This is used internally by |WriteMessage()| and by |Channel| to enqueue | 74 // This is used by |Channel| to enqueue messages (typically to a |
75 // messages (typically to a |LocalMessagePipeEndpoint|). Unlike | 75 // |LocalMessagePipeEndpoint|). Unlike |WriteMessage()|, |port| is the |
76 // |WriteMessage()|, |port| is the *destination* port. |transports| should be | 76 // *destination* port. |
77 // non-null only if it's nonempty, and only if |message| has no dispatchers | |
78 // attached. | |
79 MojoResult EnqueueMessage(unsigned port, | 77 MojoResult EnqueueMessage(unsigned port, |
80 scoped_ptr<MessageInTransit> message, | 78 scoped_ptr<MessageInTransit> message); |
81 std::vector<DispatcherTransport>* transports); | |
82 | 79 |
83 // These are used by |Channel|. | 80 // These are used by |Channel|. |
84 bool Attach(unsigned port, | 81 bool Attach(unsigned port, |
85 scoped_refptr<Channel> channel, | 82 scoped_refptr<Channel> channel, |
86 MessageInTransit::EndpointId local_id); | 83 MessageInTransit::EndpointId local_id); |
87 void Run(unsigned port, MessageInTransit::EndpointId remote_id); | 84 void Run(unsigned port, MessageInTransit::EndpointId remote_id); |
88 void OnRemove(unsigned port); | 85 void OnRemove(unsigned port); |
89 | 86 |
90 private: | 87 private: |
91 friend class base::RefCountedThreadSafe<MessagePipe>; | 88 friend class base::RefCountedThreadSafe<MessagePipe>; |
92 virtual ~MessagePipe(); | 89 virtual ~MessagePipe(); |
93 | 90 |
94 // Used by |EnqueueMessage()| to handle control messages that are actually | 91 // This is used internally by |WriteMessage()| and by |EnqueueMessage()|. |
95 // meant for us. | 92 // |transports| may be non-null only if it's nonempty and |message| has no |
| 93 // dispatchers attached. |
| 94 MojoResult EnqueueMessageInternal( |
| 95 unsigned port, |
| 96 scoped_ptr<MessageInTransit> message, |
| 97 std::vector<DispatcherTransport>* transports); |
| 98 |
| 99 // Helper for |EnqueueMessageInternal()|. Must be called with |lock_| held. |
| 100 MojoResult AttachTransportsNoLock( |
| 101 unsigned port, |
| 102 MessageInTransit* message, |
| 103 std::vector<DispatcherTransport>* transports); |
| 104 |
| 105 // Used by |EnqueueMessageInternal()| to handle control messages that are |
| 106 // actually meant for us. |
96 MojoResult HandleControlMessage(unsigned port, | 107 MojoResult HandleControlMessage(unsigned port, |
97 scoped_ptr<MessageInTransit> message); | 108 scoped_ptr<MessageInTransit> message); |
98 | 109 |
99 base::Lock lock_; // Protects the following members. | 110 base::Lock lock_; // Protects the following members. |
100 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; | 111 scoped_ptr<MessagePipeEndpoint> endpoints_[2]; |
101 | 112 |
102 DISALLOW_COPY_AND_ASSIGN(MessagePipe); | 113 DISALLOW_COPY_AND_ASSIGN(MessagePipe); |
103 }; | 114 }; |
104 | 115 |
105 } // namespace system | 116 } // namespace system |
106 } // namespace mojo | 117 } // namespace mojo |
107 | 118 |
108 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ | 119 #endif // MOJO_SYSTEM_MESSAGE_PIPE_H_ |
OLD | NEW |