| 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" |
| 11 #include "core/dom/PendingScript.h" | 11 #include "core/dom/PendingScript.h" |
| 12 #include "core/fetch/ScriptResource.h" | 12 #include "core/fetch/ScriptResource.h" |
| 13 #include "core/frame/Settings.h" | 13 #include "core/frame/Settings.h" |
| 14 #include "core/html/parser/TextResourceDecoder.h" | 14 #include "core/html/parser/TextResourceDecoder.h" |
| 15 #include "platform/Histogram.h" | 15 #include "platform/Histogram.h" |
| 16 #include "platform/SharedBuffer.h" | 16 #include "platform/SharedBuffer.h" |
| 17 #include "platform/Task.h" | |
| 18 #include "platform/ThreadSafeFunctional.h" | 17 #include "platform/ThreadSafeFunctional.h" |
| 19 #include "platform/TraceEvent.h" | 18 #include "platform/TraceEvent.h" |
| 20 #include "public/platform/WebScheduler.h" | 19 #include "public/platform/WebScheduler.h" |
| 21 #include "wtf/MainThread.h" | 20 #include "wtf/MainThread.h" |
| 22 #include "wtf/text/TextEncodingRegistry.h" | 21 #include "wtf/text/TextEncodingRegistry.h" |
| 23 | 22 |
| 24 namespace blink { | 23 namespace blink { |
| 25 | 24 |
| 26 namespace { | 25 namespace { |
| 27 | 26 |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 m_source.clear(); | 538 m_source.clear(); |
| 540 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); | 539 recordNotStreamingReasonHistogram(m_scriptType, V8CannotStream); |
| 541 recordStartedStreamingHistogram(m_scriptType, 0); | 540 recordStartedStreamingHistogram(m_scriptType, 0); |
| 542 return; | 541 return; |
| 543 } | 542 } |
| 544 | 543 |
| 545 // ScriptStreamer needs to stay alive as long as the background task is | 544 // ScriptStreamer needs to stay alive as long as the background task is |
| 546 // running. This is taken care of with a manual ref() & deref() pair; | 545 // running. This is taken care of with a manual ref() & deref() pair; |
| 547 // the corresponding deref() is in streamingComplete. | 546 // the corresponding deref() is in streamingComplete. |
| 548 ref(); | 547 ref(); |
| 549 ScriptStreamerThread::shared()->postTask(new Task(threadSafeBind(&Script
StreamerThread::runScriptStreamingTask, scriptStreamingTask.release(), AllowCros
sThreadAccess(this)))); | 548 ScriptStreamerThread::shared()->postTask(threadSafeBind(&ScriptStreamerT
hread::runScriptStreamingTask, scriptStreamingTask.release(), AllowCrossThreadAc
cess(this))); |
| 550 recordStartedStreamingHistogram(m_scriptType, 1); | 549 recordStartedStreamingHistogram(m_scriptType, 1); |
| 551 } | 550 } |
| 552 if (m_stream) | 551 if (m_stream) |
| 553 m_stream->didReceiveData(this, lengthOfBOM); | 552 m_stream->didReceiveData(this, lengthOfBOM); |
| 554 } | 553 } |
| 555 | 554 |
| 556 void ScriptStreamer::notifyFinished(Resource* resource) | 555 void ScriptStreamer::notifyFinished(Resource* resource) |
| 557 { | 556 { |
| 558 ASSERT(isMainThread()); | 557 ASSERT(isMainThread()); |
| 559 ASSERT(m_resource == resource); | 558 ASSERT(m_resource == resource); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 | 677 |
| 679 // The Resource might go out of scope if the script is no longer | 678 // The Resource might go out of scope if the script is no longer |
| 680 // needed. This makes PendingScript notify the ScriptStreamer when it is | 679 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 681 // destroyed. | 680 // destroyed. |
| 682 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); | 681 script->setStreamer(ScriptStreamer::create(script, scriptType, scriptState,
compileOption, loadingTaskRunner)); |
| 683 | 682 |
| 684 return true; | 683 return true; |
| 685 } | 684 } |
| 686 | 685 |
| 687 } // namespace blink | 686 } // namespace blink |
| OLD | NEW |