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

Side by Side Diff: Source/core/inspector/InspectorTimelineAgent.cpp

Issue 254613002: DevTools: add Tracing agent on back-end (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: removed a stray call to TracingAgent.enable() Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 namespace TimelineAgentState { 67 namespace TimelineAgentState {
68 static const char enabled[] = "enabled"; 68 static const char enabled[] = "enabled";
69 static const char started[] = "started"; 69 static const char started[] = "started";
70 static const char startedFromProtocol[] = "startedFromProtocol"; 70 static const char startedFromProtocol[] = "startedFromProtocol";
71 static const char timelineMaxCallStackDepth[] = "timelineMaxCallStackDepth"; 71 static const char timelineMaxCallStackDepth[] = "timelineMaxCallStackDepth";
72 static const char includeCounters[] = "includeCounters"; 72 static const char includeCounters[] = "includeCounters";
73 static const char includeGPUEvents[] = "includeGPUEvents"; 73 static const char includeGPUEvents[] = "includeGPUEvents";
74 static const char bufferEvents[] = "bufferEvents"; 74 static const char bufferEvents[] = "bufferEvents";
75 static const char liveEvents[] = "liveEvents"; 75 static const char liveEvents[] = "liveEvents";
76 static const char traceEventCategoryFilter[] = "traceEventCategoryFilter";
77 } 76 }
78 77
79 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo del.js 78 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo del.js
80 namespace TimelineRecordType { 79 namespace TimelineRecordType {
81 static const char Program[] = "Program"; 80 static const char Program[] = "Program";
82 81
83 static const char EventDispatch[] = "EventDispatch"; 82 static const char EventDispatch[] = "EventDispatch";
84 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation"; 83 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation";
85 static const char RecalculateStyles[] = "RecalculateStyles"; 84 static const char RecalculateStyles[] = "RecalculateStyles";
86 static const char InvalidateLayout[] = "InvalidateLayout"; 85 static const char InvalidateLayout[] = "InvalidateLayout";
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 innerStart(); 292 innerStart();
294 } else if (isStarted()) { 293 } else if (isStarted()) {
295 // Timeline was started from console.timeline, it is not restored. 294 // Timeline was started from console.timeline, it is not restored.
296 // Tell front-end timline is no longer collecting. 295 // Tell front-end timline is no longer collecting.
297 m_state->setBoolean(TimelineAgentState::started, false); 296 m_state->setBoolean(TimelineAgentState::started, false);
298 bool fromConsole = true; 297 bool fromConsole = true;
299 m_frontend->stopped(&fromConsole); 298 m_frontend->stopped(&fromConsole);
300 } 299 }
301 } 300 }
302 301
303 void InspectorTimelineAgent::enable(ErrorString*, const String* traceEventCatego ryFilter) 302 void InspectorTimelineAgent::enable(ErrorString*)
304 { 303 {
305 m_state->setBoolean(TimelineAgentState::enabled, true); 304 m_state->setBoolean(TimelineAgentState::enabled, true);
306 m_state->setString(TimelineAgentState::traceEventCategoryFilter, traceEventC ategoryFilter ? *traceEventCategoryFilter : "");
307 } 305 }
308 306
309 void InspectorTimelineAgent::disable(ErrorString*) 307 void InspectorTimelineAgent::disable(ErrorString*)
310 { 308 {
311 m_state->setBoolean(TimelineAgentState::enabled, false); 309 m_state->setBoolean(TimelineAgentState::enabled, false);
312 } 310 }
313 311
314 void InspectorTimelineAgent::start(ErrorString* errorString, const int* maxCallS tackDepth, const bool* bufferEvents, const String* liveEvents, const bool* inclu deCounters, const bool* includeGPUEvents) 312 void InspectorTimelineAgent::start(ErrorString* errorString, const int* maxCallS tackDepth, const bool* bufferEvents, const String* liveEvents, const bool* inclu deCounters, const bool* includeGPUEvents)
315 { 313 {
316 if (!m_frontend) 314 if (!m_frontend)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 bool InspectorTimelineAgent::isStarted() 348 bool InspectorTimelineAgent::isStarted()
351 { 349 {
352 return m_state->getBoolean(TimelineAgentState::started); 350 return m_state->getBoolean(TimelineAgentState::started);
353 } 351 }
354 352
355 void InspectorTimelineAgent::innerStart() 353 void InspectorTimelineAgent::innerStart()
356 { 354 {
357 if (m_overlay) 355 if (m_overlay)
358 m_overlay->startedRecordingProfile(); 356 m_overlay->startedRecordingProfile();
359 m_state->setBoolean(TimelineAgentState::started, true); 357 m_state->setBoolean(TimelineAgentState::started, true);
360 String traceEventCategoryFilter = m_state->getString(TimelineAgentState::tra ceEventCategoryFilter);
361 if (!traceEventCategoryFilter.isEmpty()) {
362 m_client->enableTracing(traceEventCategoryFilter);
363 m_disableTracingOnStop = true;
364 } else {
365 m_disableTracingOnStop = false;
366 }
367 m_instrumentingAgents->setInspectorTimelineAgent(this); 358 m_instrumentingAgents->setInspectorTimelineAgent(this);
368 ScriptGCEvent::addEventListener(this); 359 ScriptGCEvent::addEventListener(this);
369 if (m_client) { 360 if (m_client) {
370 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); 361 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance();
371 dispatcher->addListener(InstrumentationEvents::BeginFrame, TRACE_EVENT_P HASE_INSTANT, this, &InspectorTimelineAgent::onBeginImplSideFrame, m_client); 362 dispatcher->addListener(InstrumentationEvents::BeginFrame, TRACE_EVENT_P HASE_INSTANT, this, &InspectorTimelineAgent::onBeginImplSideFrame, m_client);
372 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onPaintSetupBegin, m_client); 363 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onPaintSetupBegin, m_client);
373 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onPaintSetupEnd, m_client); 364 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onPaintSetupEnd, m_client);
374 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onRasterTaskBegin, m_client); 365 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onRasterTaskBegin, m_client);
375 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onRasterTaskEnd, m_client); 366 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onRasterTaskEnd, m_client);
376 dispatcher->addListener(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_ DELETE_OBJECT, this, &InspectorTimelineAgent::onLayerDeleted, m_client); 367 dispatcher->addListener(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_ DELETE_OBJECT, this, &InspectorTimelineAgent::onLayerDeleted, m_client);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 402
412 void InspectorTimelineAgent::innerStop(bool fromConsole) 403 void InspectorTimelineAgent::innerStop(bool fromConsole)
413 { 404 {
414 m_state->setBoolean(TimelineAgentState::started, false); 405 m_state->setBoolean(TimelineAgentState::started, false);
415 406
416 if (m_client) { 407 if (m_client) {
417 TraceEventDispatcher::instance()->removeAllListeners(this, m_client); 408 TraceEventDispatcher::instance()->removeAllListeners(this, m_client);
418 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) 409 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents))
419 m_client->stopGPUEventsRecording(); 410 m_client->stopGPUEventsRecording();
420 } 411 }
421 // If we have enabled tracing, disable it now.
422 if (m_disableTracingOnStop) {
423 m_client->disableTracing();
424 m_disableTracingOnStop = false;
425 }
426 m_instrumentingAgents->setInspectorTimelineAgent(0); 412 m_instrumentingAgents->setInspectorTimelineAgent(0);
427 ScriptGCEvent::removeEventListener(this); 413 ScriptGCEvent::removeEventListener(this);
428 414
429 clearRecordStack(); 415 clearRecordStack();
430 m_threadStates.clear(); 416 m_threadStates.clear();
431 m_gpuTask.clear(); 417 m_gpuTask.clear();
432 m_layerToNodeMap.clear(); 418 m_layerToNodeMap.clear();
433 m_pixelRefToImageInfo.clear(); 419 m_pixelRefToImageInfo.clear();
434 m_imageBeingPainted = 0; 420 m_imageBeingPainted = 0;
435 m_paintSetupStart = 0; 421 m_paintSetupStart = 0;
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 , m_inspectorType(type) 1193 , m_inspectorType(type)
1208 , m_id(1) 1194 , m_id(1)
1209 , m_layerTreeId(0) 1195 , m_layerTreeId(0)
1210 , m_maxCallStackDepth(5) 1196 , m_maxCallStackDepth(5)
1211 , m_platformInstrumentationClientInstalledAtStackDepth(0) 1197 , m_platformInstrumentationClientInstalledAtStackDepth(0)
1212 , m_imageBeingPainted(0) 1198 , m_imageBeingPainted(0)
1213 , m_paintSetupStart(0) 1199 , m_paintSetupStart(0)
1214 , m_styleRecalcElementCounter(0) 1200 , m_styleRecalcElementCounter(0)
1215 , m_mayEmitFirstPaint(false) 1201 , m_mayEmitFirstPaint(false)
1216 , m_lastProgressTimestamp(0) 1202 , m_lastProgressTimestamp(0)
1217 , m_disableTracingOnStop(false)
1218 { 1203 {
1219 } 1204 }
1220 1205
1221 void InspectorTimelineAgent::appendRecord(PassRefPtr<JSONObject> data, const Str ing& type, bool captureCallStack, LocalFrame* frame) 1206 void InspectorTimelineAgent::appendRecord(PassRefPtr<JSONObject> data, const Str ing& type, bool captureCallStack, LocalFrame* frame)
1222 { 1207 {
1223 double ts = timestamp(); 1208 double ts = timestamp();
1224 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(ts , captureCallStack ? m_maxCallStackDepth : 0, type, data); 1209 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(ts , captureCallStack ? m_maxCallStackDepth : 0, type, data);
1225 setFrameIdentifier(record.get(), frame); 1210 setFrameIdentifier(record.get(), frame);
1226 addRecordToTimeline(record.release(), ts); 1211 addRecordToTimeline(record.release(), ts);
1227 } 1212 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1364 1349
1365 #ifndef NDEBUG 1350 #ifndef NDEBUG
1366 bool TimelineRecordStack::isOpenRecordOfType(const String& type) 1351 bool TimelineRecordStack::isOpenRecordOfType(const String& type)
1367 { 1352 {
1368 return !m_stack.isEmpty() && m_stack.last().type == type; 1353 return !m_stack.isEmpty() && m_stack.last().type == type;
1369 } 1354 }
1370 #endif 1355 #endif
1371 1356
1372 } // namespace WebCore 1357 } // namespace WebCore
1373 1358
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorTimelineAgent.h ('k') | Source/core/inspector/InspectorTracingAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698