Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / inspector / TimelineRecordFactory.h
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 "core/InspectorTypeBuilder.h"
35 #include "platform/JSONValues.h"
36 #include "platform/weborigin/KURL.h"
37 #include "wtf/Forward.h"
38 #include "wtf/text/WTFString.h"
39
40 namespace blink {
41
42 class Event;
43 class FloatQuad;
44 class ResourceRequest;
45 class ResourceResponse;
46
47 class TimelineRecordFactory {
48 public:
49     static PassRefPtr<TypeBuilder::Timeline::TimelineEvent> createGenericRecord(double startTime, int maxCallStackDepth, const String& type, PassRefPtr<JSONObject> data);
50     static PassRefPtr<TypeBuilder::Timeline::TimelineEvent> createBackgroundRecord(double startTime, const String& thread, const String& type, PassRefPtr<JSONObject> data);
51
52     static PassRefPtr<JSONObject> createGCEventData(size_t usedHeapSizeDelta);
53     static PassRefPtr<JSONObject> createFunctionCallData(int scriptId, const String& scriptName, int scriptLine);
54     static PassRefPtr<JSONObject> createEventDispatchData(const Event&);
55     static PassRefPtr<JSONObject> createGenericTimerData(int timerId);
56     static PassRefPtr<JSONObject> createTimerInstallData(int timerId, int timeout, bool singleShot);
57     static PassRefPtr<JSONObject> createXHRReadyStateChangeData(const String& url, int readyState);
58     static PassRefPtr<JSONObject> createXHRLoadData(const String& url);
59     static PassRefPtr<JSONObject> createEvaluateScriptData(const String&, double lineNumber);
60     static PassRefPtr<JSONObject> createConsoleTimeData(const String&);
61     static PassRefPtr<JSONObject> createTimeStampData(const String&);
62     static PassRefPtr<JSONObject> createResourceSendRequestData(const String& requestId, const ResourceRequest&);
63     static PassRefPtr<JSONObject> createResourceReceiveResponseData(const String& requestId, const ResourceResponse&);
64     static PassRefPtr<JSONObject> createReceiveResourceData(const String& requestId, int length);
65     static PassRefPtr<JSONObject> createResourceFinishData(const String& requestId, bool didFail, double finishTime);
66     static PassRefPtr<JSONObject> createLayoutData(unsigned dirtyObjects, unsigned totalObjects, bool partialLayout);
67     static PassRefPtr<JSONObject> createDecodeImageData(const String& imageType);
68     static PassRefPtr<JSONObject> createResizeImageData(bool shouldCache);
69     static PassRefPtr<JSONObject> createMarkData(bool isMainFrame);
70     static PassRefPtr<JSONObject> createParseHTMLData(unsigned startLine);
71     static PassRefPtr<JSONObject> createAnimationFrameData(int callbackId);
72     static PassRefPtr<JSONObject> createNodeData(long long nodeId);
73     static PassRefPtr<JSONObject> createLayerData(long long layerRootNodeId);
74     static PassRefPtr<JSONObject> createFrameData(int frameId);
75     static PassRefPtr<JSONObject> createGPUTaskData(bool foreign);
76
77     static void setNodeData(JSONObject* data, long long nodeId);
78     static void setLayerData(JSONObject* data, long long layerRootNodeId);
79     static void setLayerTreeData(JSONObject* data, PassRefPtr<JSONValue> layerTree);
80     static void setPaintData(JSONObject* data, const FloatQuad&, long long layerRootNodeId, int graphicsLayerId);
81     static void setLayoutRoot(JSONObject* data, const FloatQuad&, long long rootNodeId);
82     static void setStyleRecalcDetails(JSONObject* data, unsigned elementCount);
83     static void setImageDetails(JSONObject* data, long long imageElementId, const String& url);
84
85     static inline PassRefPtr<JSONObject> createWebSocketCreateData(unsigned long identifier, const KURL& url, const String& protocol)
86     {
87         RefPtr<JSONObject> data = JSONObject::create();
88         data->setNumber("identifier", identifier);
89         data->setString("url", url.string());
90         if (!protocol.isNull())
91             data->setString("webSocketProtocol", protocol);
92         return data.release();
93     }
94
95     static inline PassRefPtr<JSONObject> createGenericWebSocketData(unsigned long identifier)
96     {
97         RefPtr<JSONObject> data = JSONObject::create();
98         data->setNumber("identifier", identifier);
99         return data.release();
100     }
101
102     static PassRefPtr<JSONObject> createEmbedderCallbackData(const String& callbackName);
103
104     static String type(TypeBuilder::Timeline::TimelineEvent*);
105 private:
106     TimelineRecordFactory() { }
107 };
108
109 } // namespace blink
110
111 #endif // !defined(TimelineRecordFactory_h)