| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/node_channel.h" | 5 #include "mojo/edk/system/node_channel.h" |
| 6 | 6 |
| 7 #include <cstring> | 7 #include <cstring> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 | 10 |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 void NodeChannel::Start() { | 167 void NodeChannel::Start() { |
| 168 #if defined(OS_MACOSX) && !defined(OS_IOS) | 168 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 169 MachPortRelay* relay = delegate_->GetMachPortRelay(); | 169 MachPortRelay* relay = delegate_->GetMachPortRelay(); |
| 170 if (relay) | 170 if (relay) |
| 171 relay->AddObserver(this); | 171 relay->AddObserver(this); |
| 172 #endif | 172 #endif |
| 173 | 173 |
| 174 base::AutoLock lock(channel_lock_); | 174 base::AutoLock lock(channel_lock_); |
| 175 DCHECK(channel_); | 175 // ShutDown() may have already been called, in which case |channel_| is null. |
| 176 channel_->Start(); | 176 if (channel_) |
| 177 channel_->Start(); |
| 177 } | 178 } |
| 178 | 179 |
| 179 void NodeChannel::ShutDown() { | 180 void NodeChannel::ShutDown() { |
| 180 #if defined(OS_MACOSX) && !defined(OS_IOS) | 181 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 181 MachPortRelay* relay = delegate_->GetMachPortRelay(); | 182 MachPortRelay* relay = delegate_->GetMachPortRelay(); |
| 182 if (relay) | 183 if (relay) |
| 183 relay->RemoveObserver(this); | 184 relay->RemoveObserver(this); |
| 184 #endif | 185 #endif |
| 185 | 186 |
| 186 base::AutoLock lock(channel_lock_); | 187 base::AutoLock lock(channel_lock_); |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 | 755 |
| 755 base::AutoLock lock(channel_lock_); | 756 base::AutoLock lock(channel_lock_); |
| 756 if (!channel_) | 757 if (!channel_) |
| 757 DLOG(ERROR) << "Dropping message on closed channel."; | 758 DLOG(ERROR) << "Dropping message on closed channel."; |
| 758 else | 759 else |
| 759 channel_->Write(std::move(message)); | 760 channel_->Write(std::move(message)); |
| 760 } | 761 } |
| 761 | 762 |
| 762 } // namespace edk | 763 } // namespace edk |
| 763 } // namespace mojo | 764 } // namespace mojo |
| OLD | NEW |