| 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/edk/system/channel.h" | 5 #include "mojo/edk/system/channel.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 new ChannelEndpoint(relayer.get(), 0, message_queue)); | 231 new ChannelEndpoint(relayer.get(), 0, message_queue)); |
| 232 relayer->Init(endpoint.get(), peer_endpoint.get()); | 232 relayer->Init(endpoint.get(), peer_endpoint.get()); |
| 233 peer_endpoint->ReplaceClient(relayer.get(), 1); | 233 peer_endpoint->ReplaceClient(relayer.get(), 1); |
| 234 | 234 |
| 235 SerializedEndpoint* s = static_cast<SerializedEndpoint*>(destination); | 235 SerializedEndpoint* s = static_cast<SerializedEndpoint*>(destination); |
| 236 s->receiver_endpoint_id = AttachAndRunEndpoint(endpoint); | 236 s->receiver_endpoint_id = AttachAndRunEndpoint(endpoint); |
| 237 DVLOG(2) << "Serializing endpoint with remote peer (remote ID = " | 237 DVLOG(2) << "Serializing endpoint with remote peer (remote ID = " |
| 238 << s->receiver_endpoint_id << ")"; | 238 << s->receiver_endpoint_id << ")"; |
| 239 } | 239 } |
| 240 | 240 |
| 241 void Channel::SerializeEndpoint(scoped_refptr<ChannelEndpoint> endpoint, | |
| 242 void* destination) { | |
| 243 SerializedEndpoint* s = static_cast<SerializedEndpoint*>(destination); | |
| 244 s->receiver_endpoint_id = AttachAndRunEndpoint(endpoint); | |
| 245 DVLOG(2) << "Serializing endpoint (remote ID = " << s->receiver_endpoint_id | |
| 246 << ")"; | |
| 247 } | |
| 248 | |
| 249 scoped_refptr<IncomingEndpoint> Channel::DeserializeEndpoint( | 241 scoped_refptr<IncomingEndpoint> Channel::DeserializeEndpoint( |
| 250 const void* source) { | 242 const void* source) { |
| 251 const SerializedEndpoint* s = static_cast<const SerializedEndpoint*>(source); | 243 const SerializedEndpoint* s = static_cast<const SerializedEndpoint*>(source); |
| 252 ChannelEndpointId local_id = s->receiver_endpoint_id; | 244 ChannelEndpointId local_id = s->receiver_endpoint_id; |
| 253 // No need to check the validity of |local_id| -- if it's not valid, it simply | 245 // No need to check the validity of |local_id| -- if it's not valid, it simply |
| 254 // won't be in |incoming_endpoints_|. | 246 // won't be in |incoming_endpoints_|. |
| 255 DVLOG_IF(2, !local_id.is_valid() || !local_id.is_remote()) | 247 DVLOG_IF(2, !local_id.is_valid() || !local_id.is_remote()) |
| 256 << "Attempt to get incoming endpoint for invalid ID " << local_id; | 248 << "Attempt to get incoming endpoint for invalid ID " << local_id; |
| 257 | 249 |
| 258 base::AutoLock locker(lock_); | 250 base::AutoLock locker(lock_); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 << ", local ID " << local_id << ", remote ID " << remote_id; | 601 << ", local ID " << local_id << ", remote ID " << remote_id; |
| 610 scoped_ptr<MessageInTransit> message(new MessageInTransit( | 602 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
| 611 MessageInTransit::kTypeChannel, subtype, 0, nullptr)); | 603 MessageInTransit::kTypeChannel, subtype, 0, nullptr)); |
| 612 message->set_source_id(local_id); | 604 message->set_source_id(local_id); |
| 613 message->set_destination_id(remote_id); | 605 message->set_destination_id(remote_id); |
| 614 return WriteMessage(message.Pass()); | 606 return WriteMessage(message.Pass()); |
| 615 } | 607 } |
| 616 | 608 |
| 617 } // namespace system | 609 } // namespace system |
| 618 } // namespace mojo | 610 } // namespace mojo |
| OLD | NEW |