| 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" |
| 11 #include "mojo/system/message_pipe_dispatcher.h" | 11 #include "mojo/system/message_pipe_dispatcher.h" |
| 12 #include "mojo/system/message_pipe_endpoint.h" | 12 #include "mojo/system/message_pipe_endpoint.h" |
| 13 #include "mojo/system/proxy_message_pipe_endpoint.h" | 13 #include "mojo/system/proxy_message_pipe_endpoint.h" |
| 14 | 14 |
| 15 namespace mojo { | 15 namespace mojo { |
| 16 namespace system { | 16 namespace system { |
| 17 | 17 |
| 18 MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, | 18 MessagePipe::MessagePipe(scoped_ptr<MessagePipeEndpoint> endpoint0, |
| 19 scoped_ptr<MessagePipeEndpoint> endpoint1) { | 19 scoped_ptr<MessagePipeEndpoint> endpoint1) { |
| 20 endpoints_[0].reset(endpoint0.release()); | 20 endpoints_[0].reset(endpoint0.release()); |
| 21 endpoints_[1].reset(endpoint1.release()); | 21 endpoints_[1].reset(endpoint1.release()); |
| 22 } | 22 } |
| 23 | 23 |
| 24 MessagePipe::MessagePipe() { | 24 // static |
| 25 endpoints_[0].reset(new LocalMessagePipeEndpoint()); | 25 MessagePipe* MessagePipe::CreateLocalLocal() { |
| 26 endpoints_[1].reset(new LocalMessagePipeEndpoint()); | 26 return new MessagePipe( |
| 27 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint), |
| 28 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint)); |
| 27 } | 29 } |
| 28 | 30 |
| 29 // static | 31 // static |
| 32 MessagePipe* MessagePipe::CreateLocalProxy() { |
| 33 return new MessagePipe( |
| 34 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint), |
| 35 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint)); |
| 36 } |
| 37 |
| 38 // static |
| 39 MessagePipe* MessagePipe::CreateProxyLocal() { |
| 40 return new MessagePipe( |
| 41 scoped_ptr<MessagePipeEndpoint>(new ProxyMessagePipeEndpoint), |
| 42 scoped_ptr<MessagePipeEndpoint>(new LocalMessagePipeEndpoint)); |
| 43 } |
| 44 |
| 45 // static |
| 30 unsigned MessagePipe::GetPeerPort(unsigned port) { | 46 unsigned MessagePipe::GetPeerPort(unsigned port) { |
| 31 DCHECK(port == 0 || port == 1); | 47 DCHECK(port == 0 || port == 1); |
| 32 return port ^ 1; | 48 return port ^ 1; |
| 33 } | 49 } |
| 34 | 50 |
| 35 MessagePipeEndpoint::Type MessagePipe::GetType(unsigned port) { | 51 MessagePipeEndpoint::Type MessagePipe::GetType(unsigned port) { |
| 36 DCHECK(port == 0 || port == 1); | 52 DCHECK(port == 0 || port == 1); |
| 37 base::AutoLock locker(lock_); | 53 base::AutoLock locker(lock_); |
| 38 DCHECK(endpoints_[port]); | 54 DCHECK(endpoints_[port]); |
| 39 | 55 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 MojoResult MessagePipe::HandleControlMessage( | 303 MojoResult MessagePipe::HandleControlMessage( |
| 288 unsigned /*port*/, | 304 unsigned /*port*/, |
| 289 scoped_ptr<MessageInTransit> message) { | 305 scoped_ptr<MessageInTransit> message) { |
| 290 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " | 306 LOG(WARNING) << "Unrecognized MessagePipe control message subtype " |
| 291 << message->subtype(); | 307 << message->subtype(); |
| 292 return MOJO_RESULT_UNKNOWN; | 308 return MOJO_RESULT_UNKNOWN; |
| 293 } | 309 } |
| 294 | 310 |
| 295 } // namespace system | 311 } // namespace system |
| 296 } // namespace mojo | 312 } // namespace mojo |
| OLD | NEW |