~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/inspector/TimelineRecordFactory.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include "config.h"
 
32
 
 
33
#if ENABLE(INSPECTOR)
 
34
 
 
35
#include "TimelineRecordFactory.h"
 
36
 
 
37
#include "Event.h"
 
38
#include "InspectorValues.h"
 
39
#include "IntRect.h"
 
40
#include "LayoutRect.h"
 
41
#include "ResourceRequest.h"
 
42
#include "ResourceResponse.h"
 
43
#include "ScriptCallStack.h"
 
44
#include "ScriptCallStackFactory.h"
 
45
#include <wtf/CurrentTime.h>
 
46
 
 
47
namespace WebCore {
 
48
 
 
49
PassRefPtr<InspectorObject> TimelineRecordFactory::createGenericRecord(double startTime, int maxCallStackDepth)
 
50
{
 
51
    RefPtr<InspectorObject> record = InspectorObject::create();
 
52
    record->setNumber("startTime", startTime);
 
53
 
 
54
    if (maxCallStackDepth) {
 
55
        RefPtr<ScriptCallStack> stackTrace = createScriptCallStack(maxCallStackDepth, true);
 
56
        if (stackTrace && stackTrace->size())
 
57
            record->setValue("stackTrace", stackTrace->buildInspectorArray());
 
58
    }
 
59
    return record.release();
 
60
}
 
61
 
 
62
PassRefPtr<InspectorObject> TimelineRecordFactory::createGCEventData(const size_t usedHeapSizeDelta)
 
63
{
 
64
    RefPtr<InspectorObject> data = InspectorObject::create();
 
65
    data->setNumber("usedHeapSizeDelta", usedHeapSizeDelta);
 
66
    return data.release();
 
67
}
 
68
 
 
69
PassRefPtr<InspectorObject> TimelineRecordFactory::createFunctionCallData(const String& scriptName, int scriptLine)
 
70
{
 
71
    RefPtr<InspectorObject> data = InspectorObject::create();
 
72
    data->setString("scriptName", scriptName);
 
73
    data->setNumber("scriptLine", scriptLine);
 
74
    return data.release();
 
75
}
 
76
 
 
77
PassRefPtr<InspectorObject> TimelineRecordFactory::createEventDispatchData(const Event& event)
 
78
{
 
79
    RefPtr<InspectorObject> data = InspectorObject::create();
 
80
    data->setString("type", event.type().string());
 
81
    return data.release();
 
82
}
 
83
 
 
84
PassRefPtr<InspectorObject> TimelineRecordFactory::createGenericTimerData(int timerId)
 
85
{
 
86
    RefPtr<InspectorObject> data = InspectorObject::create();
 
87
    data->setNumber("timerId", timerId);
 
88
    return data.release();
 
89
}
 
90
 
 
91
PassRefPtr<InspectorObject> TimelineRecordFactory::createTimerInstallData(int timerId, int timeout, bool singleShot)
 
92
{
 
93
    RefPtr<InspectorObject> data = InspectorObject::create();
 
94
    data->setNumber("timerId", timerId);
 
95
    data->setNumber("timeout", timeout);
 
96
    data->setBoolean("singleShot", singleShot);
 
97
    return data.release();
 
98
}
 
99
 
 
100
PassRefPtr<InspectorObject> TimelineRecordFactory::createXHRReadyStateChangeData(const String& url, int readyState)
 
101
{
 
102
    RefPtr<InspectorObject> data = InspectorObject::create();
 
103
    data->setString("url", url);
 
104
    data->setNumber("readyState", readyState);
 
105
    return data.release();
 
106
}
 
107
 
 
108
PassRefPtr<InspectorObject> TimelineRecordFactory::createXHRLoadData(const String& url)
 
109
{
 
110
    RefPtr<InspectorObject> data = InspectorObject::create();
 
111
    data->setString("url", url);
 
112
    return data.release();
 
113
}
 
114
 
 
115
PassRefPtr<InspectorObject> TimelineRecordFactory::createEvaluateScriptData(const String& url, double lineNumber)
 
116
{
 
117
    RefPtr<InspectorObject> data = InspectorObject::create();
 
118
    data->setString("url", url);
 
119
    data->setNumber("lineNumber", lineNumber);
 
120
    return data.release();
 
121
}
 
122
 
 
123
PassRefPtr<InspectorObject> TimelineRecordFactory::createTimeStampData(const String& message)
 
124
{
 
125
    RefPtr<InspectorObject> data = InspectorObject::create();
 
126
    data->setString("message", message);
 
127
    return data.release();
 
128
}
 
129
 
 
130
PassRefPtr<InspectorObject> TimelineRecordFactory::createScheduleResourceRequestData(const String& url)
 
131
{
 
132
    RefPtr<InspectorObject> data = InspectorObject::create();
 
133
    data->setString("url", url);
 
134
    return data.release();
 
135
}
 
136
 
 
137
PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(const String& requestId, const ResourceRequest& request)
 
138
{
 
139
    RefPtr<InspectorObject> data = InspectorObject::create();
 
140
    data->setString("requestId", requestId);
 
141
    data->setString("url", request.url().string());
 
142
    data->setString("requestMethod", request.httpMethod());
 
143
    return data.release();
 
144
}
 
145
 
 
146
PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceReceiveResponseData(const String& requestId, const ResourceResponse& response)
 
147
{
 
148
    RefPtr<InspectorObject> data = InspectorObject::create();
 
149
    data->setString("requestId", requestId);
 
150
    data->setNumber("statusCode", response.httpStatusCode());
 
151
    data->setString("mimeType", response.mimeType());
 
152
    return data.release();
 
153
}
 
154
 
 
155
PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceFinishData(const String& requestId, bool didFail, double finishTime)
 
156
{
 
157
    RefPtr<InspectorObject> data = InspectorObject::create();
 
158
    data->setString("requestId", requestId);
 
159
    data->setBoolean("didFail", didFail);
 
160
    if (finishTime)
 
161
        data->setNumber("networkTime", finishTime);
 
162
    return data.release();
 
163
}
 
164
 
 
165
PassRefPtr<InspectorObject> TimelineRecordFactory::createReceiveResourceData(const String& requestId, int length)
 
166
{
 
167
    RefPtr<InspectorObject> data = InspectorObject::create();
 
168
    data->setString("requestId", requestId);
 
169
    data->setNumber("encodedDataLength", length);
 
170
    return data.release();
 
171
}
 
172
    
 
173
PassRefPtr<InspectorObject> TimelineRecordFactory::createDecodeImageData(const String& imageType)
 
174
{
 
175
    RefPtr<InspectorObject> data = InspectorObject::create();
 
176
    data->setString("imageType", imageType);
 
177
    return data.release();
 
178
}
 
179
 
 
180
PassRefPtr<InspectorObject> TimelineRecordFactory::createResizeImageData(bool shouldCache)
 
181
{
 
182
    RefPtr<InspectorObject> data = InspectorObject::create();
 
183
    data->setBoolean("cached", shouldCache);
 
184
    return data.release();
 
185
}
 
186
 
 
187
PassRefPtr<InspectorObject> TimelineRecordFactory::createParseHTMLData(unsigned int length, unsigned int startLine)
 
188
{
 
189
    RefPtr<InspectorObject> data = InspectorObject::create();
 
190
    data->setNumber("length", length);
 
191
    data->setNumber("startLine", startLine);
 
192
    return data.release();
 
193
}
 
194
 
 
195
PassRefPtr<InspectorObject> TimelineRecordFactory::createAnimationFrameData(int callbackId)
 
196
{
 
197
    RefPtr<InspectorObject> data = InspectorObject::create();
 
198
    data->setNumber("id", callbackId);
 
199
    return data.release();
 
200
}
 
201
 
 
202
void TimelineRecordFactory::addRectData(InspectorObject* data, const LayoutRect& rect)
 
203
{
 
204
    data->setNumber("x", rect.x());
 
205
    data->setNumber("y", rect.y());
 
206
    data->setNumber("width", rect.width());
 
207
    data->setNumber("height", rect.height());
 
208
}
 
209
 
 
210
} // namespace WebCore
 
211
 
 
212
#endif // ENABLE(INSPECTOR)