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

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

Issue 59793003: Emit CommitFrame and BeginFrame for impl-side frames (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased on top of TraceEventDispatcher refactoring Created 7 years 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 static const char includeDomCounters[] = "includeDomCounters"; 70 static const char includeDomCounters[] = "includeDomCounters";
71 static const char includeGPUEvents[] = "includeGPUEvents"; 71 static const char includeGPUEvents[] = "includeGPUEvents";
72 static const char bufferEvents[] = "bufferEvents"; 72 static const char bufferEvents[] = "bufferEvents";
73 } 73 }
74 74
75 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo del.js 75 // Must be kept in sync with WebInspector.TimelineModel.RecordType in TimelineMo del.js
76 namespace TimelineRecordType { 76 namespace TimelineRecordType {
77 static const char Program[] = "Program"; 77 static const char Program[] = "Program";
78 78
79 static const char EventDispatch[] = "EventDispatch"; 79 static const char EventDispatch[] = "EventDispatch";
80 static const char BeginFrame[] = "BeginFrame";
81 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation"; 80 static const char ScheduleStyleRecalculation[] = "ScheduleStyleRecalculation";
82 static const char RecalculateStyles[] = "RecalculateStyles"; 81 static const char RecalculateStyles[] = "RecalculateStyles";
83 static const char InvalidateLayout[] = "InvalidateLayout"; 82 static const char InvalidateLayout[] = "InvalidateLayout";
84 static const char Layout[] = "Layout"; 83 static const char Layout[] = "Layout";
85 static const char AutosizeText[] = "AutosizeText"; 84 static const char AutosizeText[] = "AutosizeText";
86 static const char Paint[] = "Paint"; 85 static const char Paint[] = "Paint";
87 static const char ScrollLayer[] = "ScrollLayer"; 86 static const char ScrollLayer[] = "ScrollLayer";
88 static const char ResizeImage[] = "ResizeImage"; 87 static const char ResizeImage[] = "ResizeImage";
89 static const char CompositeLayers[] = "CompositeLayers"; 88 static const char CompositeLayers[] = "CompositeLayers";
90 89
(...skipping 27 matching lines...) Expand all
118 static const char RequestAnimationFrame[] = "RequestAnimationFrame"; 117 static const char RequestAnimationFrame[] = "RequestAnimationFrame";
119 static const char CancelAnimationFrame[] = "CancelAnimationFrame"; 118 static const char CancelAnimationFrame[] = "CancelAnimationFrame";
120 static const char FireAnimationFrame[] = "FireAnimationFrame"; 119 static const char FireAnimationFrame[] = "FireAnimationFrame";
121 120
122 static const char WebSocketCreate[] = "WebSocketCreate"; 121 static const char WebSocketCreate[] = "WebSocketCreate";
123 static const char WebSocketSendHandshakeRequest[] = "WebSocketSendHandshakeReque st"; 122 static const char WebSocketSendHandshakeRequest[] = "WebSocketSendHandshakeReque st";
124 static const char WebSocketReceiveHandshakeResponse[] = "WebSocketReceiveHandsha keResponse"; 123 static const char WebSocketReceiveHandshakeResponse[] = "WebSocketReceiveHandsha keResponse";
125 static const char WebSocketDestroy[] = "WebSocketDestroy"; 124 static const char WebSocketDestroy[] = "WebSocketDestroy";
126 125
127 // Event names visible to other modules. 126 // Event names visible to other modules.
127 const char ActivateLayerTree[] = "ActivateLayerTree";
128 const char BeginFrame[] = "BeginFrame";
128 const char DecodeImage[] = "DecodeImage"; 129 const char DecodeImage[] = "DecodeImage";
130 const char GPUTask[] = "GPUTask";
129 const char Rasterize[] = "Rasterize"; 131 const char Rasterize[] = "Rasterize";
130 const char PaintSetup[] = "PaintSetup"; 132 const char PaintSetup[] = "PaintSetup";
131 const char GPUTask[] = "GPUTask";
132 } 133 }
133 134
134 namespace { 135 namespace {
135 const char BackendNodeIdGroup[] = "timeline"; 136 const char BackendNodeIdGroup[] = "timeline";
136 } 137 }
137 138
138 struct TimelineRecordEntry { 139 struct TimelineRecordEntry {
139 TimelineRecordEntry(PassRefPtr<JSONObject> record, PassRefPtr<JSONObject> da ta, PassRefPtr<JSONArray> children, const String& type, size_t usedHeapSizeAtSta rt) 140 TimelineRecordEntry(PassRefPtr<JSONObject> record, PassRefPtr<JSONObject> da ta, PassRefPtr<JSONArray> children, const String& type, size_t usedHeapSizeAtSta rt)
140 : record(record), data(data), children(children), type(type), usedHeapSi zeAtStart(usedHeapSizeAtStart) 141 : record(record), data(data), children(children), type(type), usedHeapSi zeAtStart(usedHeapSizeAtStart)
141 { 142 {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 void InspectorTimelineAgent::innerStart() 344 void InspectorTimelineAgent::innerStart()
344 { 345 {
345 if (m_overlay) 346 if (m_overlay)
346 m_overlay->startedRecordingProfile(); 347 m_overlay->startedRecordingProfile();
347 m_state->setBoolean(TimelineAgentState::started, true); 348 m_state->setBoolean(TimelineAgentState::started, true);
348 m_timeConverter.reset(); 349 m_timeConverter.reset();
349 m_instrumentingAgents->setInspectorTimelineAgent(this); 350 m_instrumentingAgents->setInspectorTimelineAgent(this);
350 ScriptGCEvent::addEventListener(this); 351 ScriptGCEvent::addEventListener(this);
351 if (m_client) { 352 if (m_client) {
352 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance(); 353 TraceEventDispatcher* dispatcher = TraceEventDispatcher::instance();
354 dispatcher->addListener(InstrumentationEvents::BeginFrame, TRACE_EVENT_P HASE_INSTANT, this, &InspectorTimelineAgent::onBeginImplSideFrame, m_client);
353 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onPaintSetupBegin, m_client); 355 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onPaintSetupBegin, m_client);
354 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onPaintSetupEnd, m_client); 356 dispatcher->addListener(InstrumentationEvents::PaintSetup, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onPaintSetupEnd, m_client);
355 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onRasterTaskBegin, m_client); 357 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_BEGIN, this, &InspectorTimelineAgent::onRasterTaskBegin, m_client);
356 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onRasterTaskEnd, m_client); 358 dispatcher->addListener(InstrumentationEvents::RasterTask, TRACE_EVENT_P HASE_END, this, &InspectorTimelineAgent::onRasterTaskEnd, m_client);
357 dispatcher->addListener(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_ DELETE_OBJECT, this, &InspectorTimelineAgent::onLayerDeleted, m_client); 359 dispatcher->addListener(InstrumentationEvents::Layer, TRACE_EVENT_PHASE_ DELETE_OBJECT, this, &InspectorTimelineAgent::onLayerDeleted, m_client);
360 dispatcher->addListener(InstrumentationEvents::ActivateLayerTree, TRACE_ EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onActivateLayerTree, m_clien t);
358 dispatcher->addListener(PlatformInstrumentation::ImageDecodeEvent, TRACE _EVENT_PHASE_BEGIN, this, &InspectorTimelineAgent::onImageDecodeBegin, m_client) ; 361 dispatcher->addListener(PlatformInstrumentation::ImageDecodeEvent, TRACE _EVENT_PHASE_BEGIN, this, &InspectorTimelineAgent::onImageDecodeBegin, m_client) ;
359 dispatcher->addListener(PlatformInstrumentation::ImageDecodeEvent, TRACE _EVENT_PHASE_END, this, &InspectorTimelineAgent::onImageDecodeEnd, m_client); 362 dispatcher->addListener(PlatformInstrumentation::ImageDecodeEvent, TRACE _EVENT_PHASE_END, this, &InspectorTimelineAgent::onImageDecodeEnd, m_client);
360 dispatcher->addListener(PlatformInstrumentation::DrawLazyPixelRefEvent, TRACE_EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onDrawLazyPixelRef, m_ client); 363 dispatcher->addListener(PlatformInstrumentation::DrawLazyPixelRefEvent, TRACE_EVENT_PHASE_INSTANT, this, &InspectorTimelineAgent::onDrawLazyPixelRef, m_ client);
361 dispatcher->addListener(PlatformInstrumentation::DecodeLazyPixelRefEvent , TRACE_EVENT_PHASE_BEGIN, this, &InspectorTimelineAgent::onDecodeLazyPixelRefBe gin, m_client); 364 dispatcher->addListener(PlatformInstrumentation::DecodeLazyPixelRefEvent , TRACE_EVENT_PHASE_BEGIN, this, &InspectorTimelineAgent::onDecodeLazyPixelRefBe gin, m_client);
362 dispatcher->addListener(PlatformInstrumentation::DecodeLazyPixelRefEvent , TRACE_EVENT_PHASE_END, this, &InspectorTimelineAgent::onDecodeLazyPixelRefEnd, m_client); 365 dispatcher->addListener(PlatformInstrumentation::DecodeLazyPixelRefEvent , TRACE_EVENT_PHASE_END, this, &InspectorTimelineAgent::onDecodeLazyPixelRefEnd, m_client);
363 dispatcher->addListener(PlatformInstrumentation::LazyPixelRef, TRACE_EVE NT_PHASE_DELETE_OBJECT, this, &InspectorTimelineAgent::onLazyPixelRefDeleted, m_ client); 366 dispatcher->addListener(PlatformInstrumentation::LazyPixelRef, TRACE_EVE NT_PHASE_DELETE_OBJECT, this, &InspectorTimelineAgent::onLazyPixelRefDeleted, m_ client);
364 367
365 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) { 368 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) {
366 m_pendingGPURecord.clear(); 369 m_pendingGPURecord.clear();
367 m_client->startGPUEventsRecording(); 370 m_client->startGPUEventsRecording();
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 void InspectorTimelineAgent::didReceiveWebSocketHandshakeResponse(Document* docu ment, unsigned long identifier, const WebSocketHandshakeResponse&) 881 void InspectorTimelineAgent::didReceiveWebSocketHandshakeResponse(Document* docu ment, unsigned long identifier, const WebSocketHandshakeResponse&)
879 { 882 {
880 appendRecord(TimelineRecordFactory::createGenericWebSocketData(identifier), TimelineRecordType::WebSocketReceiveHandshakeResponse, false, document->frame()) ; 883 appendRecord(TimelineRecordFactory::createGenericWebSocketData(identifier), TimelineRecordType::WebSocketReceiveHandshakeResponse, false, document->frame()) ;
881 } 884 }
882 885
883 void InspectorTimelineAgent::didCloseWebSocket(Document* document, unsigned long identifier) 886 void InspectorTimelineAgent::didCloseWebSocket(Document* document, unsigned long identifier)
884 { 887 {
885 appendRecord(TimelineRecordFactory::createGenericWebSocketData(identifier), TimelineRecordType::WebSocketDestroy, true, document->frame()); 888 appendRecord(TimelineRecordFactory::createGenericWebSocketData(identifier), TimelineRecordType::WebSocketDestroy, true, document->frame());
886 } 889 }
887 890
891 void InspectorTimelineAgent::onBeginImplSideFrame(const TraceEventDispatcher::Tr aceEvent& event)
892 {
893 unsigned long long layerTreeId = event.asUInt(InstrumentationEventArguments: :LayerTreeId);
894 if (layerTreeId != m_layerTreeId)
895 return;
896 TimelineThreadState& state = threadState(event.threadIdentifier());
897 state.recordStack.addInstantRecord(createRecordForEvent(event, TimelineRecor dType::BeginFrame));
898 }
899
888 void InspectorTimelineAgent::onPaintSetupBegin(const TraceEventDispatcher::Trace Event& event) 900 void InspectorTimelineAgent::onPaintSetupBegin(const TraceEventDispatcher::Trace Event& event)
889 { 901 {
890 ASSERT(!m_paintSetupStart); 902 ASSERT(!m_paintSetupStart);
891 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti mestamp()); 903 m_paintSetupStart = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti mestamp());
892 } 904 }
893 905
894 void InspectorTimelineAgent::onPaintSetupEnd(const TraceEventDispatcher::TraceEv ent& event) 906 void InspectorTimelineAgent::onPaintSetupEnd(const TraceEventDispatcher::TraceEv ent& event)
895 { 907 {
896 ASSERT(m_paintSetupStart); 908 ASSERT(m_paintSetupStart);
897 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time stamp()); 909 m_paintSetupEnd = m_timeConverter.fromMonotonicallyIncreasingTime(event.time stamp());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 955
944 void InspectorTimelineAgent::onImageDecodeEnd(const TraceEventDispatcher::TraceE vent& event) 956 void InspectorTimelineAgent::onImageDecodeEnd(const TraceEventDispatcher::TraceE vent& event)
945 { 957 {
946 TimelineThreadState& state = threadState(event.threadIdentifier()); 958 TimelineThreadState& state = threadState(event.threadIdentifier());
947 if (!state.decodedPixelRefId) 959 if (!state.decodedPixelRefId)
948 return; 960 return;
949 ASSERT(state.recordStack.isOpenRecordOfType(TimelineRecordType::DecodeImage) ); 961 ASSERT(state.recordStack.isOpenRecordOfType(TimelineRecordType::DecodeImage) );
950 state.recordStack.closeScopedRecord(m_timeConverter.fromMonotonicallyIncreas ingTime(event.timestamp())); 962 state.recordStack.closeScopedRecord(m_timeConverter.fromMonotonicallyIncreas ingTime(event.timestamp()));
951 } 963 }
952 964
965 void InspectorTimelineAgent::onActivateLayerTree(const TraceEventDispatcher::Tra ceEvent& event)
966 {
967 unsigned long long layerTreeId = event.asUInt(InstrumentationEventArguments: :LayerTreeId);
968 if (layerTreeId != m_layerTreeId)
969 return;
970 unsigned long long frameId = event.asUInt(InstrumentationEventArguments::Fra meId);
971 TimelineThreadState& state = threadState(event.threadIdentifier());
972 state.recordStack.addInstantRecord(createRecordForEvent(event, TimelineRecor dType::ActivateLayerTree, TimelineRecordFactory::createFrameData(frameId)));
973 }
974
953 void InspectorTimelineAgent::onLayerDeleted(const TraceEventDispatcher::TraceEve nt& event) 975 void InspectorTimelineAgent::onLayerDeleted(const TraceEventDispatcher::TraceEve nt& event)
954 { 976 {
955 unsigned long long id = event.id(); 977 unsigned long long id = event.id();
956 ASSERT(id); 978 ASSERT(id);
957 m_layerToNodeMap.remove(id); 979 m_layerToNodeMap.remove(id);
958 } 980 }
959 981
960 void InspectorTimelineAgent::onDecodeLazyPixelRefBegin(const TraceEventDispatche r::TraceEvent& event) 982 void InspectorTimelineAgent::onDecodeLazyPixelRefBegin(const TraceEventDispatche r::TraceEvent& event)
961 { 983 {
962 TimelineThreadState& state = threadState(event.threadIdentifier()); 984 TimelineThreadState& state = threadState(event.threadIdentifier());
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 double InspectorTimelineAgent::timestamp() 1224 double InspectorTimelineAgent::timestamp()
1203 { 1225 {
1204 return m_timeConverter.fromMonotonicallyIncreasingTime(WTF::monotonicallyInc reasingTime()); 1226 return m_timeConverter.fromMonotonicallyIncreasingTime(WTF::monotonicallyInc reasingTime());
1205 } 1227 }
1206 1228
1207 Page* InspectorTimelineAgent::page() 1229 Page* InspectorTimelineAgent::page()
1208 { 1230 {
1209 return m_pageAgent ? m_pageAgent->page() : 0; 1231 return m_pageAgent ? m_pageAgent->page() : 0;
1210 } 1232 }
1211 1233
1234 PassRefPtr<JSONObject> InspectorTimelineAgent::createRecordForEvent(const TraceE ventDispatcher::TraceEvent& event, const String& type, PassRefPtr<JSONObject> da ta)
1235 {
1236 double timeestamp = m_timeConverter.fromMonotonicallyIncreasingTime(event.ti mestamp());
1237 return TimelineRecordFactory::createBackgroundRecord(timeestamp, String::num ber(event.threadIdentifier()), type, data);
1238 }
1239
1212 TimelineRecordStack::TimelineRecordStack(InspectorTimelineAgent* timelineAgent) 1240 TimelineRecordStack::TimelineRecordStack(InspectorTimelineAgent* timelineAgent)
1213 : m_timelineAgent(timelineAgent) 1241 : m_timelineAgent(timelineAgent)
1214 { 1242 {
1215 } 1243 }
1216 1244
1217 void TimelineRecordStack::addScopedRecord(PassRefPtr<JSONObject> record) 1245 void TimelineRecordStack::addScopedRecord(PassRefPtr<JSONObject> record)
1218 { 1246 {
1219 m_stack.append(Entry(record)); 1247 m_stack.append(Entry(record));
1220 } 1248 }
1221 1249
(...skipping 20 matching lines...) Expand all
1242 #ifndef NDEBUG 1270 #ifndef NDEBUG
1243 bool TimelineRecordStack::isOpenRecordOfType(const String& type) 1271 bool TimelineRecordStack::isOpenRecordOfType(const String& type)
1244 { 1272 {
1245 String lastRecordType; 1273 String lastRecordType;
1246 return m_stack.isEmpty() || (m_stack.last().record->getString("type", &lastR ecordType) && type == lastRecordType); 1274 return m_stack.isEmpty() || (m_stack.last().record->getString("type", &lastR ecordType) && type == lastRecordType);
1247 } 1275 }
1248 #endif 1276 #endif
1249 1277
1250 } // namespace WebCore 1278 } // namespace WebCore
1251 1279
OLDNEW
« no previous file with comments | « Source/core/inspector/InspectorTimelineAgent.h ('k') | Source/core/inspector/TraceEventDispatcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698