OLD | NEW |
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 Loading... |
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 sessionId[] = "sessionId"; |
76 static const char traceEventCategoryFilter[] = "traceEventCategoryFilter"; | 77 static const char traceEventCategoryFilter[] = "traceEventCategoryFilter"; |
77 } | 78 } |
78 | 79 |
79 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo
del.js | 80 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo
del.js |
80 namespace TimelineRecordType { | 81 namespace TimelineRecordType { |
81 static const char Program[] = "Program"; | 82 static const char Program[] = "Program"; |
82 | 83 |
83 static const char EventDispatch[] = "EventDispatch"; | 84 static const char EventDispatch[] = "EventDispatch"; |
84 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation"; | 85 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation"; |
85 static const char RecalculateStyles[] = "RecalculateStyles"; | 86 static const char RecalculateStyles[] = "RecalculateStyles"; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 } | 335 } |
335 | 336 |
336 if (liveEvents) | 337 if (liveEvents) |
337 setLiveEvents(*liveEvents); | 338 setLiveEvents(*liveEvents); |
338 | 339 |
339 m_state->setLong(TimelineAgentState::timelineMaxCallStackDepth, m_maxCallSta
ckDepth); | 340 m_state->setLong(TimelineAgentState::timelineMaxCallStackDepth, m_maxCallSta
ckDepth); |
340 m_state->setBoolean(TimelineAgentState::includeCounters, includeCounters &&
*includeCounters); | 341 m_state->setBoolean(TimelineAgentState::includeCounters, includeCounters &&
*includeCounters); |
341 m_state->setBoolean(TimelineAgentState::includeGPUEvents, includeGPUEvents &
& *includeGPUEvents); | 342 m_state->setBoolean(TimelineAgentState::includeGPUEvents, includeGPUEvents &
& *includeGPUEvents); |
342 m_state->setBoolean(TimelineAgentState::bufferEvents, bufferEvents && *buffe
rEvents); | 343 m_state->setBoolean(TimelineAgentState::bufferEvents, bufferEvents && *buffe
rEvents); |
343 m_state->setString(TimelineAgentState::liveEvents, liveEvents ? *liveEvents
: ""); | 344 m_state->setString(TimelineAgentState::liveEvents, liveEvents ? *liveEvents
: ""); |
| 345 initializeSessionId(); |
344 | 346 |
345 innerStart(); | 347 innerStart(); |
346 bool fromConsole = false; | 348 bool fromConsole = false; |
347 m_frontend->started(&fromConsole); | 349 m_frontend->started(sessionId(), &fromConsole); |
348 } | 350 } |
349 | 351 |
350 bool InspectorTimelineAgent::isStarted() | 352 bool InspectorTimelineAgent::isStarted() |
351 { | 353 { |
352 return m_state->getBoolean(TimelineAgentState::started); | 354 return m_state->getBoolean(TimelineAgentState::started); |
353 } | 355 } |
354 | 356 |
355 void InspectorTimelineAgent::innerStart() | 357 void InspectorTimelineAgent::innerStart() |
356 { | 358 { |
357 if (m_overlay) | 359 if (m_overlay) |
358 m_overlay->startedRecordingProfile(); | 360 m_overlay->startedRecordingProfile(); |
359 m_state->setBoolean(TimelineAgentState::started, true); | 361 m_state->setBoolean(TimelineAgentState::started, true); |
360 String traceEventCategoryFilter = m_state->getString(TimelineAgentState::tra
ceEventCategoryFilter); | 362 String traceEventCategoryFilter = m_state->getString(TimelineAgentState::tra
ceEventCategoryFilter); |
361 if (!traceEventCategoryFilter.isEmpty()) { | 363 if (!traceEventCategoryFilter.isEmpty()) { |
362 m_client->enableTracing(traceEventCategoryFilter); | 364 m_client->enableTracing(traceEventCategoryFilter); |
363 m_disableTracingOnStop = true; | 365 m_disableTracingOnStop = true; |
364 } else { | 366 } else { |
365 m_disableTracingOnStop = false; | 367 m_disableTracingOnStop = false; |
366 } | 368 } |
367 m_instrumentingAgents->setInspectorTimelineAgent(this); | 369 m_instrumentingAgents->setInspectorTimelineAgent(this); |
368 ScriptGCEvent::addEventListener(this); | 370 ScriptGCEvent::addEventListener(this); |
| 371 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Timeli
neStarted", "sessionId", sessionId().utf8()); |
| 372 if (m_layerTreeId) { |
| 373 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Se
tLayerTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId); |
| 374 } |
369 if (m_client) { | 375 if (m_client) { |
370 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); | 376 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); |
371 dispatcher->addListener(InstrumentationEvents::BeginFrame, TRACE_EVENT_P
HASE_INSTANT, this, &InspectorTimelineAgent::onBeginImplSideFrame, m_client); | 377 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); | 378 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); | 379 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); | 380 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); | 381 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); | 382 dispatcher->addListener(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_
DELETE_OBJECT, this, &InspectorTimelineAgent::onLayerDeleted, m_client); |
377 dispatcher->addListener(InstrumentationEvents::RequestMainThreadFrame, T
RACE_EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onRequestMainThreadFram
e, m_client); | 383 dispatcher->addListener(InstrumentationEvents::RequestMainThreadFrame, T
RACE_EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onRequestMainThreadFram
e, m_client); |
378 dispatcher->addListener(InstrumentationEvents::ActivateLayerTree, TRACE_
EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onActivateLayerTree, m_clien
t); | 384 dispatcher->addListener(InstrumentationEvents::ActivateLayerTree, TRACE_
EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onActivateLayerTree, m_clien
t); |
(...skipping 12 matching lines...) Expand all Loading... |
391 m_client->startGPUEventsRecording(); | 397 m_client->startGPUEventsRecording(); |
392 } | 398 } |
393 } | 399 } |
394 } | 400 } |
395 | 401 |
396 void InspectorTimelineAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Array<TimelineEvent> >& events) | 402 void InspectorTimelineAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder::
Array<TimelineEvent> >& events) |
397 { | 403 { |
398 m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); | 404 m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); |
399 m_state->setBoolean(TimelineAgentState::bufferEvents, false); | 405 m_state->setBoolean(TimelineAgentState::bufferEvents, false); |
400 m_state->setString(TimelineAgentState::liveEvents, ""); | 406 m_state->setString(TimelineAgentState::liveEvents, ""); |
| 407 m_state->setString(TimelineAgentState::sessionId, ""); |
401 | 408 |
402 if (!isStarted()) { | 409 if (!isStarted()) { |
403 *errorString = "Timeline was not started"; | 410 *errorString = "Timeline was not started"; |
404 return; | 411 return; |
405 } | 412 } |
406 innerStop(false); | 413 innerStop(false); |
407 if (m_bufferedEvents) | 414 if (m_bufferedEvents) |
408 events = m_bufferedEvents.release(); | 415 events = m_bufferedEvents.release(); |
409 m_liveEvents.clear(); | 416 m_liveEvents.clear(); |
410 } | 417 } |
(...skipping 28 matching lines...) Expand all Loading... |
439 String message = String::format("Timeline '%s' terminated.", m_consoleTi
melines[i].utf8().data()); | 446 String message = String::format("Timeline '%s' terminated.", m_consoleTi
melines[i].utf8().data()); |
440 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageL
evel, message); | 447 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageL
evel, message); |
441 } | 448 } |
442 m_consoleTimelines.clear(); | 449 m_consoleTimelines.clear(); |
443 | 450 |
444 m_frontend->stopped(&fromConsole); | 451 m_frontend->stopped(&fromConsole); |
445 if (m_overlay) | 452 if (m_overlay) |
446 m_overlay->finishedRecordingProfile(); | 453 m_overlay->finishedRecordingProfile(); |
447 } | 454 } |
448 | 455 |
| 456 String InspectorTimelineAgent::sessionId() const |
| 457 { |
| 458 return m_state->getString(TimelineAgentState::sessionId); |
| 459 } |
| 460 |
| 461 void InspectorTimelineAgent::initializeSessionId() |
| 462 { |
| 463 static unsigned lastTimelineSessionId; |
| 464 String sessionId = IdentifiersFactory::createIdentifier(); |
| 465 m_state->setString(TimelineAgentState::sessionId, sessionId); |
| 466 } |
| 467 |
| 468 void InspectorTimelineAgent::setLayerTreeId(int layerTreeId) |
| 469 { |
| 470 m_layerTreeId = layerTreeId; |
| 471 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "setLay
erTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId); |
| 472 } |
| 473 |
449 void InspectorTimelineAgent::didBeginFrame(int frameId) | 474 void InspectorTimelineAgent::didBeginFrame(int frameId) |
450 { | 475 { |
451 TraceEventDispatcher::instance()->processBackgroundEvents(); | 476 TraceEventDispatcher::instance()->processBackgroundEvents(); |
452 m_pendingFrameRecord = TimelineRecordFactory::createGenericRecord(timestamp(
), 0, TimelineRecordType::BeginFrame, TimelineRecordFactory::createFrameData(fra
meId)); | 477 m_pendingFrameRecord = TimelineRecordFactory::createGenericRecord(timestamp(
), 0, TimelineRecordType::BeginFrame, TimelineRecordFactory::createFrameData(fra
meId)); |
453 } | 478 } |
454 | 479 |
455 void InspectorTimelineAgent::didCancelFrame() | 480 void InspectorTimelineAgent::didCancelFrame() |
456 { | 481 { |
457 m_pendingFrameRecord.clear(); | 482 m_pendingFrameRecord.clear(); |
458 } | 483 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 | 848 |
824 void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St
ring& title, ScriptState* state) | 849 void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St
ring& title, ScriptState* state) |
825 { | 850 { |
826 if (!m_state->getBoolean(TimelineAgentState::enabled)) | 851 if (!m_state->getBoolean(TimelineAgentState::enabled)) |
827 return; | 852 return; |
828 | 853 |
829 String message = String::format("Timeline '%s' started.", title.utf8().data(
)); | 854 String message = String::format("Timeline '%s' started.", title.utf8().data(
)); |
830 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageLevel
, message, String(), 0, 0, nullptr, state); | 855 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageLevel
, message, String(), 0, 0, nullptr, state); |
831 m_consoleTimelines.append(title); | 856 m_consoleTimelines.append(title); |
832 if (!isStarted()) { | 857 if (!isStarted()) { |
| 858 initializeSessionId(); |
833 innerStart(); | 859 innerStart(); |
834 bool fromConsole = true; | 860 bool fromConsole = true; |
835 m_frontend->started(&fromConsole); | 861 m_frontend->started(sessionId(), &fromConsole); |
836 } | 862 } |
837 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe
cordType::TimeStamp, true, frameForExecutionContext(context)); | 863 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe
cordType::TimeStamp, true, frameForExecutionContext(context)); |
838 } | 864 } |
839 | 865 |
840 void InspectorTimelineAgent::consoleTimelineEnd(ExecutionContext* context, const
String& title, ScriptState* state) | 866 void InspectorTimelineAgent::consoleTimelineEnd(ExecutionContext* context, const
String& title, ScriptState* state) |
841 { | 867 { |
842 if (!m_state->getBoolean(TimelineAgentState::enabled)) | 868 if (!m_state->getBoolean(TimelineAgentState::enabled)) |
843 return; | 869 return; |
844 | 870 |
845 size_t index = m_consoleTimelines.find(title); | 871 size_t index = m_consoleTimelines.find(title); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 | 1390 |
1365 #ifndef NDEBUG | 1391 #ifndef NDEBUG |
1366 bool TimelineRecordStack::isOpenRecordOfType(const String& type) | 1392 bool TimelineRecordStack::isOpenRecordOfType(const String& type) |
1367 { | 1393 { |
1368 return !m_stack.isEmpty() && m_stack.last().type == type; | 1394 return !m_stack.isEmpty() && m_stack.last().type == type; |
1369 } | 1395 } |
1370 #endif | 1396 #endif |
1371 | 1397 |
1372 } // namespace WebCore | 1398 } // namespace WebCore |
1373 | 1399 |
OLD | NEW |