| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_CHANNEL_ENDPOINT_H_ | 5 #ifndef MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ |
| 6 #define MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ | 6 #define MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 11 #include "mojo/system/message_in_transit.h" | 12 #include "mojo/system/message_in_transit.h" |
| 12 #include "mojo/system/system_impl_export.h" | 13 #include "mojo/system/system_impl_export.h" |
| 13 | 14 |
| 14 namespace mojo { | 15 namespace mojo { |
| 15 namespace system { | 16 namespace system { |
| 16 | 17 |
| 17 class Channel; | 18 class Channel; |
| 18 class MessagePipe; | 19 class MessagePipe; |
| 19 | 20 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 : public base::RefCountedThreadSafe<ChannelEndpoint> { | 110 : public base::RefCountedThreadSafe<ChannelEndpoint> { |
| 110 public: | 111 public: |
| 111 // TODO(vtl): More comments.... | 112 // TODO(vtl): More comments.... |
| 112 // The caller must keep |channel| alive until the |Channel| has taken | 113 // The caller must keep |channel| alive until the |Channel| has taken |
| 113 // ownership of a reference to the created object. (TODO(vtl): Convert | 114 // ownership of a reference to the created object. (TODO(vtl): Convert |
| 114 // |Channel::AttachMessagePipeEndpoint()| to a |Channel::AttachEndpoint()| | 115 // |Channel::AttachMessagePipeEndpoint()| to a |Channel::AttachEndpoint()| |
| 115 // that takes a |ChannelEndpoint|, and move |ChannelEndpoint| creation out of | 116 // that takes a |ChannelEndpoint|, and move |ChannelEndpoint| creation out of |
| 116 // |Channel|.) | 117 // |Channel|.) |
| 117 ChannelEndpoint(MessagePipe* message_pipe, unsigned port); | 118 ChannelEndpoint(MessagePipe* message_pipe, unsigned port); |
| 118 | 119 |
| 120 // Methods called by |MessagePipe| (via |ProxyMessagePipeEndpoint|): |
| 121 |
| 122 // TODO(vtl): This currently only works if we're "running". We'll move the |
| 123 // "paused message queue" here (will this be needed when we have |
| 124 // locally-allocated remote IDs?). |
| 125 bool EnqueueMessage(scoped_ptr<MessageInTransit> message); |
| 126 |
| 127 void DetachFromMessagePipe(); |
| 128 |
| 129 // Methods called by |Channel|: |
| 130 |
| 131 // Called by |Channel| when it takes a reference to this object. |
| 119 void AttachToChannel(Channel* channel, MessageInTransit::EndpointId local_id); | 132 void AttachToChannel(Channel* channel, MessageInTransit::EndpointId local_id); |
| 133 |
| 134 // TODO(vtl): Combine this with |AttachToChannel()|. |
| 120 void Run(MessageInTransit::EndpointId remote_id); | 135 void Run(MessageInTransit::EndpointId remote_id); |
| 121 | 136 |
| 122 // Called by |Channel| before it gives up its reference to this object. | 137 // Called by |Channel| before it gives up its reference to this object. |
| 123 void DetachFromChannel(); | 138 void DetachFromChannel(); |
| 124 | 139 |
| 125 private: | 140 private: |
| 126 enum State { | 141 enum State { |
| 127 // Attached, possibly running or not. | 142 // Attached, possibly running or not. |
| 128 STATE_NORMAL, | 143 STATE_NORMAL, |
| 129 // "Zombie" states: | 144 // "Zombie" states: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 156 MessageInTransit::EndpointId local_id_; | 171 MessageInTransit::EndpointId local_id_; |
| 157 MessageInTransit::EndpointId remote_id_; | 172 MessageInTransit::EndpointId remote_id_; |
| 158 | 173 |
| 159 DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); | 174 DISALLOW_COPY_AND_ASSIGN(ChannelEndpoint); |
| 160 }; | 175 }; |
| 161 | 176 |
| 162 } // namespace system | 177 } // namespace system |
| 163 } // namespace mojo | 178 } // namespace mojo |
| 164 | 179 |
| 165 #endif // MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ | 180 #endif // MOJO_SYSTEM_CHANNEL_ENDPOINT_H_ |
| OLD | NEW |