| 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 #include "mojo/system/message_pipe.h" | 5 #include "mojo/system/message_pipe.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "mojo/system/channel.h" | 8 #include "mojo/system/channel.h" |
| 9 #include "mojo/system/local_message_pipe_endpoint.h" | 9 #include "mojo/system/local_message_pipe_endpoint.h" |
| 10 #include "mojo/system/message_in_transit.h" | 10 #include "mojo/system/message_in_transit.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 void MessagePipe::ConvertLocalToProxy(unsigned port) { | 149 void MessagePipe::ConvertLocalToProxy(unsigned port) { |
| 150 DCHECK(port == 0 || port == 1); | 150 DCHECK(port == 0 || port == 1); |
| 151 | 151 |
| 152 base::AutoLock locker(lock_); | 152 base::AutoLock locker(lock_); |
| 153 DCHECK(endpoints_[port]); | 153 DCHECK(endpoints_[port]); |
| 154 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeLocal); | 154 DCHECK_EQ(endpoints_[port]->GetType(), MessagePipeEndpoint::kTypeLocal); |
| 155 | 155 |
| 156 bool is_peer_open = !!endpoints_[GetPeerPort(port)]; | 156 bool is_peer_open = !!endpoints_[GetPeerPort(port)]; |
| 157 | 157 |
| 158 // TODO(vtl): Hopefully this will work if the peer has been closed and when | 158 // TODO(vtl): Allowing this case is a temporary hack. It'll set up a |
| 159 // the peer is local. If the peer is remote, we should do something more | 159 // |MessagePipe| with two proxy endpoints, which will then act as a proxy |
| 160 // sophisticated. | 160 // (rather than trying to connect the two ends directly). |
| 161 DCHECK(!is_peer_open || | 161 DLOG_IF(WARNING, |
| 162 endpoints_[GetPeerPort(port)]->GetType() == | 162 is_peer_open && |
| 163 MessagePipeEndpoint::kTypeLocal); | 163 endpoints_[GetPeerPort(port)]->GetType() != |
| 164 MessagePipeEndpoint::kTypeLocal) |
| 165 << "Direct message pipe passing across multiple channels not yet " |
| 166 "implemented; will proxy"; |
| 164 | 167 |
| 165 scoped_ptr<MessagePipeEndpoint> replacement_endpoint( | 168 scoped_ptr<MessagePipeEndpoint> replacement_endpoint( |
| 166 new ProxyMessagePipeEndpoint( | 169 new ProxyMessagePipeEndpoint( |
| 167 static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get()), | 170 static_cast<LocalMessagePipeEndpoint*>(endpoints_[port].get()), |
| 168 is_peer_open)); | 171 is_peer_open)); |
| 169 endpoints_[port].swap(replacement_endpoint); | 172 endpoints_[port].swap(replacement_endpoint); |
| 170 } | 173 } |
| 171 | 174 |
| 172 MojoResult MessagePipe::EnqueueMessage(unsigned port, | 175 MojoResult MessagePipe::EnqueueMessage(unsigned port, |
| 173 scoped_ptr<MessageInTransit> message) { | 176 scoped_ptr<MessageInTransit> message) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 MojoResult MessagePipe::HandleControlMessage( | 306 MojoResult MessagePipe::HandleControlMessage( |
| 304 unsigned /*port*/, | 307 unsigned /*port*/, |
| 305 scoped_ptr<MessageInTransit> message) { | 308 scoped_ptr<MessageInTransit> message) { |
| 306 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " | 309 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " |
| 307 << message->subtype(); | 310 << message->subtype(); |
| 308 return MOJO_RESULT_UNKNOWN; | 311 return MOJO_RESULT_UNKNOWN; |
| 309 } | 312 } |
| 310 | 313 |
| 311 } // namespace system | 314 } // namespace system |
| 312 } // namespace mojo | 315 } // namespace mojo |
| OLD | NEW |