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 "bindings/core/v8/ScriptStreamer.h" | 6 #include "bindings/core/v8/ScriptStreamer.h" |
7 | 7 |
8 #include "bindings/core/v8/ScriptStreamerThread.h" | 8 #include "bindings/core/v8/ScriptStreamerThread.h" |
9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 { | 153 { |
154 ASSERT(isMainThread()); | 154 ASSERT(isMainThread()); |
155 // The Resource must still be alive; otherwise we should've cancelled | 155 // The Resource must still be alive; otherwise we should've cancelled |
156 // the streaming (if we have cancelled, the background thread is not | 156 // the streaming (if we have cancelled, the background thread is not |
157 // waiting). | 157 // waiting). |
158 ASSERT(streamer->resource()); | 158 ASSERT(streamer->resource()); |
159 | 159 |
160 // BOM can only occur at the beginning of the data. | 160 // BOM can only occur at the beginning of the data. |
161 ASSERT(lengthOfBOM == 0 || m_dataPosition == 0); | 161 ASSERT(lengthOfBOM == 0 || m_dataPosition == 0); |
162 | 162 |
163 if (streamer->resource()->cachedMetadata(V8ScriptRunner::tagForCodeCache
(streamer->resource()))) { | 163 CachedMetadataHandler* cacheHandler = streamer->resource()->cacheHandler
(); |
| 164 if (cacheHandler && cacheHandler->cachedMetadata(V8ScriptRunner::tagForC
odeCache(cacheHandler))) { |
164 // The resource has a code cache, so it's unnecessary to stream and | 165 // The resource has a code cache, so it's unnecessary to stream and |
165 // parse the code. Cancel the streaming and resume the non-streaming | 166 // parse the code. Cancel the streaming and resume the non-streaming |
166 // code path. | 167 // code path. |
167 streamer->suppressStreaming(); | 168 streamer->suppressStreaming(); |
168 { | 169 { |
169 MutexLocker locker(m_mutex); | 170 MutexLocker locker(m_mutex); |
170 m_cancelled = true; | 171 m_cancelled = true; |
171 } | 172 } |
172 m_dataQueue.finish(); | 173 m_dataQueue.finish(); |
173 return; | 174 return; |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 493 |
493 // The Resource might go out of scope if the script is no longer | 494 // The Resource might go out of scope if the script is no longer |
494 // needed. This makes PendingScript notify the ScriptStreamer when it is | 495 // needed. This makes PendingScript notify the ScriptStreamer when it is |
495 // destroyed. | 496 // destroyed. |
496 script.setStreamer(ScriptStreamer::create(resource, scriptState, compileOpti
on)); | 497 script.setStreamer(ScriptStreamer::create(resource, scriptState, compileOpti
on)); |
497 | 498 |
498 return true; | 499 return true; |
499 } | 500 } |
500 | 501 |
501 } // namespace blink | 502 } // namespace blink |
OLD | NEW |