Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Side by Side Diff: mojo/edk/system/node_controller.cc

Issue 1685183004: Bootstrap Mojo IPC independent of Chrome IPC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/embedder/platform_channel_pair.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « mojo/edk/embedder/platform_channel_pair.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698