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

Side by Side Diff: tools/android/forwarder2/host_forwarder_main.cc

Issue 18051018: Make host_forwarder better handle duplicate forwards. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Marcus' comments Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <errno.h> 5 #include <errno.h>
6 #include <signal.h> 6 #include <signal.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/wait.h> 8 #include <sys/wait.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 SendMessage( 127 SendMessage(
128 !removed_elements ? "ERROR: could not unmap port" : "OK", 128 !removed_elements ? "ERROR: could not unmap port" : "OK",
129 client_socket.get()); 129 client_socket.get());
130 return; 130 return;
131 } 131 }
132 int host_port; 132 int host_port;
133 if (!pickle_it.ReadInt(&host_port)) { 133 if (!pickle_it.ReadInt(&host_port)) {
134 SendMessage("ERROR: missing host port", client_socket.get()); 134 SendMessage("ERROR: missing host port", client_socket.get());
135 return; 135 return;
136 } 136 }
137 const bool use_dynamic_port_allocation = device_port == 0;
138 if (!use_dynamic_port_allocation) {
139 const std::string controller_key = MakeHostControllerMapKey(
140 adb_port, device_port);
141 LOG(INFO) << "Already forwarding device port " << device_port
142 << " to host port " << host_port;
143 if (controllers_.find(controller_key) != controllers_.end()) {
144 SendMessage(base::StringPrintf("%d:%d", device_port, host_port),
145 client_socket.get());
146 return;
147 }
148 }
137 // Create a new host controller. 149 // Create a new host controller.
138 scoped_ptr<HostController> host_controller( 150 scoped_ptr<HostController> host_controller(
139 new HostController(device_port, "127.0.0.1", host_port, adb_port, 151 new HostController(device_port, "127.0.0.1", host_port, adb_port,
140 GetExitNotifierFD())); 152 GetExitNotifierFD()));
141 if (!host_controller->Connect()) { 153 if (!host_controller->Connect()) {
142 has_failed_ = true; 154 has_failed_ = true;
143 SendMessage("ERROR: Connection to device failed.", client_socket.get()); 155 SendMessage("ERROR: Connection to device failed.", client_socket.get());
144 return; 156 return;
145 } 157 }
146 // Get the current allocated port. 158 // Get the current allocated port.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 327
316 return client_delegate.has_failed() || daemon_delegate.has_failed(); 328 return client_delegate.has_failed() || daemon_delegate.has_failed();
317 } 329 }
318 330
319 } // namespace 331 } // namespace
320 } // namespace forwarder2 332 } // namespace forwarder2
321 333
322 int main(int argc, char** argv) { 334 int main(int argc, char** argv) {
323 return forwarder2::RunHostForwarder(argc, argv); 335 return forwarder2::RunHostForwarder(argc, argv);
324 } 336 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698