OLD | NEW |
---|---|
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 import logging as real_logging | 4 import logging as real_logging |
5 import os | 5 import os |
6 import sys | 6 import sys |
7 | 7 |
8 from telemetry.core import local_server | 8 from telemetry.core import local_server |
9 from telemetry.core import memory_cache_http_server | 9 from telemetry.core import memory_cache_http_server |
10 from telemetry.core import network_controller | 10 from telemetry.core import network_controller |
11 from telemetry.core import tracing_controller | 11 from telemetry.core import tracing_controller |
12 from telemetry.core import util | 12 from telemetry.core import util |
13 from telemetry.internal import forwarders | |
13 from telemetry.internal.platform import (platform_backend as | 14 from telemetry.internal.platform import (platform_backend as |
14 platform_backend_module) | 15 platform_backend_module) |
15 | 16 |
16 from py_utils import discover | 17 from py_utils import discover |
17 | 18 |
18 _host_platform = None | 19 _host_platform = None |
19 # Remote platform is a dictionary from device ids to remote platform instances. | 20 # Remote platform is a dictionary from device ids to remote platform instances. |
20 _remote_platforms = {} | 21 _remote_platforms = {} |
21 | 22 |
22 | 23 |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 if paths and self.http_server.paths == paths: | 404 if paths and self.http_server.paths == paths: |
404 return False | 405 return False |
405 | 406 |
406 self.http_server.Close() | 407 self.http_server.Close() |
407 | 408 |
408 if not paths: | 409 if not paths: |
409 return False | 410 return False |
410 | 411 |
411 server = memory_cache_http_server.MemoryCacheHTTPServer(paths) | 412 server = memory_cache_http_server.MemoryCacheHTTPServer(paths) |
412 self.StartLocalServer(server) | 413 self.StartLocalServer(server) |
414 | |
415 # Requires port forwarding if browser is on remote machine, and | |
416 # replaces the http_server port number with the one resolved by | |
417 # remote machine with ssh remote port forwarding. | |
418 if not self._platform_backend._cri.local: | |
nednguyen
2017/07/18 00:44:58
This seems very wrong. Not all platform_backend ha
cywang
2017/07/18 09:03:32
Thanks a lot, I change the section to make it CrOS
| |
419 forwarder = self._platform_backend.forwarder_factory.Create( | |
420 forwarders.PortPair(self.http_server.port, 0), | |
421 use_remote_port_forwarding=True) | |
422 self.http_server.port = forwarder.host_port | |
413 return True | 423 return True |
414 | 424 |
415 def StopAllLocalServers(self): | 425 def StopAllLocalServers(self): |
416 self._local_server_controller.Close() | 426 self._local_server_controller.Close() |
417 | 427 |
418 @property | 428 @property |
419 def local_servers(self): | 429 def local_servers(self): |
420 """Returns the currently running local servers.""" | 430 """Returns the currently running local servers.""" |
421 return self._local_server_controller.local_servers | 431 return self._local_server_controller.local_servers |
422 | 432 |
423 def HasBattOrConnected(self): | 433 def HasBattOrConnected(self): |
424 return self._platform_backend.HasBattOrConnected() | 434 return self._platform_backend.HasBattOrConnected() |
425 | 435 |
426 def WaitForBatteryTemperature(self, temp): | 436 def WaitForBatteryTemperature(self, temp): |
427 """Waits for the battery on the device under test to cool down to temp. | 437 """Waits for the battery on the device under test to cool down to temp. |
428 | 438 |
429 Args: | 439 Args: |
430 temp: temperature target in degrees C. | 440 temp: temperature target in degrees C. |
431 """ | 441 """ |
432 return self._platform_backend.WaitForBatteryTemperature(temp) | 442 return self._platform_backend.WaitForBatteryTemperature(temp) |
OLD | NEW |