| 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 m_stream = new SourceStream(m_loadingTaskRunner.get()); | 534 m_stream = new SourceStream(m_loadingTaskRunner.get()); |
| 535 // m_source takes ownership of m_stream. | 535 // m_source takes ownership of m_stream. |
| 536 m_source = adoptPtr(new v8::ScriptCompiler::StreamedSource(m_stream, m_e
ncoding)); | 536 m_source = adoptPtr(new v8::ScriptCompiler::StreamedSource(m_stream, m_e
ncoding)); |
| 537 | 537 |
| 538 ScriptState::Scope scope(m_scriptState.get()); | 538 ScriptState::Scope scope(m_scriptState.get()); |
| 539 OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> scriptStreamingTask(adop
tPtr(v8::ScriptCompiler::StartStreamingScript(m_scriptState->isolate(), m_source
.get(), m_compileOptions))); | 539 OwnPtr<v8::ScriptCompiler::ScriptStreamingTask> scriptStreamingTask(adop
tPtr(v8::ScriptCompiler::StartStreamingScript(m_scriptState->isolate(), m_source
.get(), m_compileOptions))); |
| 540 if (!scriptStreamingTask) { | 540 if (!scriptStreamingTask) { |
| 541 // V8 cannot stream the script. | 541 // V8 cannot stream the script. |
| 542 suppressStreaming(); | 542 suppressStreaming(); |
| 543 m_stream = 0; | 543 m_stream = 0; |
| 544 m_source.clear(); | 544 m_source.reset(); |
| 545 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); | 545 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); |
| 546 recordStartedStreamingHistogram(m_scriptType, 0); | 546 recordStartedStreamingHistogram(m_scriptType, 0); |
| 547 return; | 547 return; |
| 548 } | 548 } |
| 549 | 549 |
| 550 ScriptStreamerThread::shared()->postTask(threadSafeBind(&ScriptStreamerT
hread::runScriptStreamingTask, passed(std::move(scriptStreamingTask)), wrapCross
ThreadPersistent(this))); | 550 ScriptStreamerThread::shared()->postTask(threadSafeBind(&ScriptStreamerT
hread::runScriptStreamingTask, passed(std::move(scriptStreamingTask)), wrapCross
ThreadPersistent(this))); |
| 551 recordStartedStreamingHistogram(m_scriptType, 1); | 551 recordStartedStreamingHistogram(m_scriptType, 1); |
| 552 } | 552 } |
| 553 if (m_stream) | 553 if (m_stream) |
| 554 m_stream->didReceiveData(this, lengthOfBOM); | 554 m_stream->didReceiveData(this, lengthOfBOM); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 | 672 |
| 673 // The Resource might go out of scope if the script is no longer | 673 // The Resource might go out of scope if the script is no longer |
| 674 // needed. This makes PendingScript notify the ScriptStreamer when it is | 674 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 675 // destroyed. | 675 // destroyed. |
| 676 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); | 676 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); |
| 677 | 677 |
| 678 return true; | 678 return true; |
| 679 } | 679 } |
| 680 | 680 |
| 681 } // namespace blink | 681 } // namespace blink |
| OLD | NEW |