| 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 "bindings/core/v8/ScriptStreamer.h" | 5 #include "bindings/core/v8/ScriptStreamer.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptStreamerThread.h" | 7 #include "bindings/core/v8/ScriptStreamerThread.h" |
| 8 #include "bindings/core/v8/V8ScriptRunner.h" | 8 #include "bindings/core/v8/V8ScriptRunner.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/Element.h" | 10 #include "core/dom/Element.h" |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 | 273 |
| 274 // The Resource must still be alive; otherwise we should've cancelled | 274 // The Resource must still be alive; otherwise we should've cancelled |
| 275 // the streaming (if we have cancelled, the background thread is not | 275 // the streaming (if we have cancelled, the background thread is not |
| 276 // waiting). | 276 // waiting). |
| 277 ASSERT(streamer->resource()); | 277 ASSERT(streamer->resource()); |
| 278 | 278 |
| 279 // BOM can only occur at the beginning of the data. | 279 // BOM can only occur at the beginning of the data. |
| 280 ASSERT(lengthOfBOM == 0 || m_queueTailPosition == 0); | 280 ASSERT(lengthOfBOM == 0 || m_queueTailPosition == 0); |
| 281 | 281 |
| 282 CachedMetadataHandler* cacheHandler = streamer->resource()->cacheHandler
(); | 282 CachedMetadataHandler* cacheHandler = streamer->resource()->cacheHandler
(); |
| 283 if (cacheHandler && cacheHandler->cachedMetadata(V8ScriptRunner::tagForC
odeCache(cacheHandler))) { | 283 if (cacheHandler && (cacheHandler->shouldAggressivelyCache() || cacheHan
dler->cachedMetadata(V8ScriptRunner::tagForCodeCache(cacheHandler)))) { |
| 284 // The resource has a code cache, so it's unnecessary to stream and | 284 // When we should aggressively cache the code cache, we can't use |
| 285 // parse the code. Cancel the streaming and resume the non-streaming | 285 // SourceStream because currently V8ScriptRunner doesn't supoprt |
| 286 // code path. | 286 // code caching with SourceStream. And if the resource has a code |
| 287 // cache, it's unnecessary to stream and parse the code. |
| 288 // Cancel the streaming and resume the non-streaming code path. |
| 287 streamer->suppressStreaming(); | 289 streamer->suppressStreaming(); |
| 288 cancel(); | 290 cancel(); |
| 289 return; | 291 return; |
| 290 } | 292 } |
| 291 | 293 |
| 292 if (!m_resourceBuffer) { | 294 if (!m_resourceBuffer) { |
| 293 // We don't have a buffer yet. Try to get it from the resource. | 295 // We don't have a buffer yet. Try to get it from the resource. |
| 294 SharedBuffer* buffer = streamer->resource()->resourceBuffer(); | 296 SharedBuffer* buffer = streamer->resource()->resourceBuffer(); |
| 295 m_resourceBuffer = RefPtr<SharedBuffer>(buffer); | 297 m_resourceBuffer = RefPtr<SharedBuffer>(buffer); |
| 296 } | 298 } |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 | 668 |
| 667 // The Resource might go out of scope if the script is no longer | 669 // The Resource might go out of scope if the script is no longer |
| 668 // needed. This makes PendingScript notify the ScriptStreamer when it is | 670 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 669 // destroyed. | 671 // destroyed. |
| 670 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); | 672 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); |
| 671 | 673 |
| 672 return true; | 674 return true; |
| 673 } | 675 } |
| 674 | 676 |
| 675 } // namespace blink | 677 } // namespace blink |
| OLD | NEW |