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