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

Side by Side Diff: build/android/pylib/forwarder.py

Issue 10836323: Change Android build configurations (step 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unnecessary changes Created 8 years, 4 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 | « build/android/pylib/fake_dns.py ('k') | build/android/pylib/run_java_tests.py » ('j') | 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 import logging 5 import logging
6 import os 6 import os
7 import pexpect 7 import pexpect
8 import re 8 import re
9 import sys 9 import sys
10 10
11 import android_commands 11 import android_commands
12 from constants import CHROME_DIR 12 from constants import CHROME_DIR
13 13
14 class Forwarder(object): 14 class Forwarder(object):
15 """Class to manage port forwards from the device to the host.""" 15 """Class to manage port forwards from the device to the host."""
16 16
17 _FORWARDER_PATH = '/data/local/tmp/forwarder' 17 _FORWARDER_PATH = '/data/local/tmp/forwarder'
18 _TIMEOUT_SECS = 30 18 _TIMEOUT_SECS = 30
19 19
20 def __init__(self, adb, port_pairs, tool, host_name): 20 def __init__(self, adb, port_pairs, tool, host_name, build_type):
21 """Forwards TCP ports on the device back to the host. 21 """Forwards TCP ports on the device back to the host.
22 22
23 Works like adb forward, but in reverse. 23 Works like adb forward, but in reverse.
24 24
25 Args: 25 Args:
26 adb: Instance of AndroidCommands for talking to the device. 26 adb: Instance of AndroidCommands for talking to the device.
27 port_pairs: A list of tuples (device_port, host_port) to forward. Note 27 port_pairs: A list of tuples (device_port, host_port) to forward. Note
28 that you can specify 0 as a device_port, in which case a 28 that you can specify 0 as a device_port, in which case a
29 port will by dynamically assigned on the device. You can 29 port will by dynamically assigned on the device. You can
30 get the number of the assigned port using the 30 get the number of the assigned port using the
31 DevicePortForHostPort method. 31 DevicePortForHostPort method.
32 tool: Tool class to use to get wrapper, if necessary, for executing the 32 tool: Tool class to use to get wrapper, if necessary, for executing the
33 forwarder (see valgrind_tools.py). 33 forwarder (see valgrind_tools.py).
34 host_name: Optional. Address to forward to, must be addressable from the 34 host_name: Address to forward to, must be addressable from the
35 host machine. Usually this is omitted and loopback is used. 35 host machine. Usually use loopback '127.0.0.1'.
36 build_type: 'Release' or 'Debug'.
36 37
37 Raises: 38 Raises:
38 Exception on failure to forward the port. 39 Exception on failure to forward the port.
39 """ 40 """
40 self._adb = adb 41 self._adb = adb
41 self._host_to_device_port_map = dict() 42 self._host_to_device_port_map = dict()
42 self._process = None 43 self._process = None
43 adb.PushIfNeeded( 44 adb.PushIfNeeded(
44 os.path.join(CHROME_DIR, 'out', 'Release', 'forwarder'), 45 os.path.join(CHROME_DIR, 'out', build_type, 'forwarder'),
45 Forwarder._FORWARDER_PATH) 46 Forwarder._FORWARDER_PATH)
46 forward_string = ['%d:%d:%s' % 47 forward_string = ['%d:%d:%s' %
47 (device, host, host_name) for device, host in port_pairs] 48 (device, host, host_name) for device, host in port_pairs]
48 49
49 # Kill off any existing forwarders on conflicting non-dynamically allocated 50 # Kill off any existing forwarders on conflicting non-dynamically allocated
50 # ports. 51 # ports.
51 for device_port, _ in port_pairs: 52 for device_port, _ in port_pairs:
52 if device_port != 0: 53 if device_port != 0:
53 self._KillForwardersUsingDevicePort(device_port) 54 self._KillForwardersUsingDevicePort(device_port)
54 55
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 def DevicePortForHostPort(self, host_port): 113 def DevicePortForHostPort(self, host_port):
113 """Get the device port that corresponds to a given host port.""" 114 """Get the device port that corresponds to a given host port."""
114 return self._host_to_device_port_map.get(host_port) 115 return self._host_to_device_port_map.get(host_port)
115 116
116 def Close(self): 117 def Close(self):
117 """Terminate the forwarder process.""" 118 """Terminate the forwarder process."""
118 if self._process: 119 if self._process:
119 self._process.close() 120 self._process.close()
120 self._process = None 121 self._process = None
OLDNEW
« no previous file with comments | « build/android/pylib/fake_dns.py ('k') | build/android/pylib/run_java_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698