|
Lines 1-5
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec1
|
| 1 |
/* |
1 |
/* |
| 2 |
* Copyright (C) 2009 Google Inc. All rights reserved. |
2 |
* Copyright (C) 2012 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 |
|
Lines 73-78
static const char RecalculateStyles[] = "RecalculateStyles";
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec2
|
| 73 |
static const char InvalidateLayout[] = "InvalidateLayout"; |
73 |
static const char InvalidateLayout[] = "InvalidateLayout"; |
| 74 |
static const char Layout[] = "Layout"; |
74 |
static const char Layout[] = "Layout"; |
| 75 |
static const char Paint[] = "Paint"; |
75 |
static const char Paint[] = "Paint"; |
|
|
76 |
static const char DeferredPaint[] = "DeferredPaint"; |
| 76 |
static const char ScrollLayer[] = "ScrollLayer"; |
77 |
static const char ScrollLayer[] = "ScrollLayer"; |
| 77 |
static const char DecodeImage[] = "DecodeImage"; |
78 |
static const char DecodeImage[] = "DecodeImage"; |
| 78 |
static const char ResizeImage[] = "ResizeImage"; |
79 |
static const char ResizeImage[] = "ResizeImage"; |
|
Lines 110-115
static const char CancelAnimationFrame[] = "CancelAnimationFrame";
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec3
|
| 110 |
static const char FireAnimationFrame[] = "FireAnimationFrame"; |
111 |
static const char FireAnimationFrame[] = "FireAnimationFrame"; |
| 111 |
} |
112 |
} |
| 112 |
|
113 |
|
|
|
114 |
class TraceEventArguments { |
| 115 |
public: |
| 116 |
TraceEventArguments(int numArguments, const char* const* argumentNames, const unsigned char* argumentTypes, const unsigned long long* argumentValues) |
| 117 |
: m_size(numArguments), m_argumentNames(argumentNames), m_argumentTypes(argumentTypes), m_argumentValues(argumentValues) |
| 118 |
{ |
| 119 |
} |
| 120 |
|
| 121 |
int size() const { return m_size; } |
| 122 |
|
| 123 |
bool getBool(const char* name) const { return getParameter(name, TRACE_VALUE_TYPE_BOOL).m_bool; } |
| 124 |
long long getInt(const char* name) const { return getParameter(name, TRACE_VALUE_TYPE_INT).m_int; } |
| 125 |
unsigned long long getUInt(const char* name) const { return getParameter(name, TRACE_VALUE_TYPE_UINT).m_uint; } |
| 126 |
double getDouble(const char* name) const { return getParameter(name, TRACE_VALUE_TYPE_DOUBLE).m_double; } |
| 127 |
const char* getString(const char* name) const { return getParameter(name, TRACE_VALUE_TYPE_STRING).m_string; } |
| 128 |
|
| 129 |
private: |
| 130 |
// FIXME: use the definition in TraceEvent.h once we expose the latter to all plaforms. |
| 131 |
union TraceValueUnion { |
| 132 |
bool m_bool; |
| 133 |
unsigned long long m_uint; |
| 134 |
long long m_int; |
| 135 |
double m_double; |
| 136 |
const void* m_pointer; |
| 137 |
const char* m_string; |
| 138 |
}; |
| 139 |
|
| 140 |
const TraceValueUnion& getParameter(const char* name, char expectedType) const |
| 141 |
{ |
| 142 |
static TraceValueUnion missingValue; |
| 143 |
|
| 144 |
for (int i = 0; i < m_size; ++i) { |
| 145 |
if (!strcmp(name, m_argumentNames[i])) { |
| 146 |
if (m_argumentTypes[i] != expectedType) { |
| 147 |
ASSERT_NOT_REACHED(); |
| 148 |
return missingValue; |
| 149 |
} |
| 150 |
return *reinterpret_cast<const TraceValueUnion*>(m_argumentValues + i); |
| 151 |
} |
| 152 |
} |
| 153 |
ASSERT_NOT_REACHED(); |
| 154 |
return missingValue; |
| 155 |
} |
| 156 |
|
| 157 |
int m_size; |
| 158 |
const char* const* m_argumentNames; |
| 159 |
const unsigned char* m_argumentTypes; |
| 160 |
const unsigned long long* m_argumentValues; |
| 161 |
}; |
| 162 |
|
| 163 |
|
| 113 |
void InspectorTimelineAgent::pushGCEventRecords() |
164 |
void InspectorTimelineAgent::pushGCEventRecords() |
| 114 |
{ |
165 |
{ |
| 115 |
if (!m_gcEvents.size()) |
166 |
if (!m_gcEvents.size()) |
|
Lines 171-176
void InspectorTimelineAgent::start(ErrorString*, const int* maxCallStackDepth)
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec4
|
| 171 |
m_instrumentingAgents->setInspectorTimelineAgent(this); |
222 |
m_instrumentingAgents->setInspectorTimelineAgent(this); |
| 172 |
ScriptGCEvent::addEventListener(this); |
223 |
ScriptGCEvent::addEventListener(this); |
| 173 |
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, true); |
224 |
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, true); |
|
|
225 |
if (m_client) |
| 226 |
m_client->enableTraceEventsReporting(true); |
| 174 |
} |
227 |
} |
| 175 |
|
228 |
|
| 176 |
void InspectorTimelineAgent::stop(ErrorString*) |
229 |
void InspectorTimelineAgent::stop(ErrorString*) |
|
Lines 178-183
void InspectorTimelineAgent::stop(ErrorString*)
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec5
|
| 178 |
if (!m_state->getBoolean(TimelineAgentState::timelineAgentEnabled)) |
231 |
if (!m_state->getBoolean(TimelineAgentState::timelineAgentEnabled)) |
| 179 |
return; |
232 |
return; |
| 180 |
|
233 |
|
|
|
234 |
if (m_client) |
| 235 |
m_client->enableTraceEventsReporting(false); |
| 181 |
m_instrumentingAgents->setInspectorTimelineAgent(0); |
236 |
m_instrumentingAgents->setInspectorTimelineAgent(0); |
| 182 |
ScriptGCEvent::removeEventListener(this); |
237 |
ScriptGCEvent::removeEventListener(this); |
| 183 |
|
238 |
|
|
Lines 185-190
void InspectorTimelineAgent::stop(ErrorString*)
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec6
|
| 185 |
m_gcEvents.clear(); |
240 |
m_gcEvents.clear(); |
| 186 |
|
241 |
|
| 187 |
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, false); |
242 |
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, false); |
|
|
243 |
m_deferredPaintLayerId = 0; |
| 244 |
m_knownLayers.clear(); |
| 188 |
} |
245 |
} |
| 189 |
|
246 |
|
| 190 |
void InspectorTimelineAgent::setIncludeMemoryDetails(ErrorString*, bool value) |
247 |
void InspectorTimelineAgent::setIncludeMemoryDetails(ErrorString*, bool value) |
|
Lines 270-275
void InspectorTimelineAgent::didRecalculateStyle()
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec7
|
| 270 |
|
327 |
|
| 271 |
void InspectorTimelineAgent::willPaint(Frame* frame) |
328 |
void InspectorTimelineAgent::willPaint(Frame* frame) |
| 272 |
{ |
329 |
{ |
|
|
330 |
if (m_deferredPaintLayerId) |
| 331 |
m_knownLayers.add(m_deferredPaintLayerId); |
| 273 |
pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Paint, true, frame, true); |
332 |
pushCurrentRecord(InspectorObject::create(), TimelineRecordType::Paint, true, frame, true); |
| 274 |
} |
333 |
} |
| 275 |
|
334 |
|
|
Lines 311-316
void InspectorTimelineAgent::didResizeImage()
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec8
|
| 311 |
didCompleteCurrentRecord(TimelineRecordType::ResizeImage); |
370 |
didCompleteCurrentRecord(TimelineRecordType::ResizeImage); |
| 312 |
} |
371 |
} |
| 313 |
|
372 |
|
|
|
373 |
|
| 374 |
void InspectorTimelineAgent::didReportTraceEvent(TraceEventPhase phase, const char*, const char* name, unsigned long long id, |
| 375 |
int numArgs, const char* const* argNames, const unsigned char* argTypes, const unsigned long long* argValues, |
| 376 |
unsigned char flags) |
| 377 |
{ |
| 378 |
TraceEventHandler handler = m_traceEventHandlers.get(name); |
| 379 |
if (!handler) |
| 380 |
return; |
| 381 |
TraceEventArguments arguments(numArgs, argNames, argTypes, argValues); |
| 382 |
(this->*handler)(name, phase, arguments); |
| 383 |
} |
| 384 |
|
| 385 |
const char kLayerId[] = "layerId"; |
| 386 |
|
| 387 |
void InspectorTimelineAgent::onDeferPaint(const char*, TraceEventPhase phase, const TraceEventArguments& arguments) |
| 388 |
{ |
| 389 |
switch (phase) { |
| 390 |
case TracePhaseBegin: |
| 391 |
m_deferredPaintLayerId = arguments.getUInt(kLayerId); |
| 392 |
ASSERT(m_deferredPaintLayerId); |
| 393 |
break; |
| 394 |
case TracePhaseEnd: |
| 395 |
m_deferredPaintLayerId = 0; |
| 396 |
break; |
| 397 |
default: |
| 398 |
ASSERT_NOT_REACHED(); |
| 399 |
} |
| 400 |
} |
| 401 |
|
| 402 |
void InspectorTimelineAgent::onPerformDeferredPaint(const char* name, TraceEventPhase phase, const TraceEventArguments& arguments) |
| 403 |
{ |
| 404 |
switch (phase) { |
| 405 |
case TracePhaseBegin: { |
| 406 |
unsigned long long layerId = arguments.getUInt(kLayerId); |
| 407 |
ASSERT(layerId); |
| 408 |
if (m_knownLayers.contains(layerId)) |
| 409 |
pushCurrentRecord(InspectorObject::create(), TimelineRecordType::DeferredPaint, false, 0, true); |
| 410 |
else |
| 411 |
pushSkippedRecord(TimelineRecordType::DeferredPaint); |
| 412 |
break; |
| 413 |
} |
| 414 |
case TracePhaseEnd: |
| 415 |
didCompleteCurrentRecord(TimelineRecordType::DeferredPaint); |
| 416 |
break; |
| 417 |
default: |
| 418 |
ASSERT_NOT_REACHED(); |
| 419 |
} |
| 420 |
} |
| 421 |
|
| 422 |
void InspectorTimelineAgent::onReleaseLayerId(const char*, TraceEventPhase, const TraceEventArguments& arguments) |
| 423 |
{ |
| 424 |
unsigned long long id = arguments.getUInt(kLayerId); |
| 425 |
ASSERT(id); |
| 426 |
m_knownLayers.remove(id); |
| 427 |
} |
| 428 |
|
| 314 |
void InspectorTimelineAgent::willComposite() |
429 |
void InspectorTimelineAgent::willComposite() |
| 315 |
{ |
430 |
{ |
| 316 |
pushCurrentRecord(InspectorObject::create(), TimelineRecordType::CompositeLayers, false, 0); |
431 |
pushCurrentRecord(InspectorObject::create(), TimelineRecordType::CompositeLayers, false, 0); |
|
Lines 485-490
void InspectorTimelineAgent::didProcessTask()
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec9
|
| 485 |
|
600 |
|
| 486 |
void InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<InspectorObject> record, const String& type, const String& frameId) |
601 |
void InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<InspectorObject> record, const String& type, const String& frameId) |
| 487 |
{ |
602 |
{ |
|
|
603 |
if (!m_recordStack.isEmpty() && !m_recordStack.last().record) |
| 604 |
return; |
| 488 |
commitFrameRecord(); |
605 |
commitFrameRecord(); |
| 489 |
innerAddRecordToTimeline(record, type, frameId); |
606 |
innerAddRecordToTimeline(record, type, frameId); |
| 490 |
} |
607 |
} |
|
Lines 534-557
void InspectorTimelineAgent::didCompleteCurrentRecord(const String& type)
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec10
|
| 534 |
{ |
651 |
{ |
| 535 |
// An empty stack could merely mean that the timeline agent was turned on in the middle of |
652 |
// An empty stack could merely mean that the timeline agent was turned on in the middle of |
| 536 |
// an event. Don't treat as an error. |
653 |
// an event. Don't treat as an error. |
| 537 |
if (!m_recordStack.isEmpty()) { |
654 |
if (m_recordStack.isEmpty()) |
| 538 |
if (m_platformInstrumentationClientInstalledAtStackDepth == m_recordStack.size()) { |
655 |
return; |
| 539 |
m_platformInstrumentationClientInstalledAtStackDepth = 0; |
|
|
| 540 |
PlatformInstrumentation::setClient(0); |
| 541 |
} |
| 542 |
|
656 |
|
| 543 |
pushGCEventRecords(); |
657 |
if (m_platformInstrumentationClientInstalledAtStackDepth == m_recordStack.size()) { |
| 544 |
TimelineRecordEntry entry = m_recordStack.last(); |
658 |
m_platformInstrumentationClientInstalledAtStackDepth = 0; |
|
|
659 |
PlatformInstrumentation::setClient(0); |
| 660 |
} |
| 661 |
|
| 662 |
TimelineRecordEntry entry = m_recordStack.last(); |
| 663 |
ASSERT(entry.type == type); |
| 664 |
if (!entry.record) { |
| 545 |
m_recordStack.removeLast(); |
665 |
m_recordStack.removeLast(); |
| 546 |
ASSERT(entry.type == type); |
666 |
return; |
| 547 |
entry.record->setObject("data", entry.data); |
|
|
| 548 |
entry.record->setArray("children", entry.children); |
| 549 |
entry.record->setNumber("endTime", timestamp()); |
| 550 |
size_t usedHeapSizeDelta = getUsedHeapSize() - entry.usedHeapSizeAtStart; |
| 551 |
if (usedHeapSizeDelta) |
| 552 |
entry.record->setNumber("usedHeapSizeDelta", usedHeapSizeDelta); |
| 553 |
addRecordToTimeline(entry.record, type, entry.frameId); |
| 554 |
} |
667 |
} |
|
|
668 |
|
| 669 |
pushGCEventRecords(); |
| 670 |
m_recordStack.removeLast(); |
| 671 |
entry.record->setObject("data", entry.data); |
| 672 |
entry.record->setArray("children", entry.children); |
| 673 |
entry.record->setNumber("endTime", timestamp()); |
| 674 |
size_t usedHeapSizeDelta = getUsedHeapSize() - entry.usedHeapSizeAtStart; |
| 675 |
if (usedHeapSizeDelta) |
| 676 |
entry.record->setNumber("usedHeapSizeDelta", usedHeapSizeDelta); |
| 677 |
addRecordToTimeline(entry.record, type, entry.frameId); |
| 555 |
} |
678 |
} |
| 556 |
|
679 |
|
| 557 |
InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* state, InspectorType type, InspectorClient* client) |
680 |
InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* state, InspectorType type, InspectorClient* client) |
|
Lines 564-570
InspectorTimelineAgent::InspectorTimelineAgent(InstrumentingAgents* instrumentin
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec11
|
| 564 |
, m_platformInstrumentationClientInstalledAtStackDepth(0) |
687 |
, m_platformInstrumentationClientInstalledAtStackDepth(0) |
| 565 |
, m_inspectorType(type) |
688 |
, m_inspectorType(type) |
| 566 |
, m_client(client) |
689 |
, m_client(client) |
|
|
690 |
, m_deferredPaintLayerId(0) |
| 567 |
{ |
691 |
{ |
|
|
692 |
m_traceEventHandlers.set("Instrumentation::DeferPaint", &InspectorTimelineAgent::onDeferPaint); |
| 693 |
m_traceEventHandlers.set("Instrumentation::PerformDeferredPaint", &InspectorTimelineAgent::onPerformDeferredPaint); |
| 694 |
m_traceEventHandlers.set("Instrumentation::ReleaseLayerId", &InspectorTimelineAgent::onReleaseLayerId); |
| 695 |
|
| 568 |
} |
696 |
} |
| 569 |
|
697 |
|
| 570 |
void InspectorTimelineAgent::appendRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame* frame) |
698 |
void InspectorTimelineAgent::appendRecord(PassRefPtr<InspectorObject> data, const String& type, bool captureCallStack, Frame* frame) |
|
Lines 594-599
void InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data,
a/Source/WebCore/inspector/InspectorTimelineAgent.cpp_sec12
|
| 594 |
} |
722 |
} |
| 595 |
} |
723 |
} |
| 596 |
|
724 |
|
|
|
725 |
void InspectorTimelineAgent::pushSkippedRecord(const String& type) |
| 726 |
{ |
| 727 |
m_recordStack.append(TimelineRecordEntry(PassRefPtr<InspectorObject>(), PassRefPtr<InspectorObject>(), PassRefPtr<InspectorArray>(), type, "", 0)); |
| 728 |
} |
| 729 |
|
| 597 |
void InspectorTimelineAgent::commitFrameRecord() |
730 |
void InspectorTimelineAgent::commitFrameRecord() |
| 598 |
{ |
731 |
{ |
| 599 |
if (!m_pendingFrameRecord) |
732 |
if (!m_pendingFrameRecord) |