InspectorTimelineAgent.cpp revision 65f03d4f644ce73618e5f4f50dd694b26f55ae12
1231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/* 2231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* Copyright (C) 2009 Google Inc. All rights reserved. 3231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* 4231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* Redistribution and use in source and binary forms, with or without 5231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* modification, are permitted provided that the following conditions are 6231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* met: 7231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* 8231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* * Redistributions of source code must retain the above copyright 9231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* notice, this list of conditions and the following disclaimer. 10231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* * Redistributions in binary form must reproduce the above 11231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* copyright notice, this list of conditions and the following disclaimer 12231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* in the documentation and/or other materials provided with the 13231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* distribution. 14231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* * Neither the name of Google Inc. nor the names of its 15231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* contributors may be used to endorse or promote products derived from 16231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* this software without specific prior written permission. 17231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* 18231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block*/ 30231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 31231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "config.h" 32231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "InspectorTimelineAgent.h" 33231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 34231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#if ENABLE(INSPECTOR) 35231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 36231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "Event.h" 37e8b154fd68f9b33be40a3590e58347f353835f5cSteve Block#include "InspectorFrontend.h" 38643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#include "IntRect.h" 39643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#include "ResourceRequest.h" 40643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#include "ResourceResponse.h" 41cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include "TimelineRecordFactory.h" 42231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 43231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include <wtf/CurrentTime.h> 44231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 45231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blocknamespace WebCore { 46231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 47a94275402997c11dd2e778633dacf4b7e630a35dBen Murdochint InspectorTimelineAgent::s_id = 0; 48dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 49e8b154fd68f9b33be40a3590e58347f353835f5cSteve BlockInspectorTimelineAgent::InspectorTimelineAgent(InspectorFrontend* frontend) 50cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block : m_frontend(frontend) 51a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch , m_id(++s_id) 52231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 53dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block ScriptGCEvent::addEventListener(this); 54231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block ASSERT(m_frontend); 55231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 56231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 57dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::pushGCEventRecords() 58dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 5921939df44de1705786c545cd1bf519d47250322dBen Murdoch if (!m_gcEvents.size()) 6021939df44de1705786c545cd1bf519d47250322dBen Murdoch return; 6121939df44de1705786c545cd1bf519d47250322dBen Murdoch 6221939df44de1705786c545cd1bf519d47250322dBen Murdoch GCEvents events = m_gcEvents; 6321939df44de1705786c545cd1bf519d47250322dBen Murdoch m_gcEvents.clear(); 6421939df44de1705786c545cd1bf519d47250322dBen Murdoch for (GCEvents::iterator i = events.begin(); i != events.end(); ++i) { 65e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(i->startTime); 66f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick record->setObject("data", TimelineRecordFactory::createGCEventData(i->collectedBytes)); 67e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("endTime", i->endTime); 68e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), GCEventTimelineRecordType); 69dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block } 70dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 71dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 72dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::didGC(double startTime, double endTime, size_t collectedBytesCount) 73dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 74dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block m_gcEvents.append(GCEvent(startTime, endTime, collectedBytesCount)); 75dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 76dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 77231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve BlockInspectorTimelineAgent::~InspectorTimelineAgent() 78231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 79dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block ScriptGCEvent::removeEventListener(this); 80dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 81dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 82dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::willCallFunction(const String& scriptName, int scriptLine) 83dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 84e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createFunctionCallData(scriptName, scriptLine), FunctionCallTimelineRecordType); 85dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 86dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 87dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::didCallFunction() 88dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 89dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block didCompleteCurrentRecord(FunctionCallTimelineRecordType); 90231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 91231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 92643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockvoid InspectorTimelineAgent::willDispatchEvent(const Event& event) 93231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 94e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createEventDispatchData(event), 95643ca7872b450ea4efacab6188849e5aac2ba161Steve Block EventDispatchTimelineRecordType); 96231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 97231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 98643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockvoid InspectorTimelineAgent::didDispatchEvent() 99231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 100643ca7872b450ea4efacab6188849e5aac2ba161Steve Block didCompleteCurrentRecord(EventDispatchTimelineRecordType); 101231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 102231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 103231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid InspectorTimelineAgent::willLayout() 104231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 105e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(InspectorObject::create(), LayoutTimelineRecordType); 106231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 107231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 108231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid InspectorTimelineAgent::didLayout() 109231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 110cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block didCompleteCurrentRecord(LayoutTimelineRecordType); 111231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 112231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 113231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid InspectorTimelineAgent::willRecalculateStyle() 114231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 115e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(InspectorObject::create(), RecalculateStylesTimelineRecordType); 116231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 117231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 118231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid InspectorTimelineAgent::didRecalculateStyle() 119231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 120cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block didCompleteCurrentRecord(RecalculateStylesTimelineRecordType); 121231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 122231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 123643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockvoid InspectorTimelineAgent::willPaint(const IntRect& rect) 124231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 125e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createPaintData(rect), PaintTimelineRecordType); 126231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 127231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 128231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid InspectorTimelineAgent::didPaint() 129231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 130cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block didCompleteCurrentRecord(PaintTimelineRecordType); 131231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 132231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 133d0825bca7fe65beaee391d30da42e937db621564Steve Blockvoid InspectorTimelineAgent::willWriteHTML(unsigned int length, unsigned int startLine) 134231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 135e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createParseHTMLData(length, startLine), ParseHTMLTimelineRecordType); 136231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 137231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 138d0825bca7fe65beaee391d30da42e937db621564Steve Blockvoid InspectorTimelineAgent::didWriteHTML(unsigned int endLine) 139231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 140d0825bca7fe65beaee391d30da42e937db621564Steve Block if (!m_recordStack.isEmpty()) { 141d0825bca7fe65beaee391d30da42e937db621564Steve Block TimelineRecordEntry entry = m_recordStack.last(); 142e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke entry.data->setNumber("endLine", endLine); 143d0825bca7fe65beaee391d30da42e937db621564Steve Block didCompleteCurrentRecord(ParseHTMLTimelineRecordType); 144d0825bca7fe65beaee391d30da42e937db621564Steve Block } 145cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 146dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 147cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::didInstallTimer(int timerId, int timeout, bool singleShot) 148cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 149dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 150e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 151f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick record->setObject("data", TimelineRecordFactory::createTimerInstallData(timerId, timeout, singleShot)); 152e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), TimerInstallTimelineRecordType); 153cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 154cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 155cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::didRemoveTimer(int timerId) 156cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 157dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 158e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 159f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick record->setObject("data", TimelineRecordFactory::createGenericTimerData(timerId)); 160e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), TimerRemoveTimelineRecordType); 161cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 162cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 163cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::willFireTimer(int timerId) 164cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 165e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createGenericTimerData(timerId), TimerFireTimelineRecordType); 166cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 167cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 168cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::didFireTimer() 169cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 170cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block didCompleteCurrentRecord(TimerFireTimelineRecordType); 171cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 172cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 173cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::willChangeXHRReadyState(const String& url, int readyState) 174cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 175e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createXHRReadyStateChangeData(url, readyState), XHRReadyStateChangeRecordType); 176cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 177cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 178cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::didChangeXHRReadyState() 179cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 180cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block didCompleteCurrentRecord(XHRReadyStateChangeRecordType); 181cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 182cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 183cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::willLoadXHR(const String& url) 184cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 185e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createXHRLoadData(url), XHRLoadRecordType); 186cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 187cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 188cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::didLoadXHR() 189cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 190cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block didCompleteCurrentRecord(XHRLoadRecordType); 191cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 192cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 193643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockvoid InspectorTimelineAgent::willEvaluateScript(const String& url, int lineNumber) 194cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 195e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createEvaluateScriptData(url, lineNumber), EvaluateScriptTimelineRecordType); 196cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 197cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 198643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockvoid InspectorTimelineAgent::didEvaluateScript() 199cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 200643ca7872b450ea4efacab6188849e5aac2ba161Steve Block didCompleteCurrentRecord(EvaluateScriptTimelineRecordType); 201643ca7872b450ea4efacab6188849e5aac2ba161Steve Block} 202643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 2036c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsenvoid InspectorTimelineAgent::didScheduleResourceRequest(const String& url) 2046c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen{ 2056c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen pushGCEventRecords(); 206e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 207f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick record->setObject("data", TimelineRecordFactory::createScheduleResourceRequestData(url)); 208e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("type", ScheduleResourceRequestTimelineRecordType); 209e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), ScheduleResourceRequestTimelineRecordType); 2106c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen} 2116c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen 21265f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdochvoid InspectorTimelineAgent::willSendResourceRequest(unsigned long identifier, const ResourceRequest& request) 213643ca7872b450ea4efacab6188849e5aac2ba161Steve Block{ 214dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 215e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 21665f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(identifier, request)); 217e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("type", ResourceSendRequestTimelineRecordType); 218e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke setHeapSizeStatistic(record.get()); 219e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke m_frontend->addRecordToTimeline(record.release()); 220643ca7872b450ea4efacab6188849e5aac2ba161Steve Block} 221643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 222dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::willReceiveResourceData(unsigned long identifier) 223643ca7872b450ea4efacab6188849e5aac2ba161Steve Block{ 224e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createReceiveResourceData(identifier), ReceiveResourceDataTimelineRecordType); 225dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 226dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 227dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::didReceiveResourceData() 228dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 229dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block didCompleteCurrentRecord(ReceiveResourceDataTimelineRecordType); 230dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 231dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 232dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::willReceiveResourceResponse(unsigned long identifier, const ResourceResponse& response) 233dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 234e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke pushCurrentRecord(TimelineRecordFactory::createResourceReceiveResponseData(identifier, response), ResourceReceiveResponseTimelineRecordType); 235dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 236dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 237dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::didReceiveResourceResponse() 238dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 239dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block didCompleteCurrentRecord(ResourceReceiveResponseTimelineRecordType); 240643ca7872b450ea4efacab6188849e5aac2ba161Steve Block} 241643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 242a94275402997c11dd2e778633dacf4b7e630a35dBen Murdochvoid InspectorTimelineAgent::didFinishLoadingResource(unsigned long identifier, bool didFail, double finishTime) 243643ca7872b450ea4efacab6188849e5aac2ba161Steve Block{ 244dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 245a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch // Sometimes network stack can provide for us exact finish loading time. In the other case we will use currentTime. 246f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 247f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch record->setObject("data", TimelineRecordFactory::createResourceFinishData(identifier, didFail, finishTime * 1000)); 248e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("type", ResourceFinishTimelineRecordType); 249e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke setHeapSizeStatistic(record.get()); 250e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke m_frontend->addRecordToTimeline(record.release()); 251643ca7872b450ea4efacab6188849e5aac2ba161Steve Block} 252643ca7872b450ea4efacab6188849e5aac2ba161Steve Block 253643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockvoid InspectorTimelineAgent::didMarkTimeline(const String& message) 254643ca7872b450ea4efacab6188849e5aac2ba161Steve Block{ 255dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 256e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 257f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick record->setObject("data", TimelineRecordFactory::createMarkTimelineData(message)); 258e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), MarkTimelineRecordType); 259231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 260231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 261dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::didMarkDOMContentEvent() 262dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 263dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 264e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 265e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), MarkDOMContentEventType); 266dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 267dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 268dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockvoid InspectorTimelineAgent::didMarkLoadEvent() 269dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 270dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 271e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 272e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke addRecordToTimeline(record.release(), MarkLoadEventType); 273dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 274dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 275231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid InspectorTimelineAgent::reset() 276231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 277cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block m_recordStack.clear(); 278cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 279cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 280e8b154fd68f9b33be40a3590e58347f353835f5cSteve Blockvoid InspectorTimelineAgent::resetFrontendProxyObject(InspectorFrontend* frontend) 281cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 282cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block ASSERT(frontend); 283cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block reset(); 284cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block m_frontend = frontend; 285231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 286231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 287e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarkevoid InspectorTimelineAgent::addRecordToTimeline(PassRefPtr<InspectorObject> prpRecord, TimelineRecordType type) 288231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 289e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record(prpRecord); 290e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("type", type); 291e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke setHeapSizeStatistic(record.get()); 292cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block if (m_recordStack.isEmpty()) 293e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke m_frontend->addRecordToTimeline(record.release()); 294cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block else { 295cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block TimelineRecordEntry parent = m_recordStack.last(); 296f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick parent.children->pushObject(record.release()); 297cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block } 298cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block} 299231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 300e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarkevoid InspectorTimelineAgent::setHeapSizeStatistic(InspectorObject* record) 301dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block{ 302dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block size_t usedHeapSize = 0; 303dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block size_t totalHeapSize = 0; 304dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block ScriptGCEvent::getHeapSize(usedHeapSize, totalHeapSize); 305e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("usedHeapSize", usedHeapSize); 306e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke record->setNumber("totalHeapSize", totalHeapSize); 307dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block} 308dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 309cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Blockvoid InspectorTimelineAgent::didCompleteCurrentRecord(TimelineRecordType type) 310cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block{ 311643ca7872b450ea4efacab6188849e5aac2ba161Steve Block // An empty stack could merely mean that the timeline agent was turned on in the middle of 312643ca7872b450ea4efacab6188849e5aac2ba161Steve Block // an event. Don't treat as an error. 313643ca7872b450ea4efacab6188849e5aac2ba161Steve Block if (!m_recordStack.isEmpty()) { 314dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 315643ca7872b450ea4efacab6188849e5aac2ba161Steve Block TimelineRecordEntry entry = m_recordStack.last(); 316643ca7872b450ea4efacab6188849e5aac2ba161Steve Block m_recordStack.removeLast(); 317643ca7872b450ea4efacab6188849e5aac2ba161Steve Block ASSERT(entry.type == type); 318f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick entry.record->setObject("data", entry.data); 319f486d19d62f1bc33246748b14b14a9dfa617b57fIain Merrick entry.record->setArray("children", entry.children); 320e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke entry.record->setNumber("endTime", WTF::currentTimeMS()); 321643ca7872b450ea4efacab6188849e5aac2ba161Steve Block addRecordToTimeline(entry.record, type); 322643ca7872b450ea4efacab6188849e5aac2ba161Steve Block } 323231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 324231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 325e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarkevoid InspectorTimelineAgent::pushCurrentRecord(PassRefPtr<InspectorObject> data, TimelineRecordType type) 326231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 327dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block pushGCEventRecords(); 328e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 329e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke m_recordStack.append(TimelineRecordEntry(record.release(), data, InspectorArray::create(), type)); 330231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 331231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} // namespace WebCore 332231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 333231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#endif // ENABLE(INSPECTOR) 334