| Index: tools/telemetry/telemetry/core/platform/profiler/java_heap_profiler.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/profiler/java_heap_profiler.py b/tools/telemetry/telemetry/core/platform/profiler/java_heap_profiler.py
|
| index fc78127cd81df6bd351c70c2c78d5c40c9ed8b1b..3fd7ab7a881b74ffb2d42f4df4579177ab7dff2f 100644
|
| --- a/tools/telemetry/telemetry/core/platform/profiler/java_heap_profiler.py
|
| +++ b/tools/telemetry/telemetry/core/platform/profiler/java_heap_profiler.py
|
| @@ -2,6 +2,7 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| +import logging
|
| import os
|
| import subprocess
|
| import threading
|
| @@ -48,9 +49,13 @@
|
| def CollectProfile(self):
|
| self._timer.cancel()
|
| self._DumpJavaHeap(True)
|
| - self._browser_backend.device.PullFile(
|
| - self._DEFAULT_DEVICE_DIR, self._output_path)
|
| - self._browser_backend.device.RunShellCommand(
|
| + try:
|
| + self._browser_backend.adb.device().PullFile(
|
| + self._DEFAULT_DEVICE_DIR, self._output_path)
|
| + except:
|
| + logging.exception('New exception caused by DeviceUtils conversion')
|
| + raise
|
| + self._browser_backend.adb.RunShellCommand(
|
| 'rm ' + os.path.join(self._DEFAULT_DEVICE_DIR, '*'))
|
| output_files = []
|
| for f in os.listdir(self._output_path):
|
| @@ -67,25 +72,25 @@
|
| self._DumpJavaHeap(False)
|
|
|
| def _DumpJavaHeap(self, wait_for_completion):
|
| - if not self._browser_backend.device.FileExists(
|
| + if not self._browser_backend.adb.device().FileExists(
|
| self._DEFAULT_DEVICE_DIR):
|
| - self._browser_backend.device.RunShellCommand(
|
| + self._browser_backend.adb.RunShellCommand(
|
| 'mkdir -p ' + self._DEFAULT_DEVICE_DIR)
|
| - self._browser_backend.device.RunShellCommand(
|
| + self._browser_backend.adb.RunShellCommand(
|
| 'chmod 777 ' + self._DEFAULT_DEVICE_DIR)
|
|
|
| device_dump_file = None
|
| for pid in self._GetProcessOutputFileMap().iterkeys():
|
| device_dump_file = '%s/%s.%s.aprof' % (self._DEFAULT_DEVICE_DIR, pid,
|
| self._run_count)
|
| - self._browser_backend.device.RunShellCommand(
|
| - 'am dumpheap %s %s' % (pid, device_dump_file))
|
| + self._browser_backend.adb.RunShellCommand('am dumpheap %s %s' %
|
| + (pid, device_dump_file))
|
| if device_dump_file and wait_for_completion:
|
| util.WaitFor(lambda: self._FileSize(device_dump_file) > 0, timeout=2)
|
| self._run_count += 1
|
|
|
| def _FileSize(self, file_name):
|
| try:
|
| - return self._browser_backend.device.Stat(file_name).st_size
|
| + return self._browser_backend.adb.device().Stat(file_name).st_size
|
| except device_errors.CommandFailedError:
|
| return 0
|
|
|