summaryrefslogtreecommitdiffstats
path: root/tools/telemetry
diff options
context:
space:
mode:
authorsatyanarayana@google.com <satyanarayana@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 00:26:56 +0000
committersatyanarayana@google.com <satyanarayana@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-10 00:26:56 +0000
commit8ef3379fcd05cade43ee152d88ed28722b530502 (patch)
tree98d30b2a8611cf1cb820df27775a27dc7abbe741 /tools/telemetry
parentbb2966ae6cf55223e1ccab3adee210549c4d628f (diff)
downloadchromium_src-8ef3379fcd05cade43ee152d88ed28722b530502.zip
chromium_src-8ef3379fcd05cade43ee152d88ed28722b530502.tar.gz
chromium_src-8ef3379fcd05cade43ee152d88ed28722b530502.tar.bz2
Change ownership of video file
Review URL: https://codereview.chromium.org/379443002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282189 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/telemetry')
-rw-r--r--tools/telemetry/telemetry/core/platform/android_platform_backend.py9
-rw-r--r--tools/telemetry/telemetry/core/tab_unittest.py3
-rw-r--r--tools/telemetry/telemetry/core/video.py11
3 files changed, 12 insertions, 11 deletions
diff --git a/tools/telemetry/telemetry/core/platform/android_platform_backend.py b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
index 43f8c33e..01b2930 100644
--- a/tools/telemetry/telemetry/core/platform/android_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/android_platform_backend.py
@@ -58,7 +58,6 @@ class AndroidPlatformBackend(
self._powermonitor = android_temperature_monitor.AndroidTemperatureMonitor(
power_controller, device)
self._video_recorder = None
- self._video_output = None
if self._no_performance_mode:
logging.warning('CPU governor will not be set!')
@@ -225,11 +224,10 @@ class AndroidPlatformBackend(
if min_bitrate_mbps > 100:
raise ValueError('Android video capture cannot capture at %dmbps. '
'Max capture rate is 100mbps.' % min_bitrate_mbps)
- self._video_output = tempfile.mkstemp()[1]
if self.is_video_capture_running:
self._video_recorder.Stop()
self._video_recorder = screenshot.VideoRecorder(
- self._device, self._video_output, megabits_per_second=min_bitrate_mbps)
+ self._device, megabits_per_second=min_bitrate_mbps)
self._video_recorder.Start()
util.WaitFor(self._video_recorder.IsStarted, 5)
@@ -240,10 +238,11 @@ class AndroidPlatformBackend(
def StopVideoCapture(self):
assert self.is_video_capture_running, 'Must start video capture first'
self._video_recorder.Stop()
- self._video_recorder.Pull()
+ video_file_obj = tempfile.NamedTemporaryFile()
+ self._video_recorder.Pull(video_file_obj.name)
self._video_recorder = None
- return video.Video(self._video_output)
+ return video.Video(video_file_obj)
def CanMonitorPower(self):
return self._powermonitor.CanMonitorPower()
diff --git a/tools/telemetry/telemetry/core/tab_unittest.py b/tools/telemetry/telemetry/core/tab_unittest.py
index 53db433..7a575b7 100644
--- a/tools/telemetry/telemetry/core/tab_unittest.py
+++ b/tools/telemetry/telemetry/core/tab_unittest.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
import logging
+import tempfile
from telemetry import benchmark
from telemetry.core import bitmap
@@ -28,7 +29,7 @@ class FakePlatform(object):
def StopVideoCapture(self):
self._is_video_capture_running = False
- return video.Video(None)
+ return video.Video(tempfile.NamedTemporaryFile())
def SetFullPerformanceModeEnabled(self, enabled):
pass
diff --git a/tools/telemetry/telemetry/core/video.py b/tools/telemetry/telemetry/core/video.py
index f470437..0ec7974 100644
--- a/tools/telemetry/telemetry/core/video.py
+++ b/tools/telemetry/telemetry/core/video.py
@@ -17,9 +17,10 @@ class BoundingBoxNotFoundException(Exception):
class Video(object):
"""Utilities for storing and interacting with the video capture."""
- def __init__(self, video_file_path):
- # TODO(satyanarayana): Figure out when to delete this file.
- self._video_file_path = video_file_path
+ def __init__(self, video_file_obj):
+ assert video_file_obj.delete
+ assert not video_file_obj.close_called
+ self._video_file_obj = video_file_obj
self._tab_contents_bounding_box = None
def UploadToCloudStorage(self, bucket, target_path):
@@ -28,7 +29,7 @@ class Video(object):
Args:
target_path: Path indicating where to store the file in cloud storage.
"""
- cloud_storage.Insert(bucket, target_path, self._video_file_path)
+ cloud_storage.Insert(bucket, target_path, self._video_file_obj.name)
def GetVideoFrameIter(self):
"""Returns the iteration for processing the video capture.
@@ -42,7 +43,7 @@ class Video(object):
time_ms is milliseconds since navigationStart.
bitmap is a telemetry.core.Bitmap.
"""
- frame_generator = self._FramesFromMp4(self._video_file_path)
+ frame_generator = self._FramesFromMp4(self._video_file_obj.name)
# Flip through frames until we find the initial tab contents flash.
content_box = None