| 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 #ifndef ScriptStreamer_h | 5 #ifndef ScriptStreamer_h |
| 6 #define ScriptStreamer_h | 6 #define ScriptStreamer_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 10 #include "wtf/RefCounted.h" | 10 #include "wtf/RefCounted.h" |
| 11 #include "wtf/text/WTFString.h" |
| 11 | 12 |
| 12 #include <v8.h> | 13 #include <v8.h> |
| 13 | 14 |
| 14 namespace blink { | 15 namespace blink { |
| 15 | 16 |
| 16 class PendingScript; | 17 class PendingScript; |
| 17 class Resource; | 18 class Resource; |
| 18 class ScriptResource; | 19 class ScriptResource; |
| 19 class ScriptState; | 20 class ScriptState; |
| 20 class Settings; | 21 class Settings; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // Called by PendingScript when data arrives from the network. | 76 // Called by PendingScript when data arrives from the network. |
| 76 void notifyAppendData(ScriptResource*); | 77 void notifyAppendData(ScriptResource*); |
| 77 void notifyFinished(Resource*); | 78 void notifyFinished(Resource*); |
| 78 | 79 |
| 79 // Called by ScriptStreamingTask when it has streamed all data to V8 and V8 | 80 // Called by ScriptStreamingTask when it has streamed all data to V8 and V8 |
| 80 // has processed it. | 81 // has processed it. |
| 81 void streamingCompleteOnBackgroundThread(); | 82 void streamingCompleteOnBackgroundThread(); |
| 82 | 83 |
| 83 v8::ScriptCompiler::StreamedSource::Encoding encoding() const { return m_enc
oding; } | 84 v8::ScriptCompiler::StreamedSource::Encoding encoding() const { return m_enc
oding; } |
| 84 | 85 |
| 86 const String& scriptURLString() const { return m_scriptURLString; } |
| 87 unsigned long scriptResourceIdentifier() const { return m_scriptResourceIden
tifier; } |
| 88 |
| 85 static void setSmallScriptThresholdForTesting(size_t threshold) | 89 static void setSmallScriptThresholdForTesting(size_t threshold) |
| 86 { | 90 { |
| 87 s_smallScriptThreshold = threshold; | 91 s_smallScriptThreshold = threshold; |
| 88 } | 92 } |
| 89 | 93 |
| 90 static size_t smallScriptThreshold() { return s_smallScriptThreshold; } | 94 static size_t smallScriptThreshold() { return s_smallScriptThreshold; } |
| 91 | 95 |
| 92 private: | 96 private: |
| 93 // Scripts whose first data chunk is smaller than this constant won't be | 97 // Scripts whose first data chunk is smaller than this constant won't be |
| 94 // streamed. Non-const for testing. | 98 // streamed. Non-const for testing. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 bool m_streamingSuppressed; | 133 bool m_streamingSuppressed; |
| 130 | 134 |
| 131 // What kind of cached data V8 produces during streaming. | 135 // What kind of cached data V8 produces during streaming. |
| 132 v8::ScriptCompiler::CompileOptions m_compileOptions; | 136 v8::ScriptCompiler::CompileOptions m_compileOptions; |
| 133 | 137 |
| 134 RefPtr<ScriptState> m_scriptState; | 138 RefPtr<ScriptState> m_scriptState; |
| 135 | 139 |
| 136 // For recording metrics for different types of scripts separately. | 140 // For recording metrics for different types of scripts separately. |
| 137 Type m_scriptType; | 141 Type m_scriptType; |
| 138 | 142 |
| 143 // Keep the script URL string for event tracing. |
| 144 const String m_scriptURLString; |
| 145 |
| 146 // Keep the script resource dentifier for event tracing. |
| 147 const unsigned long m_scriptResourceIdentifier; |
| 148 |
| 139 mutable Mutex m_mutex; | 149 mutable Mutex m_mutex; |
| 140 | 150 |
| 141 // Encoding of the streamed script. Saved for sanity checking purposes. | 151 // Encoding of the streamed script. Saved for sanity checking purposes. |
| 142 v8::ScriptCompiler::StreamedSource::Encoding m_encoding; | 152 v8::ScriptCompiler::StreamedSource::Encoding m_encoding; |
| 143 | 153 |
| 144 OwnPtr<WebTaskRunner> m_loadingTaskRunner; | 154 OwnPtr<WebTaskRunner> m_loadingTaskRunner; |
| 145 }; | 155 }; |
| 146 | 156 |
| 147 } // namespace blink | 157 } // namespace blink |
| 148 | 158 |
| 149 #endif // ScriptStreamer_h | 159 #endif // ScriptStreamer_h |
| OLD | NEW |