| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 Channel::Channel(embedder::PlatformSupport* platform_support) | 32 Channel::Channel(embedder::PlatformSupport* platform_support) |
| 33 : platform_support_(platform_support), | 33 : platform_support_(platform_support), |
| 34 is_running_(false), | 34 is_running_(false), |
| 35 is_shutting_down_(false), | 35 is_shutting_down_(false), |
| 36 channel_manager_(nullptr) { | 36 channel_manager_(nullptr) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 bool Channel::Init(scoped_ptr<RawChannel> raw_channel) { | 39 void Channel::Init(scoped_ptr<RawChannel> raw_channel) { |
| 40 DCHECK(creation_thread_checker_.CalledOnValidThread()); | 40 DCHECK(creation_thread_checker_.CalledOnValidThread()); |
| 41 DCHECK(raw_channel); | 41 DCHECK(raw_channel); |
| 42 | 42 |
| 43 // No need to take |lock_|, since this must be called before this object | 43 // No need to take |lock_|, since this must be called before this object |
| 44 // becomes thread-safe. | 44 // becomes thread-safe. |
| 45 DCHECK(!is_running_); | 45 DCHECK(!is_running_); |
| 46 raw_channel_ = raw_channel.Pass(); | 46 raw_channel_ = raw_channel.Pass(); |
| 47 | 47 raw_channel_->Init(this); |
| 48 if (!raw_channel_->Init(this)) { | |
| 49 raw_channel_.reset(); | |
| 50 return false; | |
| 51 } | |
| 52 | |
| 53 is_running_ = true; | 48 is_running_ = true; |
| 54 return true; | |
| 55 } | 49 } |
| 56 | 50 |
| 57 void Channel::SetChannelManager(ChannelManager* channel_manager) { | 51 void Channel::SetChannelManager(ChannelManager* channel_manager) { |
| 58 DCHECK(channel_manager); | 52 DCHECK(channel_manager); |
| 59 | 53 |
| 60 base::AutoLock locker(lock_); | 54 base::AutoLock locker(lock_); |
| 61 DCHECK(!is_shutting_down_); | 55 DCHECK(!is_shutting_down_); |
| 62 DCHECK(!channel_manager_); | 56 DCHECK(!channel_manager_); |
| 63 channel_manager_ = channel_manager; | 57 channel_manager_ = channel_manager; |
| 64 } | 58 } |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 << ", local ID " << local_id << ", remote ID " << remote_id; | 595 << ", local ID " << local_id << ", remote ID " << remote_id; |
| 602 scoped_ptr<MessageInTransit> message(new MessageInTransit( | 596 scoped_ptr<MessageInTransit> message(new MessageInTransit( |
| 603 MessageInTransit::kTypeChannel, subtype, 0, nullptr)); | 597 MessageInTransit::kTypeChannel, subtype, 0, nullptr)); |
| 604 message->set_source_id(local_id); | 598 message->set_source_id(local_id); |
| 605 message->set_destination_id(remote_id); | 599 message->set_destination_id(remote_id); |
| 606 return WriteMessage(message.Pass()); | 600 return WriteMessage(message.Pass()); |
| 607 } | 601 } |
| 608 | 602 |
| 609 } // namespace system | 603 } // namespace system |
| 610 } // namespace mojo | 604 } // namespace mojo |
| OLD | NEW |