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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 #include "core/page/Page.h" | 54 #include "core/page/Page.h" |
55 #include "core/rendering/RenderObject.h" | 55 #include "core/rendering/RenderObject.h" |
56 #include "core/rendering/RenderView.h" | 56 #include "core/rendering/RenderView.h" |
57 #include "core/xml/XMLHttpRequest.h" | 57 #include "core/xml/XMLHttpRequest.h" |
58 #include "platform/TraceEvent.h" | 58 #include "platform/TraceEvent.h" |
59 #include "platform/graphics/DeferredImageDecoder.h" | 59 #include "platform/graphics/DeferredImageDecoder.h" |
60 #include "platform/graphics/GraphicsLayer.h" | 60 #include "platform/graphics/GraphicsLayer.h" |
61 #include "platform/network/ResourceRequest.h" | 61 #include "platform/network/ResourceRequest.h" |
62 #include "wtf/CurrentTime.h" | 62 #include "wtf/CurrentTime.h" |
63 #include "wtf/DateMath.h" | 63 #include "wtf/DateMath.h" |
64 #include "wtf/ProcessID.h" | |
64 | 65 |
65 namespace WebCore { | 66 namespace WebCore { |
66 | 67 |
67 namespace TimelineAgentState { | 68 namespace TimelineAgentState { |
68 static const char enabled[] = "enabled"; | 69 static const char enabled[] = "enabled"; |
69 static const char started[] = "started"; | 70 static const char started[] = "started"; |
70 static const char startedFromProtocol[] = "startedFromProtocol"; | 71 static const char startedFromProtocol[] = "startedFromProtocol"; |
71 static const char timelineMaxCallStackDepth[] = "timelineMaxCallStackDepth"; | 72 static const char timelineMaxCallStackDepth[] = "timelineMaxCallStackDepth"; |
72 static const char includeCounters[] = "includeCounters"; | 73 static const char includeCounters[] = "includeCounters"; |
73 static const char includeGPUEvents[] = "includeGPUEvents"; | 74 static const char includeGPUEvents[] = "includeGPUEvents"; |
74 static const char bufferEvents[] = "bufferEvents"; | 75 static const char bufferEvents[] = "bufferEvents"; |
75 static const char liveEvents[] = "liveEvents"; | 76 static const char liveEvents[] = "liveEvents"; |
77 static const char sessionId[] = "sessionId"; | |
76 static const char traceEventCategoryFilter[] = "traceEventCategoryFilter"; | 78 static const char traceEventCategoryFilter[] = "traceEventCategoryFilter"; |
77 } | 79 } |
78 | 80 |
79 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo del.js | 81 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo del.js |
80 namespace TimelineRecordType { | 82 namespace TimelineRecordType { |
81 static const char Program[] = "Program"; | 83 static const char Program[] = "Program"; |
82 | 84 |
83 static const char EventDispatch[] = "EventDispatch"; | 85 static const char EventDispatch[] = "EventDispatch"; |
84 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation"; | 86 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation"; |
85 static const char RecalculateStyles[] = "RecalculateStyles"; | 87 static const char RecalculateStyles[] = "RecalculateStyles"; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
334 } | 336 } |
335 | 337 |
336 if (liveEvents) | 338 if (liveEvents) |
337 setLiveEvents(*liveEvents); | 339 setLiveEvents(*liveEvents); |
338 | 340 |
339 m_state->setLong(TimelineAgentState::timelineMaxCallStackDepth, m_maxCallSta ckDepth); | 341 m_state->setLong(TimelineAgentState::timelineMaxCallStackDepth, m_maxCallSta ckDepth); |
340 m_state->setBoolean(TimelineAgentState::includeCounters, includeCounters && *includeCounters); | 342 m_state->setBoolean(TimelineAgentState::includeCounters, includeCounters && *includeCounters); |
341 m_state->setBoolean(TimelineAgentState::includeGPUEvents, includeGPUEvents & & *includeGPUEvents); | 343 m_state->setBoolean(TimelineAgentState::includeGPUEvents, includeGPUEvents & & *includeGPUEvents); |
342 m_state->setBoolean(TimelineAgentState::bufferEvents, bufferEvents && *buffe rEvents); | 344 m_state->setBoolean(TimelineAgentState::bufferEvents, bufferEvents && *buffe rEvents); |
343 m_state->setString(TimelineAgentState::liveEvents, liveEvents ? *liveEvents : ""); | 345 m_state->setString(TimelineAgentState::liveEvents, liveEvents ? *liveEvents : ""); |
346 initializeSessionId(); | |
344 | 347 |
345 innerStart(); | 348 innerStart(); |
346 bool fromConsole = false; | 349 bool fromConsole = false; |
347 m_frontend->started(&fromConsole); | 350 m_frontend->started(sessionId(), &fromConsole); |
348 } | 351 } |
349 | 352 |
350 bool InspectorTimelineAgent::isStarted() | 353 bool InspectorTimelineAgent::isStarted() |
351 { | 354 { |
352 return m_state->getBoolean(TimelineAgentState::started); | 355 return m_state->getBoolean(TimelineAgentState::started); |
353 } | 356 } |
354 | 357 |
355 void InspectorTimelineAgent::innerStart() | 358 void InspectorTimelineAgent::innerStart() |
356 { | 359 { |
357 if (m_overlay) | 360 if (m_overlay) |
358 m_overlay->startedRecordingProfile(); | 361 m_overlay->startedRecordingProfile(); |
359 m_state->setBoolean(TimelineAgentState::started, true); | 362 m_state->setBoolean(TimelineAgentState::started, true); |
360 String traceEventCategoryFilter = m_state->getString(TimelineAgentState::tra ceEventCategoryFilter); | 363 String traceEventCategoryFilter = m_state->getString(TimelineAgentState::tra ceEventCategoryFilter); |
361 if (!traceEventCategoryFilter.isEmpty()) { | 364 if (!traceEventCategoryFilter.isEmpty()) { |
362 m_client->enableTracing(traceEventCategoryFilter); | 365 m_client->enableTracing(traceEventCategoryFilter); |
363 m_disableTracingOnStop = true; | 366 m_disableTracingOnStop = true; |
364 } else { | 367 } else { |
365 m_disableTracingOnStop = false; | 368 m_disableTracingOnStop = false; |
366 } | 369 } |
367 m_instrumentingAgents->setInspectorTimelineAgent(this); | 370 m_instrumentingAgents->setInspectorTimelineAgent(this); |
368 ScriptGCEvent::addEventListener(this); | 371 ScriptGCEvent::addEventListener(this); |
372 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Timeli neStarted", "sessionId", sessionId().utf8()); | |
373 if (m_layerTreeId) { | |
pfeldman
2014/04/22 17:59:50
call setLayerTreeId instead?
| |
374 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Se tLayerTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId); | |
375 } | |
369 if (m_client) { | 376 if (m_client) { |
370 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); | 377 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); |
371 dispatcher->addListener(InstrumentationEvents::BeginFrame, TRACE_EVENT_P HASE_INSTANT, this, &InspectorTimelineAgent::onBeginImplSideFrame, m_client); | 378 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); | 379 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); | 380 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); | 381 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); | 382 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); | 383 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); | 384 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); | 385 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(); | 398 m_client->startGPUEventsRecording(); |
392 } | 399 } |
393 } | 400 } |
394 } | 401 } |
395 | 402 |
396 void InspectorTimelineAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Array<TimelineEvent> >& events) | 403 void InspectorTimelineAgent::stop(ErrorString* errorString, RefPtr<TypeBuilder:: Array<TimelineEvent> >& events) |
397 { | 404 { |
398 m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); | 405 m_state->setBoolean(TimelineAgentState::startedFromProtocol, false); |
399 m_state->setBoolean(TimelineAgentState::bufferEvents, false); | 406 m_state->setBoolean(TimelineAgentState::bufferEvents, false); |
400 m_state->setString(TimelineAgentState::liveEvents, ""); | 407 m_state->setString(TimelineAgentState::liveEvents, ""); |
408 m_state->setString(TimelineAgentState::sessionId, ""); | |
401 | 409 |
402 if (!isStarted()) { | 410 if (!isStarted()) { |
403 *errorString = "Timeline was not started"; | 411 *errorString = "Timeline was not started"; |
404 return; | 412 return; |
405 } | 413 } |
406 innerStop(false); | 414 innerStop(false); |
407 if (m_bufferedEvents) | 415 if (m_bufferedEvents) |
408 events = m_bufferedEvents.release(); | 416 events = m_bufferedEvents.release(); |
409 m_liveEvents.clear(); | 417 m_liveEvents.clear(); |
410 } | 418 } |
(...skipping 28 matching lines...) Expand all Loading... | |
439 String message = String::format("Timeline '%s' terminated.", m_consoleTi melines[i].utf8().data()); | 447 String message = String::format("Timeline '%s' terminated.", m_consoleTi melines[i].utf8().data()); |
440 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageL evel, message); | 448 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageL evel, message); |
441 } | 449 } |
442 m_consoleTimelines.clear(); | 450 m_consoleTimelines.clear(); |
443 | 451 |
444 m_frontend->stopped(&fromConsole); | 452 m_frontend->stopped(&fromConsole); |
445 if (m_overlay) | 453 if (m_overlay) |
446 m_overlay->finishedRecordingProfile(); | 454 m_overlay->finishedRecordingProfile(); |
447 } | 455 } |
448 | 456 |
457 String InspectorTimelineAgent::sessionId() const | |
458 { | |
459 return m_state->getString(TimelineAgentState::sessionId); | |
460 } | |
461 | |
462 void InspectorTimelineAgent::initializeSessionId() | |
463 { | |
464 static unsigned lastTimelineSessionId; | |
465 String token = String::number(getCurrentProcessID()) + "." + String::number( ++lastTimelineSessionId); | |
yurys
2014/04/23 07:05:38
What if pid is reused after a few navigations? Gen
| |
466 m_state->setString(TimelineAgentState::sessionId, token); | |
467 } | |
468 | |
469 void InspectorTimelineAgent::setLayerTreeId(int layerTreeId) | |
470 { | |
471 m_layerTreeId = layerTreeId; | |
472 TRACE_EVENT_INSTANT2(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "setLay erTreeId", "sessionId", sessionId().utf8(), "layerTreeId", m_layerTreeId); | |
yurys
2014/04/23 07:05:38
Are we going to leave this instrumentation here af
| |
473 } | |
474 | |
449 void InspectorTimelineAgent::didBeginFrame(int frameId) | 475 void InspectorTimelineAgent::didBeginFrame(int frameId) |
450 { | 476 { |
451 TraceEventDispatcher::instance()->processBackgroundEvents(); | 477 TraceEventDispatcher::instance()->processBackgroundEvents(); |
452 m_pendingFrameRecord = TimelineRecordFactory::createGenericRecord(timestamp( ), 0, TimelineRecordType::BeginFrame, TimelineRecordFactory::createFrameData(fra meId)); | 478 m_pendingFrameRecord = TimelineRecordFactory::createGenericRecord(timestamp( ), 0, TimelineRecordType::BeginFrame, TimelineRecordFactory::createFrameData(fra meId)); |
453 } | 479 } |
454 | 480 |
455 void InspectorTimelineAgent::didCancelFrame() | 481 void InspectorTimelineAgent::didCancelFrame() |
456 { | 482 { |
457 m_pendingFrameRecord.clear(); | 483 m_pendingFrameRecord.clear(); |
458 } | 484 } |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 | 849 |
824 void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St ring& title, ScriptState* state) | 850 void InspectorTimelineAgent::consoleTimeline(ExecutionContext* context, const St ring& title, ScriptState* state) |
825 { | 851 { |
826 if (!m_state->getBoolean(TimelineAgentState::enabled)) | 852 if (!m_state->getBoolean(TimelineAgentState::enabled)) |
827 return; | 853 return; |
828 | 854 |
829 String message = String::format("Timeline '%s' started.", title.utf8().data( )); | 855 String message = String::format("Timeline '%s' started.", title.utf8().data( )); |
830 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageLevel , message, String(), 0, 0, nullptr, state); | 856 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageLevel , message, String(), 0, 0, nullptr, state); |
831 m_consoleTimelines.append(title); | 857 m_consoleTimelines.append(title); |
832 if (!isStarted()) { | 858 if (!isStarted()) { |
859 initializeSessionId(); | |
833 innerStart(); | 860 innerStart(); |
834 bool fromConsole = true; | 861 bool fromConsole = true; |
835 m_frontend->started(&fromConsole); | 862 m_frontend->started(sessionId(), &fromConsole); |
836 } | 863 } |
837 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe cordType::TimeStamp, true, frameForExecutionContext(context)); | 864 appendRecord(TimelineRecordFactory::createTimeStampData(message), TimelineRe cordType::TimeStamp, true, frameForExecutionContext(context)); |
838 } | 865 } |
839 | 866 |
840 void InspectorTimelineAgent::consoleTimelineEnd(ExecutionContext* context, const String& title, ScriptState* state) | 867 void InspectorTimelineAgent::consoleTimelineEnd(ExecutionContext* context, const String& title, ScriptState* state) |
841 { | 868 { |
842 if (!m_state->getBoolean(TimelineAgentState::enabled)) | 869 if (!m_state->getBoolean(TimelineAgentState::enabled)) |
843 return; | 870 return; |
844 | 871 |
845 size_t index = m_consoleTimelines.find(title); | 872 size_t index = m_consoleTimelines.find(title); |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1364 | 1391 |
1365 #ifndef NDEBUG | 1392 #ifndef NDEBUG |
1366 bool TimelineRecordStack::isOpenRecordOfType(const String& type) | 1393 bool TimelineRecordStack::isOpenRecordOfType(const String& type) |
1367 { | 1394 { |
1368 return !m_stack.isEmpty() && m_stack.last().type == type; | 1395 return !m_stack.isEmpty() && m_stack.last().type == type; |
1369 } | 1396 } |
1370 #endif | 1397 #endif |
1371 | 1398 |
1372 } // namespace WebCore | 1399 } // namespace WebCore |
1373 | 1400 |
OLD | NEW |