diff options
| author | horo <horo@chromium.org> | 2016-03-24 23:52:31 -0700 |
|---|---|---|
| committer | Commit bot <commit-bot@chromium.org> | 2016-03-25 06:53:50 +0000 |
| commit | 23441ef2a1903a977eea7feef9160ef80cf19e8c (patch) | |
| tree | 4a4938b2b2572b0612b05710add7df452d30195d | |
| parent | 8ffde9bc046e08086525a0f82956c562e6a5d815 (diff) | |
| download | chromium_src-23441ef2a1903a977eea7feef9160ef80cf19e8c.zip chromium_src-23441ef2a1903a977eea7feef9160ef80cf19e8c.tar.gz chromium_src-23441ef2a1903a977eea7feef9160ef80cf19e8c.tar.bz2 | |
Show v8.parseOnBackground in DevTools Timeline
BUG=595985
Review URL: https://codereview.chromium.org/1807193003
Cr-Commit-Position: refs/heads/master@{#383259}
10 files changed, 93 insertions, 3 deletions
diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/resources/timeline-script-parse.php b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/resources/timeline-script-parse.php new file mode 100644 index 0000000..f0679c2 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/resources/timeline-script-parse.php @@ -0,0 +1,5 @@ +<?php + header("Content-type: text/javascript"); + echo str_repeat(" ", 100000); + sleep(1); +?> diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse-expected.txt b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse-expected.txt new file mode 100644 index 0000000..c957fc3 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse-expected.txt @@ -0,0 +1,14 @@ +Tests the Timeline events for v8.parseOnBackground + +v8.parseOnBackground Properties: +{ + data : { + requestId : <string> + url : .../inspector/tracing/resources/timeline-script-parse.php + } + endTime : <number> + startTime : <number> + type : "v8.parseOnBackground" +} +Text details for v8.parseOnBackground: timeline-script-parse.php + diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html new file mode 100644 index 0000000..ce66fb8 --- /dev/null +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/tracing/timeline-script-parse.html @@ -0,0 +1,37 @@ +<html> +<head> +<script src="../inspector-test.js"></script> +<script src="../timeline-test.js"></script> +<script src="../network-test.js"></script> +<script> + +function performActions(callback) +{ + var script = document.createElement("script"); + script.src = "resources/timeline-script-parse.php"; + script.async = true; + script.onload = callback; + document.body.appendChild(script); +} + +function test() +{ + InspectorTest.invokeAsyncWithTimeline("performActions", finish); + + function finish() + { + InspectorTest.printTimelineRecordsWithDetails("v8.parseOnBackground"); + InspectorTest.completeTest(); + } +} + +</script> +</head> + +<body onload="runTest()"> +<p> +Tests the Timeline events for v8.parseOnBackground +</p> + +</body> +</html> diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp index 0ace8b2..2f82ff2 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp @@ -587,6 +587,8 @@ ScriptStreamer::ScriptStreamer(PendingScript* script, Type scriptType, ScriptSta , m_compileOptions(compileOptions) , m_scriptState(scriptState) , m_scriptType(scriptType) + , m_scriptURLString(m_resource->url().copy().getString()) + , m_scriptResourceIdentifier(m_resource->identifier()) , m_encoding(v8::ScriptCompiler::StreamedSource::TWO_BYTE) // Unfortunately there's no dummy encoding value in the enum; let's use one we don't stream. , m_loadingTaskRunner(adoptPtr(loadingTaskRunner->clone())) { diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h index 251e58d..67b5594 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h @@ -8,6 +8,7 @@ #include "core/CoreExport.h" #include "platform/heap/Handle.h" #include "wtf/RefCounted.h" +#include "wtf/text/WTFString.h" #include <v8.h> @@ -82,6 +83,9 @@ public: v8::ScriptCompiler::StreamedSource::Encoding encoding() const { return m_encoding; } + const String& scriptURLString() const { return m_scriptURLString; } + unsigned long scriptResourceIdentifier() const { return m_scriptResourceIdentifier; } + static void setSmallScriptThresholdForTesting(size_t threshold) { s_smallScriptThreshold = threshold; @@ -136,6 +140,12 @@ private: // For recording metrics for different types of scripts separately. Type m_scriptType; + // Keep the script URL string for event tracing. + const String m_scriptURLString; + + // Keep the script resource dentifier for event tracing. + const unsigned long m_scriptResourceIdentifier; + mutable Mutex m_mutex; // Encoding of the streamed script. Saved for sanity checking purposes. diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp index 6d9896b..5392ad2 100644 --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerThread.cpp @@ -5,6 +5,7 @@ #include "bindings/core/v8/ScriptStreamerThread.h" #include "bindings/core/v8/ScriptStreamer.h" +#include "core/inspector/InspectorTraceEvents.h" #include "platform/TraceEvent.h" #include "public/platform/Platform.h" #include "public/platform/WebTaskRunner.h" @@ -77,7 +78,7 @@ WebThread& ScriptStreamerThread::platformThread() void ScriptStreamerThread::runScriptStreamingTask(WTF::PassOwnPtr<v8::ScriptCompiler::ScriptStreamingTask> task, ScriptStreamer* streamer) { - TRACE_EVENT0("v8", "v8.parseOnBackground"); + TRACE_EVENT1("v8,devtools.timeline", "v8.parseOnBackground", "data", InspectorParseScriptEvent::data(streamer->scriptResourceIdentifier(), streamer->scriptURLString())); // Running the task can and will block: SourceStream::GetSomeData will get // called and it will block and wait for data from the network. task->Run(); diff --git a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp index fecc7f2..fd9971f 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp +++ b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp @@ -679,6 +679,15 @@ PassOwnPtr<TracedValue> InspectorEvaluateScriptEvent::data(LocalFrame* frame, co return value.release(); } +PassOwnPtr<TracedValue> InspectorParseScriptEvent::data(unsigned long identifier, const String& url) +{ + String requestId = IdentifiersFactory::requestId(identifier); + OwnPtr<TracedValue> value = TracedValue::create(); + value->setString("requestId", requestId); + value->setString("url", url); + return value.release(); +} + PassOwnPtr<TracedValue> InspectorCompileScriptEvent::data(const String& url, const TextPosition& textPosition) { return fillLocation(url, textPosition); diff --git a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h index 3b8f591..f07dcea 100644 --- a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h +++ b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h @@ -278,6 +278,10 @@ namespace InspectorEvaluateScriptEvent { PassOwnPtr<TracedValue> data(LocalFrame*, const String& url, const WTF::TextPosition&); } +namespace InspectorParseScriptEvent { +PassOwnPtr<TracedValue> data(unsigned long identifier, const String& url); +} + namespace InspectorCompileScriptEvent { PassOwnPtr<TracedValue> data(const String& url, const WTF::TextPosition&); } diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js index 243d057..70686f5 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js @@ -117,6 +117,7 @@ WebInspector.TimelineModel.RecordType = { V8Sample: "V8Sample", JitCodeAdded: "JitCodeAdded", JitCodeMoved: "JitCodeMoved", + ParseScriptOnBackground: "v8.parseOnBackground", UpdateCounters: "UpdateCounters", diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js index 9e77d90..dba4e5a 100644 --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js @@ -90,6 +90,7 @@ WebInspector.TimelineUIUtils._initEventStyles = function() eventStyles[recordTypes.XHRLoad] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("XHR Load"), categories["scripting"]); eventStyles[recordTypes.CompileScript] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Compile Script"), categories["scripting"]); eventStyles[recordTypes.EvaluateScript] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Evaluate Script"), categories["scripting"]); + eventStyles[recordTypes.ParseScriptOnBackground] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Parse Script"), categories["scripting"]); eventStyles[recordTypes.MarkLoad] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("Load event"), categories["scripting"], true); eventStyles[recordTypes.MarkDOMContent] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("DOMContentLoaded event"), categories["scripting"], true); eventStyles[recordTypes.MarkFirstPaint] = new WebInspector.TimelineRecordStyle(WebInspector.UIString("First paint"), categories["painting"], true); @@ -391,13 +392,14 @@ WebInspector.TimelineUIUtils.buildDetailsTextForTraceEvent = function(event, tar case recordType.EvaluateScript: var url = eventData["url"]; if (url) - detailsText = detailsText = WebInspector.displayNameForURL(url) + ":" + eventData["lineNumber"]; + detailsText = WebInspector.displayNameForURL(url) + ":" + eventData["lineNumber"]; break; + case recordType.ParseScriptOnBackground: case recordType.XHRReadyStateChange: case recordType.XHRLoad: var url = eventData["url"]; if (url) - detailsText = detailsText = WebInspector.displayNameForURL(url); + detailsText = WebInspector.displayNameForURL(url); break; case recordType.WebSocketCreate: @@ -540,6 +542,11 @@ WebInspector.TimelineUIUtils.buildDetailsNodeForTraceEvent = function(event, tar if (url) details = linkifyLocation("", url, eventData["lineNumber"], 0); break; + case recordType.ParseScriptOnBackground: + var url = eventData["url"]; + if (url) + details = linkifyLocation("", url, 0, 0); + break; default: if (event.hasCategory(WebInspector.TimelineModel.Category.Console)) detailsText = null; |
