 Chromium Code Reviews
 Chromium Code Reviews Issue 3013243002:
  Refactor websocket connections logic with devtool Storage domain to a separate class  (Closed)
    
  
    Issue 3013243002:
  Refactor websocket connections logic with devtool Storage domain to a separate class  (Closed) 
  | Index: telemetry/telemetry/internal/backends/chrome_inspector/inspector_storage.py | 
| diff --git a/telemetry/telemetry/internal/backends/chrome_inspector/inspector_storage.py b/telemetry/telemetry/internal/backends/chrome_inspector/inspector_storage.py | 
| new file mode 100644 | 
| index 0000000000000000000000000000000000000000..ab369175bcb77c4cdee850dcbd59d5202d87c50b | 
| --- /dev/null | 
| +++ b/telemetry/telemetry/internal/backends/chrome_inspector/inspector_storage.py | 
| @@ -0,0 +1,26 @@ | 
| +# Copyright 2017 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. | 
| + | 
| +from telemetry.core import exceptions | 
| + | 
| + | 
| +class InspectorStorage(object): | 
| + def __init__(self, inspector_websocket): | 
| + self._websocket = inspector_websocket | 
| + self._websocket.RegisterDomain('Storage', self._OnNotification) | 
| + | 
| + def _OnNotification(self, msg): | 
| + # TODO: track storage events | 
| + # (https://chromedevtools.github.io/devtools-protocol/tot/Storage/) | 
| + pass | 
| + | 
| + def ClearDataForOrigin(self, url, timeout): | 
| + res = self._websocket.SyncRequest( | 
| + {'method': 'Storage.clearDataForOrigin', | 
| + 'params': { | 
| + 'origin': url, | 
| + 'storageTypes': 'all', | 
| + }}, timeout) | 
| + if 'error' in res: | 
| 
perezju
2017/09/22 12:59:19
for a follow up, but maybe something like this sho
 
nednguyen
2017/09/22 13:02:40
Yeah, I was thinking the same too.
 | 
| + raise exceptions.StoryActionError(res['error']['message']) |