Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Side by Side Diff: Source/bindings/core/v8/ScriptStreamer.h

Issue 655263003: Script streaming: fix small script recognition heuristic. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: . Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef ScriptStreamer_h 5 #ifndef ScriptStreamer_h
6 #define ScriptStreamer_h 6 #define ScriptStreamer_h
7 7
8 #include "core/dom/PendingScript.h" 8 #include "core/dom/PendingScript.h"
9 #include "wtf/RefCounted.h" 9 #include "wtf/RefCounted.h"
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 // Called by PendingScript when data arrives from the network. 79 // Called by PendingScript when data arrives from the network.
80 void notifyAppendData(ScriptResource*); 80 void notifyAppendData(ScriptResource*);
81 void notifyFinished(Resource*); 81 void notifyFinished(Resource*);
82 82
83 // Called by ScriptStreamingTask when it has streamed all data to V8 and V8 83 // Called by ScriptStreamingTask when it has streamed all data to V8 and V8
84 // has processed it. 84 // has processed it.
85 void streamingComplete(); 85 void streamingComplete();
86 86
87 static void removeSmallScriptThresholdForTesting() 87 static void setSmallScriptThresholdForTesting(size_t threshold)
88 { 88 {
89 kSmallScriptThreshold = 0; 89 kSmallScriptThreshold = threshold;
90 } 90 }
91 91
92 static size_t smallScriptThreshold() { return kSmallScriptThreshold; } 92 static size_t smallScriptThreshold() { return kSmallScriptThreshold; }
93 93
94 private: 94 private:
95 // Scripts whose first data chunk is smaller than this constant won't be 95 // Scripts whose first data chunk is smaller than this constant won't be
96 // streamed. Non-const for testing. 96 // streamed. Non-const for testing.
97 static size_t kSmallScriptThreshold; 97 static size_t kSmallScriptThreshold;
98 98
99 ScriptStreamer(ScriptResource*, v8::ScriptCompiler::StreamedSource::Encoding , PendingScript::Type); 99 ScriptStreamer(ScriptResource*, v8::ScriptCompiler::StreamedSource::Encoding , PendingScript::Type);
(...skipping 12 matching lines...) Expand all
112 // script data is not needed any more, and the client won't get notified 112 // script data is not needed any more, and the client won't get notified
113 // when the loading and streaming are done. 113 // when the loading and streaming are done.
114 bool m_detached; 114 bool m_detached;
115 115
116 SourceStream* m_stream; 116 SourceStream* m_stream;
117 v8::ScriptCompiler::StreamedSource m_source; 117 v8::ScriptCompiler::StreamedSource m_source;
118 ScriptResourceClient* m_client; 118 ScriptResourceClient* m_client;
119 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_task; 119 WTF::OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> m_task;
120 bool m_loadingFinished; // Whether loading from the network is done. 120 bool m_loadingFinished; // Whether loading from the network is done.
121 bool m_parsingFinished; // Whether the V8 side processing is done. 121 bool m_parsingFinished; // Whether the V8 side processing is done.
122 bool m_firstDataChunkReceived; 122 // Whether we have received enough data to start the streaming.
123 bool m_haveEnoughDataForStreaming;
123 124
124 // Whether the script source code should be retrieved from the Resource 125 // Whether the script source code should be retrieved from the Resource
125 // instead of the ScriptStreamer. 126 // instead of the ScriptStreamer.
126 bool m_streamingSuppressed; 127 bool m_streamingSuppressed;
127 128
128 // What kind of cached data V8 produces during streaming. 129 // What kind of cached data V8 produces during streaming.
129 unsigned m_cachedDataType; 130 unsigned m_cachedDataType;
130 131
131 // For recording metrics for different types of scripts separately. 132 // For recording metrics for different types of scripts separately.
132 PendingScript::Type m_scriptType; 133 PendingScript::Type m_scriptType;
133 }; 134 };
134 135
135 } // namespace blink 136 } // namespace blink
136 137
137 #endif // ScriptStreamer_h 138 #endif // ScriptStreamer_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/ScriptStreamer.cpp » ('j') | Source/bindings/core/v8/ScriptStreamer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698