Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 """Provides a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
| 6 | 6 |
| 7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
| 8 """ | 8 """ |
| 9 # pylint: disable=W0613 | 9 # pylint: disable=W0613 |
| 10 | 10 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 718 timeout: timeout in seconds | 718 timeout: timeout in seconds |
| 719 retries: number of retries | 719 retries: number of retries |
| 720 Returns: | 720 Returns: |
| 721 A dict containing |num_reads|, |num_writes|, |read_ms|, and |write_ms|. | 721 A dict containing |num_reads|, |num_writes|, |read_ms|, and |write_ms|. |
| 722 Raises: | 722 Raises: |
| 723 CommandTimeoutError on timeout. | 723 CommandTimeoutError on timeout. |
| 724 DeviceUnreachableError on missing device. | 724 DeviceUnreachableError on missing device. |
| 725 """ | 725 """ |
| 726 return self.old_interface.GetIoStats() | 726 return self.old_interface.GetIoStats() |
| 727 | 727 |
| 728 @decorators.WithTimeoutAndRetriesFromInstance() | |
| 729 def GetMemoryUsageForPid(self, pid, timeout=None, retries=None): | |
| 730 """Gets the memory usage for the given PID. | |
| 731 | |
| 732 Args: | |
| 733 pid: An integer containing the PID to get the memory usage for. | |
|
frankf
2014/07/23 16:39:44
you can shorten this to : "PID of the process"
jbudorick
2014/07/23 18:09:44
Done.
| |
| 734 timeout: timeout in seconds | |
| 735 retries: number of retries | |
| 736 Returns: | |
|
tonyg
2014/07/21 16:02:09
You should keep it this way in this patch for cons
jbudorick
2014/07/23 18:09:43
Changed throughout the file.
| |
| 737 A 2-tuple containing: | |
| 738 - A dict containing the overall memory usage statistics for the PID. | |
| 739 - A dict containing memory usage statistics broken down by mapping. | |
| 740 Raises: | |
| 741 CommandTimeoutError on timeout. | |
| 742 """ | |
| 743 return self.old_interface.GetMemoryUsageForPid(pid) | |
| 744 | |
| 728 def __str__(self): | 745 def __str__(self): |
| 729 """Returns the device serial.""" | 746 """Returns the device serial.""" |
| 730 return self.old_interface.GetDevice() | 747 return self.old_interface.GetDevice() |
| 731 | 748 |
| 732 @staticmethod | 749 @staticmethod |
| 733 def parallel(devices=None, async=False): | 750 def parallel(devices=None, async=False): |
| 734 """Creates a Parallelizer to operate over the provided list of devices. | 751 """Creates a Parallelizer to operate over the provided list of devices. |
| 735 | 752 |
| 736 If |devices| is either |None| or an empty list, the Parallelizer will | 753 If |devices| is either |None| or an empty list, the Parallelizer will |
| 737 operate over all attached devices. | 754 operate over all attached devices. |
| 738 | 755 |
| 739 Args: | 756 Args: |
| 740 devices: A list of either DeviceUtils instances or objects from | 757 devices: A list of either DeviceUtils instances or objects from |
| 741 from which DeviceUtils instances can be constructed. If None, | 758 from which DeviceUtils instances can be constructed. If None, |
| 742 all attached devices will be used. | 759 all attached devices will be used. |
| 743 async: If true, returns a Parallelizer that runs operations | 760 async: If true, returns a Parallelizer that runs operations |
| 744 asynchronously. | 761 asynchronously. |
| 745 Returns: | 762 Returns: |
| 746 A Parallelizer operating over |devices|. | 763 A Parallelizer operating over |devices|. |
| 747 """ | 764 """ |
| 748 if not devices or len(devices) == 0: | 765 if not devices or len(devices) == 0: |
| 749 devices = pylib.android_commands.GetAttachedDevices() | 766 devices = pylib.android_commands.GetAttachedDevices() |
| 750 parallelizer_type = (parallelizer.Parallelizer if async | 767 parallelizer_type = (parallelizer.Parallelizer if async |
| 751 else parallelizer.SyncParallelizer) | 768 else parallelizer.SyncParallelizer) |
| 752 return parallelizer_type([ | 769 return parallelizer_type([ |
| 753 d if isinstance(d, DeviceUtils) else DeviceUtils(d) | 770 d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
| 754 for d in devices]) | 771 for d in devices]) |
| 755 | 772 |
| OLD | NEW |