| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 """Functions that configure the shell before it is run manipulating its argument | 5 """Functions that configure the shell before it is run manipulating its argument |
| 6 list.""" | 6 list.""" |
| 7 | 7 |
| 8 import urlparse | 8 import urlparse |
| 9 | 9 |
| 10 _LOCAL_ORIGIN_PORT = 31337 |
| 11 |
| 10 _MAP_ORIGIN_PREFIX = '--map-origin=' | 12 _MAP_ORIGIN_PREFIX = '--map-origin=' |
| 11 # When spinning up servers for local origins, we want to use predictable ports | 13 # When spinning up servers for local origins, we want to use predictable ports |
| 12 # so that caching works between subsequent runs with the same command line. | 14 # so that caching works between subsequent runs with the same command line. |
| 13 _MAP_ORIGIN_BASE_PORT = 31338 | 15 _MAP_ORIGIN_BASE_PORT = 31338 |
| 14 | 16 |
| 15 # Port on which the mojo:debugger http server will be available on the host | 17 # Port on which the mojo:debugger http server will be available on the host |
| 16 # machine. | 18 # machine. |
| 17 _MOJO_DEBUGGER_PORT = 7777 | 19 _MOJO_DEBUGGER_PORT = 7777 |
| 18 | 20 |
| 19 | 21 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 def ConfigureDebugger(shell): | 74 def ConfigureDebugger(shell): |
| 73 """Configures mojo:debugger to run and sets up port forwarding for its http | 75 """Configures mojo:debugger to run and sets up port forwarding for its http |
| 74 server if the shell is running on a device. | 76 server if the shell is running on a device. |
| 75 | 77 |
| 76 Returns: | 78 Returns: |
| 77 Arguments that need to be appended to the shell argument list in order to | 79 Arguments that need to be appended to the shell argument list in order to |
| 78 run with the debugger. | 80 run with the debugger. |
| 79 """ | 81 """ |
| 80 shell.ForwardHostPortToShell(_MOJO_DEBUGGER_PORT) | 82 shell.ForwardHostPortToShell(_MOJO_DEBUGGER_PORT) |
| 81 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT] | 83 return ['mojo:debugger %d' % _MOJO_DEBUGGER_PORT] |
| 84 |
| 85 |
| 86 def ConfigureLocalOrigin(shell, local_dir, fixed_port=True): |
| 87 """Sets up a local http server to serve files in |local_dir| along with |
| 88 device port forwarding if needed. |
| 89 |
| 90 Returns: |
| 91 The list of arguments to be appended to the shell argument list. |
| 92 """ |
| 93 |
| 94 origin_url = shell.ServeLocalDirectory( |
| 95 local_dir, _LOCAL_ORIGIN_PORT if fixed_port else 0) |
| 96 return ["--origin=" + origin_url] |
| OLD | NEW |