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 | |
196 scoped_refptr<NodeChannel> parent = GetParentChannel(); | 183 scoped_refptr<NodeChannel> parent = GetParentChannel(); |
197 if (parent) { | 184 if (parent) { |
198 parent->RequestPortMerge(port.name(), token); | 185 parent->RequestPortMerge(port.name(), token); |
199 return; | 186 return; |
200 } | 187 } |
201 | 188 |
202 base::AutoLock lock(pending_port_merges_lock_); | 189 base::AutoLock lock(pending_port_merges_lock_); |
203 pending_port_merges_.push_back(std::make_pair(token, port)); | 190 pending_port_merges_.push_back(std::make_pair(token, port)); |
204 } | 191 } |
205 | 192 |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 shutdown_callback_.Reset(); | 870 shutdown_callback_.Reset(); |
884 } | 871 } |
885 | 872 |
886 DCHECK(!callback.is_null()); | 873 DCHECK(!callback.is_null()); |
887 | 874 |
888 callback.Run(); | 875 callback.Run(); |
889 } | 876 } |
890 | 877 |
891 } // namespace edk | 878 } // namespace edk |
892 } // namespace mojo | 879 } // namespace mojo |
OLD | NEW |