| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 // it. | 558 // it. |
| 559 if (!m_haveEnoughDataForStreaming) { | 559 if (!m_haveEnoughDataForStreaming) { |
| 560 recordNotStreamingReasonHistogram(m_scriptType, ScriptTooSmall); | 560 recordNotStreamingReasonHistogram(m_scriptType, ScriptTooSmall); |
| 561 recordStartedStreamingHistogram(m_scriptType, 0); | 561 recordStartedStreamingHistogram(m_scriptType, 0); |
| 562 suppressStreaming(); | 562 suppressStreaming(); |
| 563 } | 563 } |
| 564 if (m_stream) | 564 if (m_stream) |
| 565 m_stream->didFinishLoading(); | 565 m_stream->didFinishLoading(); |
| 566 m_loadingFinished = true; | 566 m_loadingFinished = true; |
| 567 | 567 |
| 568 // Calling notifyFinishedToClient can result into the upper layers dropping | |
| 569 // references to ScriptStreamer. Keep it alive until this function ends. | |
| 570 RawPtr<ScriptStreamer> protect(this); | |
| 571 | |
| 572 notifyFinishedToClient(); | 568 notifyFinishedToClient(); |
| 573 } | 569 } |
| 574 | 570 |
| 575 ScriptStreamer::ScriptStreamer(PendingScript* script, Type scriptType, ScriptSta
te* scriptState, v8::ScriptCompiler::CompileOptions compileOptions, WebTaskRunne
r* loadingTaskRunner) | 571 ScriptStreamer::ScriptStreamer(PendingScript* script, Type scriptType, ScriptSta
te* scriptState, v8::ScriptCompiler::CompileOptions compileOptions, WebTaskRunne
r* loadingTaskRunner) |
| 576 : m_pendingScript(script) | 572 : m_pendingScript(script) |
| 577 , m_resource(script->resource()) | 573 , m_resource(script->resource()) |
| 578 , m_detached(false) | 574 , m_detached(false) |
| 579 , m_stream(0) | 575 , m_stream(0) |
| 580 , m_loadingFinished(false) | 576 , m_loadingFinished(false) |
| 581 , m_parsingFinished(false) | 577 , m_parsingFinished(false) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 | 666 |
| 671 // The Resource might go out of scope if the script is no longer | 667 // The Resource might go out of scope if the script is no longer |
| 672 // needed. This makes PendingScript notify the ScriptStreamer when it is | 668 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 673 // destroyed. | 669 // destroyed. |
| 674 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); | 670 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); |
| 675 | 671 |
| 676 return true; | 672 return true; |
| 677 } | 673 } |
| 678 | 674 |
| 679 } // namespace blink | 675 } // namespace blink |
| OLD | NEW |