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_controller.h" | 5 #include "mojo/edk/system/node_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 DVLOG(2) << "Reserving port " << port.name() << "@" << name_ << " for token " | 173 DVLOG(2) << "Reserving port " << port.name() << "@" << name_ << " for token " |
174 << token; | 174 << token; |
175 | 175 |
176 base::AutoLock lock(reserved_ports_lock_); | 176 base::AutoLock lock(reserved_ports_lock_); |
177 auto result = reserved_ports_.insert(std::make_pair(token, port)); | 177 auto result = reserved_ports_.insert(std::make_pair(token, port)); |
178 DCHECK(result.second); | 178 DCHECK(result.second); |
179 } | 179 } |
180 | 180 |
181 void NodeController::MergePortIntoParent(const std::string& token, | 181 void NodeController::MergePortIntoParent(const std::string& token, |
182 const ports::PortRef& port) { | 182 const ports::PortRef& port) { |
| 183 { |
| 184 // This request may be coming from within the process that reserved the |
| 185 // "parent" side (e.g. for Chrome single-process mode), so if this token is |
| 186 // reserved locally, merge locally instead. |
| 187 base::AutoLock lock(reserved_ports_lock_); |
| 188 auto it = reserved_ports_.find(token); |
| 189 if (it != reserved_ports_.end()) { |
| 190 node_->MergePorts(port, name_, it->second.name()); |
| 191 reserved_ports_.erase(it); |
| 192 return; |
| 193 } |
| 194 } |
| 195 |
183 scoped_refptr<NodeChannel> parent = GetParentChannel(); | 196 scoped_refptr<NodeChannel> parent = GetParentChannel(); |
184 if (parent) { | 197 if (parent) { |
185 parent->RequestPortMerge(port.name(), token); | 198 parent->RequestPortMerge(port.name(), token); |
186 return; | 199 return; |
187 } | 200 } |
188 | 201 |
189 base::AutoLock lock(pending_port_merges_lock_); | 202 base::AutoLock lock(pending_port_merges_lock_); |
190 pending_port_merges_.push_back(std::make_pair(token, port)); | 203 pending_port_merges_.push_back(std::make_pair(token, port)); |
191 } | 204 } |
192 | 205 |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 shutdown_callback_.Reset(); | 883 shutdown_callback_.Reset(); |
871 } | 884 } |
872 | 885 |
873 DCHECK(!callback.is_null()); | 886 DCHECK(!callback.is_null()); |
874 | 887 |
875 callback.Run(); | 888 callback.Run(); |
876 } | 889 } |
877 | 890 |
878 } // namespace edk | 891 } // namespace edk |
879 } // namespace mojo | 892 } // namespace mojo |
OLD | NEW |