Chromium Code Reviews| 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 | |
| 68 String invalidationListToString(const WillBeHeapVector<RefPtrWillBeMember<Descen dantInvalidationSet> >& invalidationList) | |
| 69 { | |
| 70 StringBuilder builder; | |
|
yurys
2014/09/30 09:21:14
Please use TracedValue instead for building the st
caseq
2014/09/30 12:24:00
+1 to that.
kouhei (in TOK)
2014/10/01 04:16:14
Done.
| |
| 71 | |
| 72 builder.append("["); | |
| 73 bool isFirst = true; | |
| 74 for (const auto& invalidationSet : invalidationList) { | |
| 75 if (!isFirst) | |
| 76 builder.append(", "); | |
| 77 isFirst = false; | |
| 78 | |
| 79 builder.append(invalidationSet->toDebugString()); | |
| 80 } | |
| 81 builder.append("]"); | |
| 82 return builder.toString(); | |
| 83 } | |
| 84 | |
| 59 } | 85 } |
| 60 | 86 |
| 87 const char InspectorStyleInvalidatorInvalidateEvent::ElementHasPendingInvalidati onMap[] = "Element has pending invalidation map"; | |
| 88 const char InspectorStyleInvalidatorInvalidateEvent::InvalidateCustomPseudo[] = "Invalidate custom pseudo element."; | |
| 89 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedAttri bute[] = "Invalidation set matched attribute."; | |
| 90 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedClass [] = "Invalidation set matched class."; | |
| 91 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedId[] = "Invalidation set matched id."; | |
| 92 const char InspectorStyleInvalidatorInvalidateEvent::InvalidationSetMatchedTagNa me[] = "Invalidation set matched tagName."; | |
| 93 const char InspectorStyleInvalidatorInvalidateEvent::PreventStyleSharingForParen t[] = "Prevent style sharing for parent."; | |
| 94 | |
| 95 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorStyleInvalidatorInvali dateEvent::data(Element& element, const char* reason, const String& selectorPart ) | |
| 96 { | |
| 97 RefPtr<TracedValue> value = TracedValue::create(); | |
| 98 value->setString("frame", toHexString(element.document().frame())); | |
| 99 setNodeInfo(value.get(), &element, "nodeId", "nodeName"); | |
| 100 value->setString("reason", reason); | |
| 101 value->setString("selectorPart", selectorPart); | |
| 102 return value; | |
|
caseq
2014/09/30 12:24:00
nit: value.release(), since you've just changed th
kouhei (in TOK)
2014/10/01 04:16:14
Done.
| |
| 103 } | |
| 104 | |
| 105 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorStyleInvalidatorInvali dateEvent::invalidationList(Element& element, const WillBeHeapVector<RefPtrWillB eMember<DescendantInvalidationSet> >& invalidationList) | |
| 106 { | |
| 107 return data(element, InspectorStyleInvalidatorInvalidateEvent::ElementHasPen dingInvalidationMap, invalidationListToString(invalidationList)); | |
| 108 } | |
| 109 | |
| 61 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::beginData (FrameView* frameView) | 110 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorLayoutEvent::beginData (FrameView* frameView) |
| 62 { | 111 { |
| 63 bool isPartial; | 112 bool isPartial; |
| 64 unsigned needsLayoutObjects; | 113 unsigned needsLayoutObjects; |
| 65 unsigned totalObjects; | 114 unsigned totalObjects; |
| 66 LocalFrame& frame = frameView->frame(); | 115 LocalFrame& frame = frameView->frame(); |
| 67 frame.countObjectsNeedingLayout(needsLayoutObjects, totalObjects, isPartial) ; | 116 frame.countObjectsNeedingLayout(needsLayoutObjects, totalObjects, isPartial) ; |
| 68 | 117 |
| 69 RefPtr<TracedValue> value = TracedValue::create(); | 118 RefPtr<TracedValue> value = TracedValue::create(); |
| 70 value->setInteger("dirtyObjects", needsLayoutObjects); | 119 value->setInteger("dirtyObjects", needsLayoutObjects); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 402 | 451 |
| 403 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTracingSessionIdForWor kerEvent::data(const String& sessionId, WorkerThread* workerThread) | 452 PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorTracingSessionIdForWor kerEvent::data(const String& sessionId, WorkerThread* workerThread) |
| 404 { | 453 { |
| 405 RefPtr<TracedValue> value = TracedValue::create(); | 454 RefPtr<TracedValue> value = TracedValue::create(); |
| 406 value->setString("sessionId", sessionId); | 455 value->setString("sessionId", sessionId); |
| 407 value->setDouble("workerThreadId", workerThread->platformThreadId()); | 456 value->setDouble("workerThreadId", workerThread->platformThreadId()); |
| 408 return value.release(); | 457 return value.release(); |
| 409 } | 458 } |
| 410 | 459 |
| 411 } | 460 } |
| OLD | NEW |