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