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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 suppressStreaming(); | 464 suppressStreaming(); |
465 recordNotStreamingReasonHistogram(m_scriptType, ContextNotValid); | 465 recordNotStreamingReasonHistogram(m_scriptType, ContextNotValid); |
466 recordStartedStreamingHistogram(m_scriptType, 0); | 466 recordStartedStreamingHistogram(m_scriptType, 0); |
467 return; | 467 return; |
468 } | 468 } |
469 | 469 |
470 DCHECK(!m_stream); | 470 DCHECK(!m_stream); |
471 DCHECK(!m_source); | 471 DCHECK(!m_source); |
472 m_stream = new SourceStream(m_loadingTaskRunner.get()); | 472 m_stream = new SourceStream(m_loadingTaskRunner.get()); |
473 // m_source takes ownership of m_stream. | 473 // m_source takes ownership of m_stream. |
474 m_source = wrapUnique( | 474 m_source = WTF::wrapUnique( |
475 new v8::ScriptCompiler::StreamedSource(m_stream, m_encoding)); | 475 new v8::ScriptCompiler::StreamedSource(m_stream, m_encoding)); |
476 | 476 |
477 ScriptState::Scope scope(m_scriptState.get()); | 477 ScriptState::Scope scope(m_scriptState.get()); |
478 std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> | 478 std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> |
479 scriptStreamingTask(wrapUnique(v8::ScriptCompiler::StartStreamingScript( | 479 scriptStreamingTask( |
480 m_scriptState->isolate(), m_source.get(), m_compileOptions))); | 480 WTF::wrapUnique(v8::ScriptCompiler::StartStreamingScript( |
| 481 m_scriptState->isolate(), m_source.get(), m_compileOptions))); |
481 if (!scriptStreamingTask) { | 482 if (!scriptStreamingTask) { |
482 // V8 cannot stream the script. | 483 // V8 cannot stream the script. |
483 suppressStreaming(); | 484 suppressStreaming(); |
484 m_stream = 0; | 485 m_stream = 0; |
485 m_source.reset(); | 486 m_source.reset(); |
486 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); | 487 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); |
487 recordStartedStreamingHistogram(m_scriptType, 0); | 488 recordStartedStreamingHistogram(m_scriptType, 0); |
488 return; | 489 return; |
489 } | 490 } |
490 | 491 |
491 ScriptStreamerThread::shared()->postTask( | 492 ScriptStreamerThread::shared()->postTask( |
492 crossThreadBind(&ScriptStreamerThread::runScriptStreamingTask, | 493 crossThreadBind(&ScriptStreamerThread::runScriptStreamingTask, |
493 passed(std::move(scriptStreamingTask)), | 494 WTF::passed(std::move(scriptStreamingTask)), |
494 wrapCrossThreadPersistent(this))); | 495 wrapCrossThreadPersistent(this))); |
495 recordStartedStreamingHistogram(m_scriptType, 1); | 496 recordStartedStreamingHistogram(m_scriptType, 1); |
496 } | 497 } |
497 if (m_stream) | 498 if (m_stream) |
498 m_stream->didReceiveData(this); | 499 m_stream->didReceiveData(this); |
499 } | 500 } |
500 | 501 |
501 void ScriptStreamer::notifyFinished(Resource* resource) { | 502 void ScriptStreamer::notifyFinished(Resource* resource) { |
502 DCHECK(isMainThread()); | 503 DCHECK(isMainThread()); |
503 CHECK_EQ(m_resource, resource); | 504 CHECK_EQ(m_resource, resource); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 // The Resource might go out of scope if the script is no longer | 621 // The Resource might go out of scope if the script is no longer |
621 // needed. This makes PendingScript notify the ScriptStreamer when it is | 622 // needed. This makes PendingScript notify the ScriptStreamer when it is |
622 // destroyed. | 623 // destroyed. |
623 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState, | 624 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState, |
624 compileOption, loadingTaskRunner)); | 625 compileOption, loadingTaskRunner)); |
625 | 626 |
626 return true; | 627 return true; |
627 } | 628 } |
628 | 629 |
629 } // namespace blink | 630 } // namespace blink |
OLD | NEW |