| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 void ScriptStreamer::streamingCompleteOnBackgroundThread() | 432 void ScriptStreamer::streamingCompleteOnBackgroundThread() |
| 433 { | 433 { |
| 434 ASSERT(!isMainThread()); | 434 ASSERT(!isMainThread()); |
| 435 { | 435 { |
| 436 MutexLocker locker(m_mutex); | 436 MutexLocker locker(m_mutex); |
| 437 m_parsingFinished = true; | 437 m_parsingFinished = true; |
| 438 } | 438 } |
| 439 | 439 |
| 440 // notifyFinished might already be called, or it might be called in the | 440 // notifyFinished might already be called, or it might be called in the |
| 441 // future (if the parsing finishes earlier because of a parse error). | 441 // future (if the parsing finishes earlier because of a parse error). |
| 442 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ScriptStreame
r::streamingComplete, AllowCrossThreadAccess(this))); | 442 m_loadingTaskRunner->postTask(BLINK_FROM_HERE, threadSafeBind(&ScriptStreame
r::streamingComplete, wrapCrossThreadPersistent(this))); |
| 443 | 443 |
| 444 // The task might delete ScriptStreamer, so it's not safe to do anything | 444 // The task might delete ScriptStreamer, so it's not safe to do anything |
| 445 // after posting it. Note that there's no way to guarantee that this | 445 // after posting it. Note that there's no way to guarantee that this |
| 446 // function has returned before the task is ran - however, we should not | 446 // function has returned before the task is ran - however, we should not |
| 447 // access the "this" object after posting the task. (Especially, we should | 447 // access the "this" object after posting the task. (Especially, we should |
| 448 // not be holding the mutex at this point.) | 448 // not be holding the mutex at this point.) |
| 449 } | 449 } |
| 450 | 450 |
| 451 void ScriptStreamer::cancel() | 451 void ScriptStreamer::cancel() |
| 452 { | 452 { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.clear(); |
| 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)), AllowCros
sThreadAccess(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); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void ScriptStreamer::notifyFinished(Resource* resource) | 557 void ScriptStreamer::notifyFinished(Resource* resource) |
| 558 { | 558 { |
| 559 ASSERT(isMainThread()); | 559 ASSERT(isMainThread()); |
| 560 ASSERT(m_resource == resource); | 560 ASSERT(m_resource == resource); |
| (...skipping 111 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 |