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#ifndef InspectorTimelineAgent_h 32231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#define InspectorTimelineAgent_h 33231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 34bac5ab03db021eac2dd5b0043251c60be9d2723eNicolas Roard#if ENABLE(INSPECTOR) 35bac5ab03db021eac2dd5b0043251c60be9d2723eNicolas Roard 3681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch#include "InspectorFrontend.h" 37e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke#include "InspectorValues.h" 38dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "ScriptGCEvent.h" 39dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block#include "ScriptGCEventListener.h" 402fc2651226baac27029e38c9d6ef883fa32084dbSteve Block#include <wtf/PassOwnPtr.h> 41cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block#include <wtf/Vector.h> 42231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 43231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blocknamespace WebCore { 44dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockclass Event; 45e8b154fd68f9b33be40a3590e58347f353835f5cSteve Blockclass InspectorFrontend; 462fc2651226baac27029e38c9d6ef883fa32084dbSteve Blockclass InspectorState; 4781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochclass InstrumentingAgents; 48dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockclass IntRect; 49dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockclass ResourceRequest; 50dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockclass ResourceResponse; 51dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 5281bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdochtypedef String ErrorString; 5381bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 54ab9e7a118cf1ea2e3a93dce683b2ded3e7291ddbBen Murdochclass InspectorTimelineAgent : ScriptGCEventListener { 552fc2651226baac27029e38c9d6ef883fa32084dbSteve Block WTF_MAKE_NONCOPYABLE(InspectorTimelineAgent); 56dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockpublic: 5781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch static PassOwnPtr<InspectorTimelineAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* state) 582fc2651226baac27029e38c9d6ef883fa32084dbSteve Block { 5981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch return adoptPtr(new InspectorTimelineAgent(instrumentingAgents, state)); 602fc2651226baac27029e38c9d6ef883fa32084dbSteve Block } 612fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 62dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block ~InspectorTimelineAgent(); 63dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 6481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void setFrontend(InspectorFrontend*); 6581bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void clearFrontend(); 6681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void restore(); 6781bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 6881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void start(ErrorString* error); 6981bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void stop(ErrorString* error); 7081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch bool started() const; 7181bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch 72a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch int id() const { return m_id; } 73a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 742fc2651226baac27029e38c9d6ef883fa32084dbSteve Block void didCommitLoad(); 75dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 76dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block // Methods called from WebCore. 77dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willCallFunction(const String& scriptName, int scriptLine); 78dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didCallFunction(); 79dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 80dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willDispatchEvent(const Event&); 81dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didDispatchEvent(); 82dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 83dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willLayout(); 84dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didLayout(); 85dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 86dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willRecalculateStyle(); 87dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didRecalculateStyle(); 88dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 89dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willPaint(const IntRect&); 90dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didPaint(); 91dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 92545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch // FIXME: |length| should be passed in didWrite instead willWrite 93545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch // as the parser can not know how much it will process until it tries. 94dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willWriteHTML(unsigned int length, unsigned int startLine); 95dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didWriteHTML(unsigned int endLine); 96545e470e52f0ac6a3a072bf559c796b42c6066b6Ben Murdoch 97dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didInstallTimer(int timerId, int timeout, bool singleShot); 98dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didRemoveTimer(int timerId); 99dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willFireTimer(int timerId); 100dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didFireTimer(); 101dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 102dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willChangeXHRReadyState(const String&, int); 103dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didChangeXHRReadyState(); 104dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willLoadXHR(const String&); 105dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didLoadXHR(); 106dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 107dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willEvaluateScript(const String&, int); 108dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didEvaluateScript(); 109dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 110dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didMarkTimeline(const String&); 111dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didMarkDOMContentEvent(); 112dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didMarkLoadEvent(); 113dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 1146c2af9490927c3c5959b5cb07461b646f8b32f6cKristian Monsen void didScheduleResourceRequest(const String& url); 11565f03d4f644ce73618e5f4f50dd694b26f55ae12Ben Murdoch void willSendResourceRequest(unsigned long, const ResourceRequest&); 116dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willReceiveResourceResponse(unsigned long, const ResourceResponse&); 117dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didReceiveResourceResponse(); 118a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch void didFinishLoadingResource(unsigned long, bool didFail, double finishTime); 119dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void willReceiveResourceData(unsigned long identifier); 120dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void didReceiveResourceData(); 121cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 122dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block virtual void didGC(double, double, size_t); 123dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 124dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Blockprivate: 125dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block struct TimelineRecordEntry { 1262bde8e466a4451c7319e3a072d118917957d6554Steve Block TimelineRecordEntry(PassRefPtr<InspectorObject> record, PassRefPtr<InspectorObject> data, PassRefPtr<InspectorArray> children, const String& type) 127dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block : record(record), data(data), children(children), type(type) 128dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block { 129dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block } 130e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> record; 131e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorObject> data; 132e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke RefPtr<InspectorArray> children; 1332bde8e466a4451c7319e3a072d118917957d6554Steve Block String type; 134dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block }; 135cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 13681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch InspectorTimelineAgent(InstrumentingAgents*, InspectorState*); 1372fc2651226baac27029e38c9d6ef883fa32084dbSteve Block 1382bde8e466a4451c7319e3a072d118917957d6554Steve Block void pushCurrentRecord(PassRefPtr<InspectorObject>, const String& type); 139e458d70a0d18538346f41b503114c9ebe6b2ce12Leon Clarke void setHeapSizeStatistic(InspectorObject* record); 140cac0f67c402d107cdb10971b95719e2ff9c7c76bSteve Block 1412bde8e466a4451c7319e3a072d118917957d6554Steve Block void didCompleteCurrentRecord(const String& type); 142231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 1432bde8e466a4451c7319e3a072d118917957d6554Steve Block void addRecordToTimeline(PassRefPtr<InspectorObject>, const String& type); 144d0825bca7fe65beaee391d30da42e937db621564Steve Block 145dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block void pushGCEventRecords(); 14681bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch void clearRecordStack(); 147231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 14881bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch InstrumentingAgents* m_instrumentingAgents; 1492fc2651226baac27029e38c9d6ef883fa32084dbSteve Block InspectorState* m_state; 15081bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch InspectorFrontend::Timeline* m_frontend; 151dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block 152dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block Vector<TimelineRecordEntry> m_recordStack; 153a94275402997c11dd2e778633dacf4b7e630a35dBen Murdoch 15481bc750723a18f21cd17d1b173cd2a4dda9cea6eBen Murdoch int m_id; 155dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block struct GCEvent { 156dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block GCEvent(double startTime, double endTime, size_t collectedBytes) 157dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block : startTime(startTime), endTime(endTime), collectedBytes(collectedBytes) 158dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block { 159dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block } 160dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block double startTime; 161dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block double endTime; 162dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block size_t collectedBytes; 163231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block }; 164dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block typedef Vector<GCEvent> GCEvents; 165dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block GCEvents m_gcEvents; 166dcc8cf2e65d1aa555cce12431a16547e66b469eeSteve Block}; 167231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 168231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} // namespace WebCore 169231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 170bac5ab03db021eac2dd5b0043251c60be9d2723eNicolas Roard#endif // !ENABLE(INSPECTOR) 171231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#endif // !defined(InspectorTimelineAgent_h) 172