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

Unified Diff: tools/telemetry/telemetry/core/chrome/system_info_backend.py

Issue 21682002: Expose GPU information to Telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed more unnecessary includes. Created 7 years, 4 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
Index: tools/telemetry/telemetry/core/chrome/system_info_backend.py
diff --git a/tools/telemetry/telemetry/core/chrome/system_info_backend.py b/tools/telemetry/telemetry/core/chrome/system_info_backend.py
new file mode 100644
index 0000000000000000000000000000000000000000..b8bb17716704b551e437079aa1ed970de84e8c7d
--- /dev/null
+++ b/tools/telemetry/telemetry/core/chrome/system_info_backend.py
@@ -0,0 +1,56 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import logging
+import socket
+
+
+from telemetry.core import gpu_info
+from telemetry.core.chrome import websocket
+
+
+class SystemInfoBackend(object):
+ def __init__(self, devtools_port):
+ debugger_url = 'ws://localhost:%i/devtools/browser' % devtools_port
+ self._socket = websocket.create_connection(debugger_url)
+ self._next_request_id = 0
+ self._cur_socket_timeout = 0
+ self._thread = None
+ self._tracing_data = []
+
+ def GetGPUInfo(self, timeout=10):
+ req = {'method': 'SystemInfo.getGPUInfo'}
+ self._SyncRequest(req, timeout)
+ while self._socket:
+ try:
+ data = self._socket.recv()
+ if not data:
+ break
+ res = json.loads(data)
+ if 'error' in res:
+ return None
+ logging.debug('got [%s]', data)
+ return gpu_info.GPUInfo.FromDict(res['result'])
+ except (socket.error, websocket.WebSocketException):
+ logging.warning('Timeout waiting for GPU info, unusual.')
+ return None
+
+ def Close(self):
+ if self._socket:
+ self._socket.close()
+ self._socket = None
+
+ def _SyncRequest(self, req, timeout=10):
+ self._SetTimeout(timeout)
+ req['id'] = self._next_request_id
+ self._next_request_id += 1
+ data = json.dumps(req)
+ logging.debug('will send [%s]', data)
+ self._socket.send(data)
+
+ def _SetTimeout(self, timeout):
+ if self._cur_socket_timeout != timeout:
+ self._socket.settimeout(timeout)
+ self._cur_socket_timeout = timeout

Powered by Google App Engine
This is Rietveld 408576698