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/core/v8/ScriptCallStackFactory.h" | 8 #include "bindings/core/v8/ScriptCallStackFactory.h" |
9 #include "bindings/core/v8/ScriptGCEvent.h" | 9 #include "bindings/core/v8/ScriptGCEvent.h" |
10 #include "bindings/core/v8/ScriptSourceCode.h" | 10 #include "bindings/core/v8/ScriptSourceCode.h" |
11 #include "core/css/invalidation/DescendantInvalidationSet.h" | |
11 #include "core/events/Event.h" | 12 #include "core/events/Event.h" |
12 #include "core/frame/FrameView.h" | 13 #include "core/frame/FrameView.h" |
13 #include "core/frame/LocalFrame.h" | 14 #include "core/frame/LocalFrame.h" |
14 #include "core/inspector/IdentifiersFactory.h" | 15 #include "core/inspector/IdentifiersFactory.h" |
15 #include "core/inspector/InspectorNodeIds.h" | 16 #include "core/inspector/InspectorNodeIds.h" |
16 #include "core/inspector/ScriptCallStack.h" | 17 #include "core/inspector/ScriptCallStack.h" |
17 #include "core/page/Page.h" | 18 #include "core/page/Page.h" |
18 #include "core/rendering/RenderImage.h" | 19 #include "core/rendering/RenderImage.h" |
19 #include "core/rendering/RenderLayer.h" | 20 #include "core/rendering/RenderLayer.h" |
20 #include "core/rendering/RenderObject.h" | 21 #include "core/rendering/RenderObject.h" |
21 #include "core/workers/WorkerThread.h" | 22 #include "core/workers/WorkerThread.h" |
22 #include "core/xml/XMLHttpRequest.h" | 23 #include "core/xml/XMLHttpRequest.h" |
23 #include "platform/JSONValues.h" | 24 #include "platform/JSONValues.h" |
24 #include "platform/TracedValue.h" | 25 #include "platform/TracedValue.h" |
25 #include "platform/graphics/GraphicsLayer.h" | 26 #include "platform/graphics/GraphicsLayer.h" |
26 #include "platform/network/ResourceRequest.h" | 27 #include "platform/network/ResourceRequest.h" |
27 #include "platform/network/ResourceResponse.h" | 28 #include "platform/network/ResourceResponse.h" |
28 #include "platform/weborigin/KURL.h" | 29 #include "platform/weborigin/KURL.h" |
29 #include "wtf/Vector.h" | 30 #include "wtf/Vector.h" |
31 #include "wtf/text/StringBuilder.h" | |
30 #include <inttypes.h> | 32 #include <inttypes.h> |
31 | 33 |
32 namespace blink { | 34 namespace blink { |
33 | 35 |
34 static const unsigned maxInvalidationTrackingCallstackSize = 5; | 36 static const unsigned maxInvalidationTrackingCallstackSize = 5; |
35 | 37 |
36 namespace { | 38 namespace { |
37 | 39 |
38 class JSCallStack : public TraceEvent::ConvertableToTraceFormat { | 40 class JSCallStack : public TraceEvent::ConvertableToTraceFormat { |
39 public: | 41 public: |
40 explicit JSCallStack(PassRefPtrWillBeRawPtr<ScriptCallStack> callstack) | 42 explicit JSCallStack(PassRefPtrWillBeRawPtr<ScriptCallStack> callstack) |
41 { | 43 { |
42 m_serialized = callstack ? callstack->buildInspectorArray()->toJSONStrin g() : "[]"; | 44 m_serialized = callstack ? callstack->buildInspectorArray()->toJSONStrin g() : "[]"; |
43 ASSERT(m_serialized.isSafeToSendToAnotherThread()); | 45 ASSERT(m_serialized.isSafeToSendToAnotherThread()); |
44 } | 46 } |
45 virtual String asTraceFormat() const | 47 virtual String asTraceFormat() const |
46 { | 48 { |
47 return m_serialized; | 49 return m_serialized; |
48 } | 50 } |
49 | 51 |
50 private: | 52 private: |
51 String m_serialized; | 53 String m_serialized; |
52 }; | 54 }; |
53 | 55 |
54 String toHexString(const void* p) | 56 String toHexString(const void* p) |
55 { | 57 { |
56 return String::format("0x%" PRIx64, static_cast<uint64>(reinterpret_cast<int ptr_t>(p))); | 58 return String::format("0x%" PRIx64, static_cast<uint64>(reinterpret_cast<int ptr_t>(p))); |
57 } | 59 } |
58 | 60 |
61 void setNodeInfo(TracedValue* value, Node* node, const char* idFieldName, const char* nameFieldName = 0) | |
62 { | |
63 value->setInteger(idFieldName, InspectorNodeIds::idForNode(node)); | |
64 if (nameFieldName) | |
65 value->setString(nameFieldName, node->debugName()); | |
66 } | |
67 | |
59 } | 68 } |
60 | 69 |
70 const char InspectorStyleInvalidatorInvalidateEvent::ElementHasPendingInvalidati onList[] = "Element has pending invalidation list"; | |
71 const char InspectorStyleInvalidatorInvalidateEvent::InvalidateCustomPseudo[] = "Invalidate custom pseudo element."; | |
72 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedAttri bute[] = "Invalidation set matched attribute."; | |
73 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedClass [] = "Invalidation set matched class."; | |
74 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedId[] = "Invalidation set matched id."; | |
75 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedTagNa me[] = "Invalidation set matched tagName."; | |
76 const char InspectorStyleInvalidatorInvalidateEvent::PreventStyleSharingForParen t[] = "Prevent style sharing for parent."; | |
77 | |
78 PassRefPtr<TracedValue> InspectorStyleInvalidatorInvalidateEvent::fillCommonPart (Element& element, const char* reason) | |
79 { | |
80 RefPtr<TracedValue> value = TracedValue::create(); | |
81 value->setString("frame", toHexString(element.document().frame())); | |
82 setNodeInfo(value.get(), &element, "nodeId", "nodeName"); | |
83 value->setString("reason", reason); | |
84 return value.release(); | |
85 } | |
86 | |
87 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorStyleInvalidatorInvali dateEvent::data(Element& element, const char* reason) | |
88 { | |
89 return fillCommonPart(element, reason); | |
90 } | |
91 | |
92 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorStyleInvalidatorInvali dateEvent::selectorPart(Element& element, const char* reason, const String& sele ctorPart) | |
93 { | |
94 RefPtr<TracedValue> value = fillCommonPart(element, reason); | |
95 value->beginArray("selectorParts"); | |
96 value->pushString(selectorPart); | |
caseq
2014/10/01 07:50:50
So selectorParts contents is either a string (here
kouhei (in TOK)
2014/10/02 02:16:46
I changed this to use different key for each.
| |
97 value->endArray(); | |
98 return value.release(); | |
99 } | |
100 | |
101 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorStyleInvalidatorInvali dateEvent::invalidationList(Element& element, const WillBeHeapVector<RefPtrWillB eMember<DescendantInvalidationSet> >& invalidationList) | |
102 { | |
103 RefPtr<TracedValue> value = fillCommonPart(element, ElementHasPendingInvalid ationList); | |
104 value->beginArray("selectorParts"); | |
105 for (const auto& invalidationSet : invalidationList) { | |
caseq
2014/10/01 07:50:50
nit: redundant {}
kouhei (in TOK)
2014/10/02 02:16:46
Done.
| |
106 invalidationSet->toTracedValue(value.get()); | |
107 } | |
108 value->endArray(); | |
109 return value.release(); | |
110 } | |
111 | |
61 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::beginData (FrameView* frameView) | 112 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::beginData (FrameView* frameView) |
62 { | 113 { |
63 bool isPartial; | 114 bool isPartial; |
64 unsigned needsLayoutObjects; | 115 unsigned needsLayoutObjects; |
65 unsigned totalObjects; | 116 unsigned totalObjects; |
66 LocalFrame& frame = frameView->frame(); | 117 LocalFrame& frame = frameView->frame(); |
67 frame.countObjectsNeedingLayout(needsLayoutObjects, totalObjects, isPartial) ; | 118 frame.countObjectsNeedingLayout(needsLayoutObjects, totalObjects, isPartial) ; |
68 | 119 |
69 RefPtr<TracedValue> value = TracedValue::create(); | 120 RefPtr<TracedValue> value = TracedValue::create(); |
70 value->setInteger("dirtyObjects", needsLayoutObjects); | 121 value->setInteger("dirtyObjects", needsLayoutObjects); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 | 453 |
403 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTracingSessionIdForWor kerEvent::data(const String& sessionId, WorkerThread* workerThread) | 454 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTracingSessionIdForWor kerEvent::data(const String& sessionId, WorkerThread* workerThread) |
404 { | 455 { |
405 RefPtr<TracedValue> value = TracedValue::create(); | 456 RefPtr<TracedValue> value = TracedValue::create(); |
406 value->setString("sessionId", sessionId); | 457 value->setString("sessionId", sessionId); |
407 value->setDouble("workerThreadId", workerThread->platformThreadId()); | 458 value->setDouble("workerThreadId", workerThread->platformThreadId()); |
408 return value.release(); | 459 return value.release(); |
409 } | 460 } |
410 | 461 |
411 } | 462 } |
OLD | NEW |