Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / backends / chrome / system_info_backend.py
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from telemetry import decorators
6 from telemetry.core import camel_case
7 from telemetry.core import system_info
8 from telemetry.core.backends.chrome import websocket_browser_connection
9
10
11 class SystemInfoBackend(object):
12   def __init__(self, devtools_port):
13     self._conn = websocket_browser_connection.WebSocketBrowserConnection(
14         devtools_port)
15
16   @decorators.Cache
17   def GetSystemInfo(self, timeout=10):
18     req = {'method': 'SystemInfo.getInfo'}
19     try:
20       res = self._conn.SyncRequest(req, timeout)
21     finally:
22       self._conn.Close()
23     if 'error' in res:
24       return None
25     return system_info.SystemInfo.FromDict(
26         camel_case.ToUnderscore(res['result']))