| 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 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/logging.h" | 11 #include "base/logging.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "mojo/edk/embedder/platform_handle_vector.h" | 13 #include "mojo/edk/embedder/platform_handle_vector.h" |
| 13 #include "mojo/edk/system/endpoint_relayer.h" | 14 #include "mojo/edk/system/endpoint_relayer.h" |
| 14 #include "mojo/edk/system/transport_data.h" | 15 #include "mojo/edk/system/transport_data.h" |
| 15 | 16 |
| 16 namespace mojo { | 17 namespace mojo { |
| 17 namespace system { | 18 namespace system { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 28 | 29 |
| 29 } // namespace | 30 } // namespace |
| 30 | 31 |
| 31 Channel::Channel(embedder::PlatformSupport* platform_support) | 32 Channel::Channel(embedder::PlatformSupport* platform_support) |
| 32 : platform_support_(platform_support), | 33 : platform_support_(platform_support), |
| 33 is_running_(false), | 34 is_running_(false), |
| 34 is_shutting_down_(false), | 35 is_shutting_down_(false), |
| 35 channel_manager_(nullptr) { | 36 channel_manager_(nullptr) { |
| 36 } | 37 } |
| 37 | 38 |
| 38 void Channel::Init(scoped_ptr<RawChannel> raw_channel) { | 39 void Channel::Init(std::unique_ptr<RawChannel> raw_channel) { |
| 39 DCHECK(creation_thread_checker_.CalledOnValidThread()); | 40 DCHECK(creation_thread_checker_.CalledOnValidThread()); |
| 40 DCHECK(raw_channel); | 41 DCHECK(raw_channel); |
| 41 | 42 |
| 42 // No need to take |mutex_|, since this must be called before this object | 43 // No need to take |mutex_|, since this must be called before this object |
| 43 // becomes thread-safe. | 44 // becomes thread-safe. |
| 44 DCHECK(!is_running_); | 45 DCHECK(!is_running_); |
| 45 raw_channel_ = raw_channel.Pass(); | 46 raw_channel_ = std::move(raw_channel); |
| 46 raw_channel_->Init(this); | 47 raw_channel_->Init(this); |
| 47 is_running_ = true; | 48 is_running_ = true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 void Channel::SetChannelManager(ChannelManager* channel_manager) { | 51 void Channel::SetChannelManager(ChannelManager* channel_manager) { |
| 51 DCHECK(channel_manager); | 52 DCHECK(channel_manager); |
| 52 | 53 |
| 53 MutexLocker locker(&mutex_); | 54 MutexLocker locker(&mutex_); |
| 54 DCHECK(!is_shutting_down_); | 55 DCHECK(!is_shutting_down_); |
| 55 DCHECK(!channel_manager_); | 56 DCHECK(!channel_manager_); |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 << ", local ID " << local_id << ", remote ID " << remote_id; | 626 << ", local ID " << local_id << ", remote ID " << remote_id; |
| 626 scoped_ptr<MessageInTransit> message(new MessageInTransit( | 627 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
| 627 MessageInTransit::Type::CHANNEL, subtype, num_bytes, bytes)); | 628 MessageInTransit::Type::CHANNEL, subtype, num_bytes, bytes)); |
| 628 message->set_source_id(local_id); | 629 message->set_source_id(local_id); |
| 629 message->set_destination_id(remote_id); | 630 message->set_destination_id(remote_id); |
| 630 return WriteMessage(message.Pass()); | 631 return WriteMessage(message.Pass()); |
| 631 } | 632 } |
| 632 | 633 |
| 633 } // namespace system | 634 } // namespace system |
| 634 } // namespace mojo | 635 } // namespace mojo |
| OLD | NEW |