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 | 6 |
7 from telemetry.core import discover | |
8 from telemetry.core import network_controller | 7 from telemetry.core import network_controller |
9 from telemetry.core import tracing_controller | 8 from telemetry.core import tracing_controller |
10 from telemetry.core import util | 9 from telemetry.core import util |
11 from telemetry.internal.platform import platform_backend as platform_backend_mod
ule | 10 from telemetry.internal.platform import platform_backend as platform_backend_mod
ule |
| 11 from telemetry.util import classes_util |
12 | 12 |
13 | 13 |
14 _host_platform = None | 14 _host_platform = None |
15 # Remote platform is a dictionary from device ids to remote platform instances. | 15 # Remote platform is a dictionary from device ids to remote platform instances. |
16 _remote_platforms = {} | 16 _remote_platforms = {} |
17 | 17 |
18 | 18 |
19 def _InitHostPlatformIfNeeded(): | 19 def _InitHostPlatformIfNeeded(): |
20 global _host_platform | 20 global _host_platform |
21 if _host_platform: | 21 if _host_platform: |
(...skipping 10 matching lines...) Expand all Loading... |
32 | 32 |
33 | 33 |
34 def GetHostPlatform(): | 34 def GetHostPlatform(): |
35 _InitHostPlatformIfNeeded() | 35 _InitHostPlatformIfNeeded() |
36 return _host_platform | 36 return _host_platform |
37 | 37 |
38 | 38 |
39 def _IterAllPlatformBackendClasses(): | 39 def _IterAllPlatformBackendClasses(): |
40 platform_dir = os.path.dirname( | 40 platform_dir = os.path.dirname( |
41 os.path.realpath(platform_backend_module.__file__)) | 41 os.path.realpath(platform_backend_module.__file__)) |
42 return discover.DiscoverClasses( | 42 return classes_util.DiscoverClasses( |
43 platform_dir, util.GetTelemetryDir(), | 43 platform_dir, util.GetTelemetryDir(), |
44 platform_backend_module.PlatformBackend).itervalues() | 44 platform_backend_module.PlatformBackend) |
45 | 45 |
46 | 46 |
47 def GetPlatformForDevice(device, finder_options, logging=real_logging): | 47 def GetPlatformForDevice(device, finder_options, logging=real_logging): |
48 """ Returns a platform instance for the device. | 48 """ Returns a platform instance for the device. |
49 Args: | 49 Args: |
50 device: a device.Device instance. | 50 device: a device.Device instance. |
51 """ | 51 """ |
52 if device.guid in _remote_platforms: | 52 if device.guid in _remote_platforms: |
53 return _remote_platforms[device.guid] | 53 return _remote_platforms[device.guid] |
54 try: | 54 try: |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 | 308 |
309 Args: | 309 Args: |
310 proc: a process object returned from subprocess.Popen. | 310 proc: a process object returned from subprocess.Popen. |
311 app_name: on Windows, is the prefix of the application's window | 311 app_name: on Windows, is the prefix of the application's window |
312 class name that should be searched for. This helps ensure | 312 class name that should be searched for. This helps ensure |
313 that only the application's windows are closed. | 313 that only the application's windows are closed. |
314 | 314 |
315 Returns True if it is believed the attempt succeeded. | 315 Returns True if it is believed the attempt succeeded. |
316 """ | 316 """ |
317 return self._platform_backend.CooperativelyShutdown(proc, app_name) | 317 return self._platform_backend.CooperativelyShutdown(proc, app_name) |
OLD | NEW |