Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: tools/telemetry/telemetry/core/platform/win_platform_backend.py

Issue 394923003: [telemetry] Add IPPET power monitor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Increase timeout again to 20s. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor_unittest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/platform/win_platform_backend.py
diff --git a/tools/telemetry/telemetry/core/platform/win_platform_backend.py b/tools/telemetry/telemetry/core/platform/win_platform_backend.py
index 4597c40c7c6e84918b1ee20310b09a2d963d6e6c..5f723646bc5c85d9d56ed1f0ad2c24c6d0e0ed93 100644
--- a/tools/telemetry/telemetry/core/platform/win_platform_backend.py
+++ b/tools/telemetry/telemetry/core/platform/win_platform_backend.py
@@ -11,10 +11,14 @@ import time
try:
import pywintypes # pylint: disable=F0401
import win32api # pylint: disable=F0401
+ from win32com.shell import shell # pylint: disable=F0401
+ from win32com.shell import shellcon # pylint: disable=F0401
import win32con # pylint: disable=F0401
import win32process # pylint: disable=F0401
except ImportError:
pywintypes = None
+ shell = None
+ shellcon = None
win32api = None
win32con = None
win32process = None
@@ -23,9 +27,14 @@ from telemetry import decorators
from telemetry.core import exceptions
from telemetry.core.platform import desktop_platform_backend
from telemetry.core.platform import platform_backend
+from telemetry.core.platform.power_monitor import ippet_power_monitor
class WinPlatformBackend(desktop_platform_backend.DesktopPlatformBackend):
+ def __init__(self):
+ super(WinPlatformBackend, self).__init__()
+ self._power_monitor = ippet_power_monitor.IppetPowerMonitor(self)
+
# pylint: disable=W0613
def StartRawDisplayFrameRateMeasurement(self):
raise NotImplementedError()
@@ -201,3 +210,32 @@ class WinPlatformBackend(desktop_platform_backend.DesktopPlatformBackend):
ctypes.windll.psapi.GetPerformanceInfo(
ctypes.byref(performance_info), performance_info.size)
return performance_info
+
+ def LaunchApplication(
+ self, application, parameters=None, elevate_privilege=False):
+ """Launch an application. Returns a PyHANDLE object."""
+
+ # Use ShellExecuteEx() instead of subprocess.Popen()/OpenProcess() to
+ # elevate privileges. A new console will be created if the new process has
+ # different permissions than this process.
+ proc_info = shell.ShellExecuteEx(
+ fMask=shellcon.SEE_MASK_NOCLOSEPROCESS | shellcon.SEE_MASK_NO_CONSOLE,
+ lpVerb='runas' if elevate_privilege else '',
+ lpFile=application,
+ lpParameters=' '.join(parameters) if parameters else '',
+ nShow=win32con.SW_HIDE)
+ if proc_info['hInstApp'] <= 32:
+ raise Exception('Unable to launch %s' % application)
+ return proc_info['hProcess']
+
+ def CanMonitorPower(self):
+ return self._power_monitor.CanMonitorPower()
+
+ def CanMeasurePerApplicationPower(self):
+ return self._power_monitor.CanMeasurePerApplicationPower()
+
+ def StartMonitoringPower(self, browser):
+ self._power_monitor.StartMonitoringPower(browser)
+
+ def StopMonitoringPower(self):
+ return self._power_monitor.StopMonitoringPower()
« no previous file with comments | « tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor_unittest.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698