| 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 WTF_MAKE_NONCOPYABLE(SourceStream); | 174 WTF_MAKE_NONCOPYABLE(SourceStream); |
| 175 public: | 175 public: |
| 176 explicit SourceStream(WebTaskRunner* loadingTaskRunner) | 176 explicit SourceStream(WebTaskRunner* loadingTaskRunner) |
| 177 : v8::ScriptCompiler::ExternalSourceStream() | 177 : v8::ScriptCompiler::ExternalSourceStream() |
| 178 , m_cancelled(false) | 178 , m_cancelled(false) |
| 179 , m_finished(false) | 179 , m_finished(false) |
| 180 , m_queueLeadPosition(0) | 180 , m_queueLeadPosition(0) |
| 181 , m_queueTailPosition(0) | 181 , m_queueTailPosition(0) |
| 182 , m_bookmarkPosition(0) | 182 , m_bookmarkPosition(0) |
| 183 , m_lengthOfBOM(0) | 183 , m_lengthOfBOM(0) |
| 184 , m_loadingTaskRunner(wrapUnique(loadingTaskRunner->clone())) | 184 , m_loadingTaskRunner(loadingTaskRunner->clone()) |
| 185 { | 185 { |
| 186 } | 186 } |
| 187 | 187 |
| 188 virtual ~SourceStream() override { } | 188 virtual ~SourceStream() override { } |
| 189 | 189 |
| 190 // Called by V8 on a background thread. Should block until we can return | 190 // Called by V8 on a background thread. Should block until we can return |
| 191 // some data. | 191 // some data. |
| 192 size_t GetMoreData(const uint8_t** src) override | 192 size_t GetMoreData(const uint8_t** src) override |
| 193 { | 193 { |
| 194 ASSERT(!isMainThread()); | 194 ASSERT(!isMainThread()); |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 , m_loadingFinished(false) | 583 , m_loadingFinished(false) |
| 584 , m_parsingFinished(false) | 584 , m_parsingFinished(false) |
| 585 , m_haveEnoughDataForStreaming(false) | 585 , m_haveEnoughDataForStreaming(false) |
| 586 , m_streamingSuppressed(false) | 586 , m_streamingSuppressed(false) |
| 587 , m_compileOptions(compileOptions) | 587 , m_compileOptions(compileOptions) |
| 588 , m_scriptState(scriptState) | 588 , m_scriptState(scriptState) |
| 589 , m_scriptType(scriptType) | 589 , m_scriptType(scriptType) |
| 590 , m_scriptURLString(m_resource->url().copy().getString()) | 590 , m_scriptURLString(m_resource->url().copy().getString()) |
| 591 , m_scriptResourceIdentifier(m_resource->identifier()) | 591 , m_scriptResourceIdentifier(m_resource->identifier()) |
| 592 , m_encoding(v8::ScriptCompiler::StreamedSource::TWO_BYTE) // Unfortunately
there's no dummy encoding value in the enum; let's use one we don't stream. | 592 , m_encoding(v8::ScriptCompiler::StreamedSource::TWO_BYTE) // Unfortunately
there's no dummy encoding value in the enum; let's use one we don't stream. |
| 593 , m_loadingTaskRunner(wrapUnique(loadingTaskRunner->clone())) | 593 , m_loadingTaskRunner(loadingTaskRunner->clone()) |
| 594 { | 594 { |
| 595 } | 595 } |
| 596 | 596 |
| 597 ScriptStreamer::~ScriptStreamer() | 597 ScriptStreamer::~ScriptStreamer() |
| 598 { | 598 { |
| 599 } | 599 } |
| 600 | 600 |
| 601 DEFINE_TRACE(ScriptStreamer) | 601 DEFINE_TRACE(ScriptStreamer) |
| 602 { | 602 { |
| 603 visitor->trace(m_pendingScript); | 603 visitor->trace(m_pendingScript); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 | 673 |
| 674 // The Resource might go out of scope if the script is no longer | 674 // The Resource might go out of scope if the script is no longer |
| 675 // needed. This makes PendingScript notify the ScriptStreamer when it is | 675 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 676 // destroyed. | 676 // destroyed. |
| 677 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); | 677 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); |
| 678 | 678 |
| 679 return true; | 679 return true; |
| 680 } | 680 } |
| 681 | 681 |
| 682 } // namespace blink | 682 } // namespace blink |
| OLD | NEW |