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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 , inKnownLayerTask(false) | 209 , inKnownLayerTask(false) |
210 , decodedPixelRefId(0) | 210 , decodedPixelRefId(0) |
211 { | 211 { |
212 } | 212 } |
213 | 213 |
214 TimelineRecordStack recordStack; | 214 TimelineRecordStack recordStack; |
215 bool inKnownLayerTask; | 215 bool inKnownLayerTask; |
216 unsigned long long decodedPixelRefId; | 216 unsigned long long decodedPixelRefId; |
217 }; | 217 }; |
218 | 218 |
219 struct TimelineGCEvent { | |
220 TimelineGCEvent(double startTime, double endTime, size_t collectedBytes) | |
221 : startTime(startTime), endTime(endTime), collectedBytes(collectedBytes) | |
222 { | |
223 } | |
224 double startTime; | |
225 double endTime; | |
226 size_t collectedBytes; | |
227 }; | |
228 | |
229 struct TimelineImageInfo { | 219 struct TimelineImageInfo { |
230 int backendNodeId; | 220 int backendNodeId; |
231 String url; | 221 String url; |
232 | 222 |
233 TimelineImageInfo() : backendNodeId(0) { } | 223 TimelineImageInfo() : backendNodeId(0) { } |
234 TimelineImageInfo(int backendNodeId, String url) : backendNodeId(backendNode
Id), url(url) { } | 224 TimelineImageInfo(int backendNodeId, String url) : backendNodeId(backendNode
Id), url(url) { } |
235 }; | 225 }; |
236 | 226 |
237 static LocalFrame* frameForExecutionContext(ExecutionContext* context) | 227 static LocalFrame* frameForExecutionContext(ExecutionContext* context) |
238 { | 228 { |
(...skipping 12 matching lines...) Expand all Loading... |
251 return true; | 241 return true; |
252 | 242 |
253 for (size_t i = 0; i < eventPath.size(); i++) { | 243 for (size_t i = 0; i < eventPath.size(); i++) { |
254 if (eventPath[i].node()->hasEventListeners(eventType)) | 244 if (eventPath[i].node()->hasEventListeners(eventType)) |
255 return true; | 245 return true; |
256 } | 246 } |
257 | 247 |
258 return false; | 248 return false; |
259 } | 249 } |
260 | 250 |
261 void InspectorTimelineAgent::pushGCEventRecords() | |
262 { | |
263 if (!m_gcEvents.size()) | |
264 return; | |
265 | |
266 GCEvents events = m_gcEvents; | |
267 m_gcEvents.clear(); | |
268 for (GCEvents::iterator i = events.begin(); i != events.end(); ++i) { | |
269 double ts = i->startTime * msPerSecond; | |
270 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecor
d(ts, m_maxCallStackDepth, TimelineRecordType::GCEvent, TimelineRecordFactory::c
reateGCEventData(i->collectedBytes)); | |
271 record->setEndTime(i->endTime * msPerSecond); | |
272 addRecordToTimeline(record.release(), ts); | |
273 } | |
274 } | |
275 | |
276 void InspectorTimelineAgent::didGC(double startTime, double endTime, size_t coll
ectedBytesCount) | 251 void InspectorTimelineAgent::didGC(double startTime, double endTime, size_t coll
ectedBytesCount) |
277 { | 252 { |
278 m_gcEvents.append(TimelineGCEvent(startTime, endTime, collectedBytesCount)); | 253 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord( |
| 254 startTime * msPerSecond, |
| 255 0, |
| 256 TimelineRecordType::GCEvent, |
| 257 TimelineRecordFactory::createGCEventData(collectedBytesCount)); |
| 258 record->setEndTime(endTime * msPerSecond); |
| 259 addRecordToTimeline(record.release(), timestamp()); |
279 } | 260 } |
280 | 261 |
281 InspectorTimelineAgent::~InspectorTimelineAgent() | 262 InspectorTimelineAgent::~InspectorTimelineAgent() |
282 { | 263 { |
283 } | 264 } |
284 | 265 |
285 void InspectorTimelineAgent::setFrontend(InspectorFrontend* frontend) | 266 void InspectorTimelineAgent::setFrontend(InspectorFrontend* frontend) |
286 { | 267 { |
287 m_frontend = frontend->timeline(); | 268 m_frontend = frontend->timeline(); |
288 } | 269 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (m_client) { | 403 if (m_client) { |
423 TraceEventDispatcher::instance()->removeAllListeners(this, m_client); | 404 TraceEventDispatcher::instance()->removeAllListeners(this, m_client); |
424 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) | 405 if (m_state->getBoolean(TimelineAgentState::includeGPUEvents)) |
425 m_client->stopGPUEventsRecording(); | 406 m_client->stopGPUEventsRecording(); |
426 } | 407 } |
427 m_instrumentingAgents->setInspectorTimelineAgent(0); | 408 m_instrumentingAgents->setInspectorTimelineAgent(0); |
428 ScriptGCEvent::removeEventListener(this); | 409 ScriptGCEvent::removeEventListener(this); |
429 | 410 |
430 clearRecordStack(); | 411 clearRecordStack(); |
431 m_threadStates.clear(); | 412 m_threadStates.clear(); |
432 m_gcEvents.clear(); | |
433 m_gpuTask.clear(); | 413 m_gpuTask.clear(); |
434 m_layerToNodeMap.clear(); | 414 m_layerToNodeMap.clear(); |
435 m_pixelRefToImageInfo.clear(); | 415 m_pixelRefToImageInfo.clear(); |
436 m_imageBeingPainted = 0; | 416 m_imageBeingPainted = 0; |
437 m_paintSetupStart = 0; | 417 m_paintSetupStart = 0; |
438 m_mayEmitFirstPaint = false; | 418 m_mayEmitFirstPaint = false; |
439 | 419 |
440 for (size_t i = 0; i < m_consoleTimelines.size(); ++i) { | 420 for (size_t i = 0; i < m_consoleTimelines.size(); ++i) { |
441 String message = String::format("Timeline '%s' terminated.", m_consoleTi
melines[i].utf8().data()); | 421 String message = String::format("Timeline '%s' terminated.", m_consoleTi
melines[i].utf8().data()); |
442 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageL
evel, message); | 422 mainFrame()->console().addMessage(ConsoleAPIMessageSource, DebugMessageL
evel, message); |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 void InspectorTimelineAgent::didCompleteCurrentRecord(const String& type) | 1130 void InspectorTimelineAgent::didCompleteCurrentRecord(const String& type) |
1151 { | 1131 { |
1152 // An empty stack could merely mean that the timeline agent was turned on in
the middle of | 1132 // An empty stack could merely mean that the timeline agent was turned on in
the middle of |
1153 // an event. Don't treat as an error. | 1133 // an event. Don't treat as an error. |
1154 if (!m_recordStack.isEmpty()) { | 1134 if (!m_recordStack.isEmpty()) { |
1155 if (m_platformInstrumentationClientInstalledAtStackDepth == m_recordStac
k.size()) { | 1135 if (m_platformInstrumentationClientInstalledAtStackDepth == m_recordStac
k.size()) { |
1156 m_platformInstrumentationClientInstalledAtStackDepth = 0; | 1136 m_platformInstrumentationClientInstalledAtStackDepth = 0; |
1157 PlatformInstrumentation::setClient(0); | 1137 PlatformInstrumentation::setClient(0); |
1158 } | 1138 } |
1159 | 1139 |
1160 pushGCEventRecords(); | |
1161 TimelineRecordEntry entry = m_recordStack.last(); | 1140 TimelineRecordEntry entry = m_recordStack.last(); |
1162 m_recordStack.removeLast(); | 1141 m_recordStack.removeLast(); |
1163 while (entry.type != type && entry.skipWhenUnbalanced && !m_recordStack.
isEmpty()) { | 1142 while (entry.type != type && entry.skipWhenUnbalanced && !m_recordStack.
isEmpty()) { |
1164 // Discard pending skippable entry, paste its children inplace. | 1143 // Discard pending skippable entry, paste its children inplace. |
1165 if (entry.children) | 1144 if (entry.children) |
1166 m_recordStack.last().children->concat(entry.children); | 1145 m_recordStack.last().children->concat(entry.children); |
1167 entry = m_recordStack.last(); | 1146 entry = m_recordStack.last(); |
1168 m_recordStack.removeLast(); | 1147 m_recordStack.removeLast(); |
1169 } | 1148 } |
1170 ASSERT(entry.type == type); | 1149 ASSERT(entry.type == type); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 , m_imageBeingPainted(0) | 1182 , m_imageBeingPainted(0) |
1204 , m_paintSetupStart(0) | 1183 , m_paintSetupStart(0) |
1205 , m_styleRecalcElementCounter(0) | 1184 , m_styleRecalcElementCounter(0) |
1206 , m_mayEmitFirstPaint(false) | 1185 , m_mayEmitFirstPaint(false) |
1207 , m_lastProgressTimestamp(0) | 1186 , m_lastProgressTimestamp(0) |
1208 { | 1187 { |
1209 } | 1188 } |
1210 | 1189 |
1211 void InspectorTimelineAgent::appendRecord(PassRefPtr<JSONObject> data, const Str
ing& type, bool captureCallStack, LocalFrame* frame) | 1190 void InspectorTimelineAgent::appendRecord(PassRefPtr<JSONObject> data, const Str
ing& type, bool captureCallStack, LocalFrame* frame) |
1212 { | 1191 { |
1213 pushGCEventRecords(); | |
1214 double ts = timestamp(); | 1192 double ts = timestamp(); |
1215 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(ts
, captureCallStack ? m_maxCallStackDepth : 0, type, data); | 1193 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(ts
, captureCallStack ? m_maxCallStackDepth : 0, type, data); |
1216 setFrameIdentifier(record.get(), frame); | 1194 setFrameIdentifier(record.get(), frame); |
1217 addRecordToTimeline(record.release(), ts); | 1195 addRecordToTimeline(record.release(), ts); |
1218 } | 1196 } |
1219 | 1197 |
1220 void InspectorTimelineAgent::sendEvent(PassRefPtr<TimelineEvent> record) | 1198 void InspectorTimelineAgent::sendEvent(PassRefPtr<TimelineEvent> record) |
1221 { | 1199 { |
1222 RefPtr<TimelineEvent> retain = record; | 1200 RefPtr<TimelineEvent> retain = record; |
1223 if (m_bufferedEvents) { | 1201 if (m_bufferedEvents) { |
1224 m_bufferedEvents->addItem(retain); | 1202 m_bufferedEvents->addItem(retain); |
1225 if (!m_liveEvents.contains(TimelineRecordFactory::type(retain.get()))) | 1203 if (!m_liveEvents.contains(TimelineRecordFactory::type(retain.get()))) |
1226 return; | 1204 return; |
1227 } | 1205 } |
1228 m_frontend->eventRecorded(retain.release()); | 1206 m_frontend->eventRecorded(retain.release()); |
1229 } | 1207 } |
1230 | 1208 |
1231 void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<JSONObject> data, cons
t String& type, bool captureCallStack, LocalFrame* frame, bool hasLowLevelDetail
s) | 1209 void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<JSONObject> data, cons
t String& type, bool captureCallStack, LocalFrame* frame, bool hasLowLevelDetail
s) |
1232 { | 1210 { |
1233 pushGCEventRecords(); | |
1234 commitFrameRecord(); | 1211 commitFrameRecord(); |
1235 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(ti
mestamp(), captureCallStack ? m_maxCallStackDepth : 0, type, data.get()); | 1212 RefPtr<TimelineEvent> record = TimelineRecordFactory::createGenericRecord(ti
mestamp(), captureCallStack ? m_maxCallStackDepth : 0, type, data.get()); |
1236 setFrameIdentifier(record.get(), frame); | 1213 setFrameIdentifier(record.get(), frame); |
1237 m_recordStack.append(TimelineRecordEntry(record.release(), data, TypeBuilder
::Array<TimelineEvent>::create(), type, getUsedHeapSize())); | 1214 m_recordStack.append(TimelineRecordEntry(record.release(), data, TypeBuilder
::Array<TimelineEvent>::create(), type, getUsedHeapSize())); |
1238 if (hasLowLevelDetails && !m_platformInstrumentationClientInstalledAtStackDe
pth && !PlatformInstrumentation::hasClient()) { | 1215 if (hasLowLevelDetails && !m_platformInstrumentationClientInstalledAtStackDe
pth && !PlatformInstrumentation::hasClient()) { |
1239 m_platformInstrumentationClientInstalledAtStackDepth = m_recordStack.siz
e(); | 1216 m_platformInstrumentationClientInstalledAtStackDepth = m_recordStack.siz
e(); |
1240 PlatformInstrumentation::setClient(this); | 1217 PlatformInstrumentation::setClient(this); |
1241 } | 1218 } |
1242 } | 1219 } |
1243 | 1220 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 | 1333 |
1357 #ifndef NDEBUG | 1334 #ifndef NDEBUG |
1358 bool TimelineRecordStack::isOpenRecordOfType(const String& type) | 1335 bool TimelineRecordStack::isOpenRecordOfType(const String& type) |
1359 { | 1336 { |
1360 return !m_stack.isEmpty() && m_stack.last().type == type; | 1337 return !m_stack.isEmpty() && m_stack.last().type == type; |
1361 } | 1338 } |
1362 #endif | 1339 #endif |
1363 | 1340 |
1364 } // namespace WebCore | 1341 } // namespace WebCore |
1365 | 1342 |
OLD | NEW |