OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/inspector/InspectorTraceEvents.h" | 6 #include "core/inspector/InspectorTraceEvents.h" |
7 | 7 |
8 #include "bindings/v8/ScriptCallStackFactory.h" | 8 #include "bindings/v8/ScriptCallStackFactory.h" |
9 #include "bindings/v8/ScriptGCEvent.h" | 9 #include "bindings/v8/ScriptGCEvent.h" |
10 #include "bindings/v8/ScriptSourceCode.h" | 10 #include "bindings/v8/ScriptSourceCode.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "platform/weborigin/KURL.h" | 25 #include "platform/weborigin/KURL.h" |
26 #include "wtf/Vector.h" | 26 #include "wtf/Vector.h" |
27 #include <inttypes.h> | 27 #include <inttypes.h> |
28 | 28 |
29 namespace WebCore { | 29 namespace WebCore { |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 class JSCallStack : public TraceEvent::ConvertableToTraceFormat { | 33 class JSCallStack : public TraceEvent::ConvertableToTraceFormat { |
34 public: | 34 public: |
35 explicit JSCallStack(PassRefPtrWillBeRawPtr<ScriptCallStack> callstack) : m_
callstack(callstack) { } | 35 explicit JSCallStack(PassRefPtrWillBeRawPtr<ScriptCallStack> callstack) |
| 36 { |
| 37 m_serialized = callstack ? callstack->buildInspectorArray()->toJSONStrin
g() : "null"; |
| 38 ASSERT(m_serialized.isSafeToSendToAnotherThread()); |
| 39 } |
36 virtual String asTraceFormat() const | 40 virtual String asTraceFormat() const |
37 { | 41 { |
38 if (!m_callstack) | 42 return m_serialized; |
39 return "null"; | |
40 return m_callstack->buildInspectorArray()->toJSONString(); | |
41 } | 43 } |
42 | 44 |
43 private: | 45 private: |
44 RefPtrWillBePersistent<ScriptCallStack> m_callstack; | 46 String m_serialized; |
45 }; | 47 }; |
46 | 48 |
47 String toHexString(void* p) | 49 String toHexString(void* p) |
48 { | 50 { |
49 return String::format("0x%" PRIx64, static_cast<uint64>(reinterpret_cast<int
ptr_t>(p))); | 51 return String::format("0x%" PRIx64, static_cast<uint64>(reinterpret_cast<int
ptr_t>(p))); |
50 } | 52 } |
51 | 53 |
52 } | 54 } |
53 | 55 |
54 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::beginData
(FrameView* frameView) | 56 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::beginData
(FrameView* frameView) |
55 { | 57 { |
56 bool isPartial; | 58 bool isPartial; |
57 unsigned needsLayoutObjects; | 59 unsigned needsLayoutObjects; |
58 unsigned totalObjects; | 60 unsigned totalObjects; |
59 LocalFrame& frame = frameView->frame(); | 61 LocalFrame& frame = frameView->frame(); |
60 frame.countObjectsNeedingLayout(needsLayoutObjects, totalObjects, isPartial)
; | 62 frame.countObjectsNeedingLayout(needsLayoutObjects, totalObjects, isPartial)
; |
61 | 63 |
62 RefPtr<JSONObject> data = JSONObject::create(); | 64 TracedValue value; |
63 data->setNumber("dirtyObjects", needsLayoutObjects); | 65 return value.setInteger("dirtyObjects", needsLayoutObjects) |
64 data->setNumber("totalObjects", totalObjects); | 66 .setInteger("totalObjects", totalObjects) |
65 data->setBoolean("partialLayout", isPartial); | 67 .setBoolean("partialLayout", isPartial) |
66 data->setString("frame", toHexString(&frame)); | 68 .setString("frame", toHexString(&frame)) |
67 return TracedValue::fromJSONValue(data); | 69 .finish(); |
68 } | 70 } |
69 | 71 |
70 static PassRefPtr<JSONArray> createQuad(const FloatQuad& quad) | 72 static void createQuad(TracedValue& value, const char* name, const FloatQuad& qu
ad) |
71 { | 73 { |
72 RefPtr<JSONArray> array = JSONArray::create(); | 74 value.beginArray(name) |
73 array->pushNumber(quad.p1().x()); | 75 .pushDouble(quad.p1().x()) |
74 array->pushNumber(quad.p1().y()); | 76 .pushDouble(quad.p1().y()) |
75 array->pushNumber(quad.p2().x()); | 77 .pushDouble(quad.p2().x()) |
76 array->pushNumber(quad.p2().y()); | 78 .pushDouble(quad.p2().y()) |
77 array->pushNumber(quad.p3().x()); | 79 .pushDouble(quad.p3().x()) |
78 array->pushNumber(quad.p3().y()); | 80 .pushDouble(quad.p3().y()) |
79 array->pushNumber(quad.p4().x()); | 81 .pushDouble(quad.p4().x()) |
80 array->pushNumber(quad.p4().y()); | 82 .pushDouble(quad.p4().y()) |
81 return array.release(); | 83 .endArray(); |
82 } | 84 } |
83 | 85 |
84 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::endData(R
enderObject* rootForThisLayout) | 86 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::endData(R
enderObject* rootForThisLayout) |
85 { | 87 { |
86 Vector<FloatQuad> quads; | 88 Vector<FloatQuad> quads; |
87 rootForThisLayout->absoluteQuads(quads); | 89 rootForThisLayout->absoluteQuads(quads); |
88 | 90 |
89 RefPtr<JSONObject> data = JSONObject::create(); | 91 TracedValue value; |
90 if (quads.size() >= 1) { | 92 if (quads.size() >= 1) { |
91 data->setArray("root", createQuad(quads[0])); | 93 createQuad(value, "root", quads[0]); |
92 int rootNodeId = InspectorNodeIds::idForNode(rootForThisLayout->generati
ngNode()); | 94 int rootNodeId = InspectorNodeIds::idForNode(rootForThisLayout->generati
ngNode()); |
93 data->setNumber("rootNode", rootNodeId); | 95 value.setInteger("rootNode", rootNodeId); |
94 } else { | 96 } else { |
95 ASSERT_NOT_REACHED(); | 97 ASSERT_NOT_REACHED(); |
96 } | 98 } |
97 return TracedValue::fromJSONValue(data); | 99 return value.finish(); |
98 } | 100 } |
99 | 101 |
100 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorSendRequestEvent::data
(unsigned long identifier, LocalFrame* frame, const ResourceRequest& request) | 102 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorSendRequestEvent::data
(unsigned long identifier, LocalFrame* frame, const ResourceRequest& request) |
101 { | 103 { |
102 String requestId = IdentifiersFactory::requestId(identifier); | 104 String requestId = IdentifiersFactory::requestId(identifier); |
103 | 105 |
104 RefPtr<JSONObject> data = JSONObject::create(); | 106 TracedValue value; |
105 data->setString("requestId", requestId); | 107 return value.setString("requestId", requestId) |
106 data->setString("frame", toHexString(frame)); | 108 .setString("frame", toHexString(frame)) |
107 data->setString("url", request.url().string()); | 109 .setString("url", request.url().string()) |
108 data->setString("requestMethod", request.httpMethod()); | 110 .setString("requestMethod", request.httpMethod()) |
109 return TracedValue::fromJSONValue(data); | 111 .finish(); |
110 } | 112 } |
111 | 113 |
112 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorReceiveResponseEvent::
data(unsigned long identifier, LocalFrame* frame, const ResourceResponse& respon
se) | 114 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorReceiveResponseEvent::
data(unsigned long identifier, LocalFrame* frame, const ResourceResponse& respon
se) |
113 { | 115 { |
114 String requestId = IdentifiersFactory::requestId(identifier); | 116 String requestId = IdentifiersFactory::requestId(identifier); |
115 | 117 |
116 RefPtr<JSONObject> data = JSONObject::create(); | 118 TracedValue value; |
117 data->setString("requestId", requestId); | 119 return value.setString("requestId", requestId) |
118 data->setString("frame", toHexString(frame)); | 120 .setString("frame", toHexString(frame)) |
119 data->setNumber("statusCode", response.httpStatusCode()); | 121 .setInteger("statusCode", response.httpStatusCode()) |
120 data->setString("mimeType", response.mimeType().string().isolatedCopy()); | 122 .setString("mimeType", response.mimeType().string().isolatedCopy()) |
121 return TracedValue::fromJSONValue(data); | 123 .finish(); |
122 } | 124 } |
123 | 125 |
124 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorReceiveDataEvent::data
(unsigned long identifier, LocalFrame* frame, int encodedDataLength) | 126 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorReceiveDataEvent::data
(unsigned long identifier, LocalFrame* frame, int encodedDataLength) |
125 { | 127 { |
126 String requestId = IdentifiersFactory::requestId(identifier); | 128 String requestId = IdentifiersFactory::requestId(identifier); |
127 | 129 |
128 RefPtr<JSONObject> data = JSONObject::create(); | 130 TracedValue value; |
129 data->setString("requestId", requestId); | 131 return value.setString("requestId", requestId) |
130 data->setString("frame", toHexString(frame)); | 132 .setString("frame", toHexString(frame)) |
131 data->setNumber("encodedDataLength", encodedDataLength); | 133 .setInteger("encodedDataLength", encodedDataLength) |
132 return TracedValue::fromJSONValue(data); | 134 .finish(); |
133 } | 135 } |
134 | 136 |
135 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorResourceFinishEvent::d
ata(unsigned long identifier, double finishTime, bool didFail) | 137 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorResourceFinishEvent::d
ata(unsigned long identifier, double finishTime, bool didFail) |
136 { | 138 { |
137 String requestId = IdentifiersFactory::requestId(identifier); | 139 String requestId = IdentifiersFactory::requestId(identifier); |
138 | 140 |
139 RefPtr<JSONObject> data = JSONObject::create(); | 141 TracedValue value; |
140 data->setString("requestId", requestId); | 142 value.setString("requestId", requestId); |
141 data->setBoolean("didFail", didFail); | 143 value.setBoolean("didFail", didFail); |
142 if (finishTime) | 144 if (finishTime) |
143 data->setNumber("networkTime", finishTime); | 145 value.setDouble("networkTime", finishTime); |
144 return TracedValue::fromJSONValue(data); | 146 return value.finish(); |
145 } | 147 } |
146 | 148 |
147 static LocalFrame* frameForExecutionContext(ExecutionContext* context) | 149 static LocalFrame* frameForExecutionContext(ExecutionContext* context) |
148 { | 150 { |
149 LocalFrame* frame = 0; | 151 LocalFrame* frame = 0; |
150 if (context->isDocument()) | 152 if (context->isDocument()) |
151 frame = toDocument(context)->frame(); | 153 frame = toDocument(context)->frame(); |
152 return frame; | 154 return frame; |
153 } | 155 } |
154 | 156 |
155 static PassRefPtr<JSONObject> genericTimerData(ExecutionContext* context, int ti
merId) | 157 static PassOwnPtr<TracedValue> genericTimerData(ExecutionContext* context, int t
imerId) |
156 { | 158 { |
157 RefPtr<JSONObject> data = JSONObject::create(); | 159 OwnPtr<TracedValue> value = adoptPtr(new TracedValue()); |
158 data->setNumber("timerId", timerId); | 160 value->setInteger("timerId", timerId); |
159 if (LocalFrame* frame = frameForExecutionContext(context)) | 161 if (LocalFrame* frame = frameForExecutionContext(context)) |
160 data->setString("frame", toHexString(frame)); | 162 value->setString("frame", toHexString(frame)); |
161 return data.release(); | 163 return value.release(); |
162 } | 164 } |
163 | 165 |
164 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTimerInstallEvent::dat
a(ExecutionContext* context, int timerId, int timeout, bool singleShot) | 166 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTimerInstallEvent::dat
a(ExecutionContext* context, int timerId, int timeout, bool singleShot) |
165 { | 167 { |
166 RefPtr<JSONObject> data = genericTimerData(context, timerId); | 168 OwnPtr<TracedValue> value = genericTimerData(context, timerId); |
167 data->setNumber("timeout", timeout); | 169 value->setInteger("timeout", timeout); |
168 data->setBoolean("singleShot", singleShot); | 170 value->setBoolean("singleShot", singleShot); |
169 return TracedValue::fromJSONValue(data); | 171 return value->finish(); |
170 } | 172 } |
171 | 173 |
172 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTimerRemoveEvent::data
(ExecutionContext* context, int timerId) | 174 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTimerRemoveEvent::data
(ExecutionContext* context, int timerId) |
173 { | 175 { |
174 return TracedValue::fromJSONValue(genericTimerData(context, timerId)); | 176 return genericTimerData(context, timerId)->finish(); |
175 } | 177 } |
176 | 178 |
177 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTimerFireEvent::data(E
xecutionContext* context, int timerId) | 179 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTimerFireEvent::data(E
xecutionContext* context, int timerId) |
178 { | 180 { |
179 return TracedValue::fromJSONValue(genericTimerData(context, timerId)); | 181 return genericTimerData(context, timerId)->finish(); |
180 } | 182 } |
181 | 183 |
182 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorAnimationFrameEvent::d
ata(Document* document, int callbackId) | 184 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorAnimationFrameEvent::d
ata(Document* document, int callbackId) |
183 { | 185 { |
184 RefPtr<JSONObject> data = JSONObject::create(); | 186 TracedValue value; |
185 data->setNumber("id", callbackId); | 187 return value.setInteger("id", callbackId) |
186 data->setString("frame", toHexString(document->frame())); | 188 .setString("frame", toHexString(document->frame())) |
187 return TracedValue::fromJSONValue(data); | 189 .finish(); |
188 } | 190 } |
189 | 191 |
190 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorWebSocketCreateEvent::
data(Document* document, unsigned long identifier, const KURL& url, const String
& protocol) | 192 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorWebSocketCreateEvent::
data(Document* document, unsigned long identifier, const KURL& url, const String
& protocol) |
191 { | 193 { |
192 RefPtr<JSONObject> data = JSONObject::create(); | 194 TracedValue value; |
193 data->setNumber("identifier", identifier); | 195 value.setInteger("identifier", identifier); |
194 data->setString("url", url.string()); | 196 value.setString("url", url.string()); |
195 data->setString("frame", toHexString(document->frame())); | 197 value.setString("frame", toHexString(document->frame())); |
196 if (!protocol.isNull()) | 198 if (!protocol.isNull()) |
197 data->setString("webSocketProtocol", protocol); | 199 value.setString("webSocketProtocol", protocol); |
198 return TracedValue::fromJSONValue(data); | 200 return value.finish(); |
199 } | 201 } |
200 | 202 |
201 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorWebSocketEvent::data(D
ocument* document, unsigned long identifier) | 203 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorWebSocketEvent::data(D
ocument* document, unsigned long identifier) |
202 { | 204 { |
203 RefPtr<JSONObject> data = JSONObject::create(); | 205 TracedValue value; |
204 data->setNumber("identifier", identifier); | 206 value.setInteger("identifier", identifier); |
205 data->setString("frame", toHexString(document->frame())); | 207 value.setString("frame", toHexString(document->frame())); |
206 return TracedValue::fromJSONValue(data); | 208 return value.finish(); |
207 } | 209 } |
208 | 210 |
209 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorParseHtmlEvent::beginD
ata(Document* document, unsigned startLine) | 211 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorParseHtmlEvent::beginD
ata(Document* document, unsigned startLine) |
210 { | 212 { |
211 RefPtr<JSONObject> data = JSONObject::create(); | 213 TracedValue value; |
212 data->setNumber("startLine", startLine); | 214 value.setInteger("startLine", startLine); |
213 data->setString("frame", toHexString(document->frame())); | 215 value.setString("frame", toHexString(document->frame())); |
214 return TracedValue::fromJSONValue(data); | 216 return value.finish(); |
215 } | 217 } |
216 | 218 |
217 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorXhrReadyStateChangeEve
nt::data(ExecutionContext* context, XMLHttpRequest* request) | 219 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorXhrReadyStateChangeEve
nt::data(ExecutionContext* context, XMLHttpRequest* request) |
218 { | 220 { |
219 RefPtr<JSONObject> data = JSONObject::create(); | 221 TracedValue value; |
220 data->setString("url", request->url().string()); | 222 value.setString("url", request->url().string()); |
221 data->setNumber("readyState", request->readyState()); | 223 value.setInteger("readyState", request->readyState()); |
222 if (LocalFrame* frame = frameForExecutionContext(context)) | 224 if (LocalFrame* frame = frameForExecutionContext(context)) |
223 data->setString("frame", toHexString(frame)); | 225 value.setString("frame", toHexString(frame)); |
224 return TracedValue::fromJSONValue(data); | 226 return value.finish(); |
225 } | 227 } |
226 | 228 |
227 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorXhrLoadEvent::data(Exe
cutionContext* context, XMLHttpRequest* request) | 229 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorXhrLoadEvent::data(Exe
cutionContext* context, XMLHttpRequest* request) |
228 { | 230 { |
229 RefPtr<JSONObject> data = JSONObject::create(); | 231 TracedValue value; |
230 data->setString("url", request->url().string()); | 232 value.setString("url", request->url().string()); |
231 if (LocalFrame* frame = frameForExecutionContext(context)) | 233 if (LocalFrame* frame = frameForExecutionContext(context)) |
232 data->setString("frame", toHexString(frame)); | 234 value.setString("frame", toHexString(frame)); |
233 return TracedValue::fromJSONValue(data); | 235 return value.finish(); |
234 } | 236 } |
235 | 237 |
236 static void localToPageQuad(const RenderObject& renderer, const LayoutRect& rect
, FloatQuad* quad) | 238 static void localToPageQuad(const RenderObject& renderer, const LayoutRect& rect
, FloatQuad* quad) |
237 { | 239 { |
238 LocalFrame* frame = renderer.frame(); | 240 LocalFrame* frame = renderer.frame(); |
239 FrameView* view = frame->view(); | 241 FrameView* view = frame->view(); |
240 FloatQuad absolute = renderer.localToAbsoluteQuad(FloatQuad(rect)); | 242 FloatQuad absolute = renderer.localToAbsoluteQuad(FloatQuad(rect)); |
241 quad->setP1(view->contentsToRootView(roundedIntPoint(absolute.p1()))); | 243 quad->setP1(view->contentsToRootView(roundedIntPoint(absolute.p1()))); |
242 quad->setP2(view->contentsToRootView(roundedIntPoint(absolute.p2()))); | 244 quad->setP2(view->contentsToRootView(roundedIntPoint(absolute.p2()))); |
243 quad->setP3(view->contentsToRootView(roundedIntPoint(absolute.p3()))); | 245 quad->setP3(view->contentsToRootView(roundedIntPoint(absolute.p3()))); |
244 quad->setP4(view->contentsToRootView(roundedIntPoint(absolute.p4()))); | 246 quad->setP4(view->contentsToRootView(roundedIntPoint(absolute.p4()))); |
245 } | 247 } |
246 | 248 |
247 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorPaintEvent::data(Rende
rObject* renderer, const LayoutRect& clipRect, const GraphicsLayer* graphicsLaye
r) | 249 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorPaintEvent::data(Rende
rObject* renderer, const LayoutRect& clipRect, const GraphicsLayer* graphicsLaye
r) |
248 { | 250 { |
249 RefPtr<JSONObject> data = JSONObject::create(); | 251 TracedValue value; |
250 data->setString("frame", toHexString(renderer->frame())); | 252 value.setString("frame", toHexString(renderer->frame())); |
251 FloatQuad quad; | 253 FloatQuad quad; |
252 localToPageQuad(*renderer, clipRect, &quad); | 254 localToPageQuad(*renderer, clipRect, &quad); |
253 data->setArray("clip", createQuad(quad)); | 255 createQuad(value, "clip", quad); |
254 int nodeId = InspectorNodeIds::idForNode(renderer->generatingNode()); | 256 int nodeId = InspectorNodeIds::idForNode(renderer->generatingNode()); |
255 data->setNumber("nodeId", nodeId); | 257 value.setInteger("nodeId", nodeId); |
256 int graphicsLayerId = graphicsLayer ? graphicsLayer->platformLayer()->id() :
0; | 258 int graphicsLayerId = graphicsLayer ? graphicsLayer->platformLayer()->id() :
0; |
257 data->setNumber("layerId", graphicsLayerId); | 259 value.setInteger("layerId", graphicsLayerId); |
258 return TracedValue::fromJSONValue(data); | 260 return value.finish(); |
259 } | 261 } |
260 | 262 |
261 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorMarkLoadEvent::data(Lo
calFrame* frame) | 263 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorMarkLoadEvent::data(Lo
calFrame* frame) |
262 { | 264 { |
263 RefPtr<JSONObject> data = JSONObject::create(); | 265 TracedValue value; |
264 data->setString("frame", toHexString(frame)); | 266 value.setString("frame", toHexString(frame)); |
265 bool isMainFrame = frame && frame->page()->mainFrame() == frame; | 267 bool isMainFrame = frame && frame->page()->mainFrame() == frame; |
266 data->setBoolean("isMainFrame", isMainFrame); | 268 value.setBoolean("isMainFrame", isMainFrame); |
267 return TracedValue::fromJSONValue(data); | 269 return value.finish(); |
268 } | 270 } |
269 | 271 |
270 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorScrollLayerEvent::data
(RenderObject* renderer) | 272 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorScrollLayerEvent::data
(RenderObject* renderer) |
271 { | 273 { |
272 RefPtr<JSONObject> data = JSONObject::create(); | 274 TracedValue value; |
273 data->setString("frame", toHexString(renderer->frame())); | 275 value.setString("frame", toHexString(renderer->frame())); |
274 int nodeId = InspectorNodeIds::idForNode(renderer->generatingNode()); | 276 int nodeId = InspectorNodeIds::idForNode(renderer->generatingNode()); |
275 data->setNumber("nodeId", nodeId); | 277 value.setInteger("nodeId", nodeId); |
276 return TracedValue::fromJSONValue(data); | 278 return value.finish(); |
277 } | 279 } |
278 | 280 |
279 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorEvaluateScriptEvent::d
ata(LocalFrame* frame, const String& url, int lineNumber) | 281 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorEvaluateScriptEvent::d
ata(LocalFrame* frame, const String& url, int lineNumber) |
280 { | 282 { |
281 RefPtr<JSONObject> data = JSONObject::create(); | 283 TracedValue value; |
282 data->setString("frame", toHexString(frame)); | 284 value.setString("frame", toHexString(frame)); |
283 data->setString("url", url); | 285 value.setString("url", url); |
284 data->setNumber("lineNumber", lineNumber); | 286 value.setInteger("lineNumber", lineNumber); |
285 return TracedValue::fromJSONValue(data); | 287 return value.finish(); |
286 } | 288 } |
287 | 289 |
288 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorFunctionCallEvent::dat
a(ExecutionContext* context, int scriptId, const String& scriptName, int scriptL
ine) | 290 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorFunctionCallEvent::dat
a(ExecutionContext* context, int scriptId, const String& scriptName, int scriptL
ine) |
289 { | 291 { |
290 RefPtr<JSONObject> data = JSONObject::create(); | 292 TracedValue value; |
291 data->setString("scriptId", String::number(scriptId)); | 293 value.setString("scriptId", String::number(scriptId)); |
292 data->setString("scriptName", scriptName); | 294 value.setString("scriptName", scriptName); |
293 data->setNumber("scriptLine", scriptLine); | 295 value.setInteger("scriptLine", scriptLine); |
294 if (LocalFrame* frame = frameForExecutionContext(context)) | 296 if (LocalFrame* frame = frameForExecutionContext(context)) |
295 data->setString("frame", toHexString(frame)); | 297 value.setString("frame", toHexString(frame)); |
296 return TracedValue::fromJSONValue(data); | 298 return value.finish(); |
297 } | 299 } |
298 | 300 |
299 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorPaintImageEvent::data(
const RenderImage& renderImage) | 301 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorPaintImageEvent::data(
const RenderImage& renderImage) |
300 { | 302 { |
301 RefPtr<JSONObject> data = JSONObject::create(); | 303 TracedValue value; |
302 data->setNumber("nodeId", InspectorNodeIds::idForNode(renderImage.generating
Node())); | 304 value.setInteger("nodeId", InspectorNodeIds::idForNode(renderImage.generatin
gNode())); |
303 | |
304 if (const ImageResource* resource = renderImage.cachedImage()) | 305 if (const ImageResource* resource = renderImage.cachedImage()) |
305 data->setString("url", resource->url().string()); | 306 value.setString("url", resource->url().string()); |
306 | 307 return value.finish(); |
307 return TracedValue::fromJSONValue(data); | |
308 } | 308 } |
309 | 309 |
310 static size_t usedHeapSize() | 310 static size_t usedHeapSize() |
311 { | 311 { |
312 HeapInfo info; | 312 HeapInfo info; |
313 ScriptGCEvent::getHeapSize(info); | 313 ScriptGCEvent::getHeapSize(info); |
314 return info.usedJSHeapSize; | 314 return info.usedJSHeapSize; |
315 } | 315 } |
316 | 316 |
317 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorUpdateCountersEvent::d
ata() | 317 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorUpdateCountersEvent::d
ata() |
318 { | 318 { |
319 RefPtr<JSONObject> data = JSONObject::create(); | 319 TracedValue value; |
320 if (isMainThread()) { | 320 if (isMainThread()) { |
321 data->setNumber("documents", InspectorCounters::counterValue(InspectorCo
unters::DocumentCounter)); | 321 value.setInteger("documents", InspectorCounters::counterValue(InspectorC
ounters::DocumentCounter)); |
322 data->setNumber("nodes", InspectorCounters::counterValue(InspectorCounte
rs::NodeCounter)); | 322 value.setInteger("nodes", InspectorCounters::counterValue(InspectorCount
ers::NodeCounter)); |
323 data->setNumber("jsEventListeners", InspectorCounters::counterValue(Insp
ectorCounters::JSEventListenerCounter)); | 323 value.setInteger("jsEventListeners", InspectorCounters::counterValue(Ins
pectorCounters::JSEventListenerCounter)); |
324 } | 324 } |
325 data->setNumber("jsHeapSizeUsed", static_cast<double>(usedHeapSize())); | 325 value.setDouble("jsHeapSizeUsed", static_cast<double>(usedHeapSize())); |
326 return TracedValue::fromJSONValue(data); | 326 return value.finish(); |
327 } | 327 } |
328 | 328 |
329 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorCallStackEvent::curren
tCallStack() | 329 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorCallStackEvent::curren
tCallStack() |
330 { | 330 { |
331 return adoptRef(new JSCallStack(createScriptCallStack(ScriptCallStack::maxCa
llStackSizeToCapture, true))); | 331 return adoptRef(new JSCallStack(createScriptCallStack(ScriptCallStack::maxCa
llStackSizeToCapture, true))); |
332 } | 332 } |
333 | 333 |
334 } | 334 } |
OLD | NEW |