1/* 2 * Copyright (C) 2009 Google Inc. All rights reserved. 3 * Copyright (C) 2014 University of Washington. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * * Neither the name of Google Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#ifndef TimelineRecordFactory_h 33#define TimelineRecordFactory_h 34 35#include "URL.h" 36#include <inspector/InspectorValues.h> 37#include <wtf/Forward.h> 38#include <wtf/text/WTFString.h> 39 40namespace JSC { 41class Profile; 42} 43 44namespace Inspector { 45struct ScriptBreakpointAction; 46} 47 48namespace WebCore { 49 50 class Event; 51 class FloatQuad; 52 class ResourceRequest; 53 class ResourceResponse; 54 class ScriptProfile; 55 56 class TimelineRecordFactory { 57 public: 58 static PassRefPtr<Inspector::InspectorObject> createGenericRecord(double startTime, int maxCallStackDepth); 59 static PassRefPtr<Inspector::InspectorObject> createBackgroundRecord(double startTime, const String& thread); 60 61 static PassRefPtr<Inspector::InspectorObject> createGCEventData(const size_t usedHeapSizeDelta); 62 63 static PassRefPtr<Inspector::InspectorObject> createFunctionCallData(const String& scriptName, int scriptLine); 64 static PassRefPtr<Inspector::InspectorObject> createConsoleProfileData(const String& title); 65 66 static PassRefPtr<Inspector::InspectorObject> createProbeSampleData(const Inspector::ScriptBreakpointAction&, int hitCount); 67 68 static PassRefPtr<Inspector::InspectorObject> createEventDispatchData(const Event&); 69 70 static PassRefPtr<Inspector::InspectorObject> createGenericTimerData(int timerId); 71 72 static PassRefPtr<Inspector::InspectorObject> createTimerInstallData(int timerId, int timeout, bool singleShot); 73 74 static PassRefPtr<Inspector::InspectorObject> createXHRReadyStateChangeData(const String& url, int readyState); 75 76 static PassRefPtr<Inspector::InspectorObject> createXHRLoadData(const String& url); 77 78 static PassRefPtr<Inspector::InspectorObject> createEvaluateScriptData(const String&, double lineNumber); 79 80 static PassRefPtr<Inspector::InspectorObject> createTimeStampData(const String&); 81 82 static PassRefPtr<Inspector::InspectorObject> createResourceSendRequestData(const String& requestId, const ResourceRequest&); 83 84 static PassRefPtr<Inspector::InspectorObject> createScheduleResourceRequestData(const String&); 85 86 static PassRefPtr<Inspector::InspectorObject> createResourceReceiveResponseData(const String& requestId, const ResourceResponse&); 87 88 static PassRefPtr<Inspector::InspectorObject> createReceiveResourceData(const String& requestId, int length); 89 90 static PassRefPtr<Inspector::InspectorObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime); 91 92 static PassRefPtr<Inspector::InspectorObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout); 93 94 static PassRefPtr<Inspector::InspectorObject> createDecodeImageData(const String& imageType); 95 96 static PassRefPtr<Inspector::InspectorObject> createResizeImageData(bool shouldCache); 97 98 static PassRefPtr<Inspector::InspectorObject> createMarkData(bool isMainFrame); 99 100 static PassRefPtr<Inspector::InspectorObject> createParseHTMLData(unsigned startLine); 101 102 static PassRefPtr<Inspector::InspectorObject> createAnimationFrameData(int callbackId); 103 104 static PassRefPtr<Inspector::InspectorObject> createPaintData(const FloatQuad&); 105 106 static void appendLayoutRoot(Inspector::InspectorObject* data, const FloatQuad&); 107 108 static void appendProfile(Inspector::InspectorObject*, PassRefPtr<JSC::Profile>); 109 110#if ENABLE(WEB_SOCKETS) 111 static inline PassRefPtr<Inspector::InspectorObject> createWebSocketCreateData(unsigned long identifier, const URL& url, const String& protocol) 112 { 113 RefPtr<Inspector::InspectorObject> data = Inspector::InspectorObject::create(); 114 data->setNumber("identifier", identifier); 115 data->setString("url", url.string()); 116 if (!protocol.isNull()) 117 data->setString("webSocketProtocol", protocol); 118 return data.release(); 119 } 120 121 static inline PassRefPtr<Inspector::InspectorObject> createGenericWebSocketData(unsigned long identifier) 122 { 123 RefPtr<Inspector::InspectorObject> data = Inspector::InspectorObject::create(); 124 data->setNumber("identifier", identifier); 125 return data.release(); 126 } 127#endif 128 private: 129 TimelineRecordFactory() { } 130 }; 131 132} // namespace WebCore 133 134#endif // !defined(TimelineRecordFactory_h) 135