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

Side by Side Diff: telemetry/telemetry/internal/platform/tracing_agent/chrome_tracing_agent.py

Issue 1827323003: [Telemetry] Clear tracing state before browser start (Closed) Base URL: git@github.com:catapult-project/catapult@master
Patch Set: fix test Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import atexit 5 import atexit
6 import logging 6 import logging
7 import os 7 import os
8 import shutil 8 import shutil
9 import stat 9 import stat
10 import sys 10 import sys
11 import tempfile 11 import tempfile
12 import traceback 12 import traceback
13 13
14 from telemetry.internal.platform import tracing_agent 14 from telemetry.internal.platform import tracing_agent
15 from telemetry.internal.platform.tracing_agent import ( 15 from telemetry.internal.platform.tracing_agent import (
16 chrome_tracing_devtools_manager) 16 chrome_tracing_devtools_manager)
17 17
18 _DESKTOP_OS_NAMES = ['linux', 'mac', 'win'] 18 _DESKTOP_OS_NAMES = ['linux', 'mac', 'win']
19 _STARTUP_TRACING_OS_NAMES = _DESKTOP_OS_NAMES + ['android'] 19 _STARTUP_TRACING_OS_NAMES = _DESKTOP_OS_NAMES + ['android']
20 20
21 # The trace config file path should be the same as specified in 21 # The trace config file path should be the same as specified in
22 # src/components/tracing/trace_config_file.[h|cc] 22 # src/components/tracing/trace_config_file.[h|cc]
23 _CHROME_TRACE_CONFIG_DIR_ANDROID = '/data/local/' 23 _CHROME_TRACE_CONFIG_DIR_ANDROID = '/data/local/'
24 _CHROME_TRACE_CONFIG_FILE_NAME = 'chrome-trace-config.json' 24 _CHROME_TRACE_CONFIG_FILE_NAME = 'chrome-trace-config.json'
25 25
26 26
27 def ClearStarupTracingStateIfNeeded(platform_backend):
28 # Trace config file has fixed path on Android and temporary path on desktop.
29 if platform_backend.GetOSName() == 'android':
30 trace_config_file = os.path.join(_CHROME_TRACE_CONFIG_DIR_ANDROID,
31 _CHROME_TRACE_CONFIG_FILE_NAME)
32 platform_backend.device.RunShellCommand(
33 ['rm', '-f', trace_config_file], check_return=True, as_root=True)
34
35
27 class ChromeTracingStartedError(Exception): 36 class ChromeTracingStartedError(Exception):
28 pass 37 pass
29 38
30 39
31 class ChromeTracingStoppedError(Exception): 40 class ChromeTracingStoppedError(Exception):
32 pass 41 pass
33 42
34 43
35 class ChromeTracingAgent(tracing_agent.TracingAgent): 44 class ChromeTracingAgent(tracing_agent.TracingAgent):
36 def __init__(self, platform_backend): 45 def __init__(self, platform_backend):
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 for backend in self._IterInspectorBackends(): 212 for backend in self._IterInspectorBackends():
204 backend.EvaluateJavaScript("console.timeEnd('flush-tracing');") 213 backend.EvaluateJavaScript("console.timeEnd('flush-tracing');")
205 214
206 def _IterInspectorBackends(self): 215 def _IterInspectorBackends(self):
207 for client in chrome_tracing_devtools_manager.GetDevToolsClients( 216 for client in chrome_tracing_devtools_manager.GetDevToolsClients(
208 self._platform_backend): 217 self._platform_backend):
209 context_map = client.GetUpdatedInspectableContexts() 218 context_map = client.GetUpdatedInspectableContexts()
210 for context in context_map.contexts: 219 for context in context_map.contexts:
211 if context['type'] in ['iframe', 'page', 'webview']: 220 if context['type'] in ['iframe', 'page', 'webview']:
212 yield context_map.GetInspectorBackend(context['id']) 221 yield context_map.GetInspectorBackend(context['id'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698