| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 65 |
| 66 // When the streaming is suppressed, the data is not given to V8, but | 66 // When the streaming is suppressed, the data is not given to V8, but |
| 67 // ScriptStreamer still watches the resource load and notifies the upper | 67 // ScriptStreamer still watches the resource load and notifies the upper |
| 68 // layers when loading is finished. It is used in situations when we have | 68 // layers when loading is finished. It is used in situations when we have |
| 69 // started streaming but then we detect we don't want to stream (e.g., when | 69 // started streaming but then we detect we don't want to stream (e.g., when |
| 70 // we have the code cache for the script) and we still want to parse and | 70 // we have the code cache for the script) and we still want to parse and |
| 71 // execute it when it has finished loading. | 71 // execute it when it has finished loading. |
| 72 void SuppressStreaming(); | 72 void SuppressStreaming(); |
| 73 bool StreamingSuppressed() const { return streaming_suppressed_; } | 73 bool StreamingSuppressed() const { return streaming_suppressed_; } |
| 74 | 74 |
| 75 v8::ScriptCompiler::CompileOptions GetCompileOptions() const { | |
| 76 return compile_options_; | |
| 77 } | |
| 78 | |
| 79 // Called by PendingScript when data arrives from the network. | 75 // Called by PendingScript when data arrives from the network. |
| 80 void NotifyAppendData(ScriptResource*); | 76 void NotifyAppendData(ScriptResource*); |
| 81 void NotifyFinished(Resource*); | 77 void NotifyFinished(Resource*); |
| 82 | 78 |
| 83 // Called by ScriptStreamingTask when it has streamed all data to V8 and V8 | 79 // Called by ScriptStreamingTask when it has streamed all data to V8 and V8 |
| 84 // has processed it. | 80 // has processed it. |
| 85 void StreamingCompleteOnBackgroundThread(); | 81 void StreamingCompleteOnBackgroundThread(); |
| 86 | 82 |
| 87 v8::ScriptCompiler::StreamedSource::Encoding GetEncoding() const { | |
| 88 return encoding_; | |
| 89 } | |
| 90 | |
| 91 const String& ScriptURLString() const { return script_url_string_; } | 83 const String& ScriptURLString() const { return script_url_string_; } |
| 92 unsigned long ScriptResourceIdentifier() const { | 84 unsigned long ScriptResourceIdentifier() const { |
| 93 return script_resource_identifier_; | 85 return script_resource_identifier_; |
| 94 } | 86 } |
| 95 | 87 |
| 96 static void SetSmallScriptThresholdForTesting(size_t threshold) { | 88 static void SetSmallScriptThresholdForTesting(size_t threshold) { |
| 97 small_script_threshold_ = threshold; | 89 small_script_threshold_ = threshold; |
| 98 } | 90 } |
| 99 | 91 |
| 100 static size_t SmallScriptThreshold() { return small_script_threshold_; } | |
| 101 | |
| 102 private: | 92 private: |
| 103 // Scripts whose first data chunk is smaller than this constant won't be | 93 // Scripts whose first data chunk is smaller than this constant won't be |
| 104 // streamed. Non-const for testing. | 94 // streamed. Non-const for testing. |
| 105 static size_t small_script_threshold_; | 95 static size_t small_script_threshold_; |
| 106 | 96 |
| 107 static ScriptStreamer* Create( | 97 static ScriptStreamer* Create( |
| 108 PendingScript* script, | 98 PendingScript* script, |
| 109 Type script_type, | 99 Type script_type, |
| 110 ScriptState* script_state, | 100 ScriptState* script_state, |
| 111 v8::ScriptCompiler::CompileOptions compile_options, | 101 v8::ScriptCompiler::CompileOptions compile_options, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 | 155 |
| 166 // Encoding of the streamed script. Saved for sanity checking purposes. | 156 // Encoding of the streamed script. Saved for sanity checking purposes. |
| 167 v8::ScriptCompiler::StreamedSource::Encoding encoding_; | 157 v8::ScriptCompiler::StreamedSource::Encoding encoding_; |
| 168 | 158 |
| 169 RefPtr<WebTaskRunner> loading_task_runner_; | 159 RefPtr<WebTaskRunner> loading_task_runner_; |
| 170 }; | 160 }; |
| 171 | 161 |
| 172 } // namespace blink | 162 } // namespace blink |
| 173 | 163 |
| 174 #endif // ScriptStreamer_h | 164 #endif // ScriptStreamer_h |
| OLD | NEW |