| 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 "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/ScriptStreamer.h" | 6 #include "bindings/core/v8/ScriptStreamer.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptStreamerThread.h" | 8 #include "bindings/core/v8/ScriptStreamerThread.h" |
| 9 #include "bindings/core/v8/V8ScriptRunner.h" | 9 #include "bindings/core/v8/V8ScriptRunner.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| 11 #include "core/dom/Element.h" | 11 #include "core/dom/Element.h" |
| 12 #include "core/dom/PendingScript.h" | 12 #include "core/dom/PendingScript.h" |
| 13 #include "core/fetch/ScriptResource.h" | 13 #include "core/fetch/ScriptResource.h" |
| 14 #include "core/frame/Settings.h" | 14 #include "core/frame/Settings.h" |
| 15 #include "core/html/parser/TextResourceDecoder.h" | 15 #include "core/html/parser/TextResourceDecoder.h" |
| 16 #include "platform/SharedBuffer.h" | 16 #include "platform/SharedBuffer.h" |
| 17 #include "platform/Task.h" |
| 17 #include "platform/ThreadSafeFunctional.h" | 18 #include "platform/ThreadSafeFunctional.h" |
| 18 #include "platform/TraceEvent.h" | 19 #include "platform/TraceEvent.h" |
| 19 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
| 20 #include "wtf/MainThread.h" | 21 #include "wtf/MainThread.h" |
| 21 #include "wtf/text/TextEncodingRegistry.h" | 22 #include "wtf/text/TextEncodingRegistry.h" |
| 22 | 23 |
| 23 namespace blink { | 24 namespace blink { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 m_source.clear(); | 423 m_source.clear(); |
| 423 Platform::current()->histogramEnumeration(notStreamingReasonHistogra
mName(m_scriptType), V8CannotStream, NotStreamingReasonEnd); | 424 Platform::current()->histogramEnumeration(notStreamingReasonHistogra
mName(m_scriptType), V8CannotStream, NotStreamingReasonEnd); |
| 424 Platform::current()->histogramEnumeration(startedStreamingHistogramN
ame(m_scriptType), 0, 2); | 425 Platform::current()->histogramEnumeration(startedStreamingHistogramN
ame(m_scriptType), 0, 2); |
| 425 return; | 426 return; |
| 426 } | 427 } |
| 427 | 428 |
| 428 // ScriptStreamer needs to stay alive as long as the background task is | 429 // ScriptStreamer needs to stay alive as long as the background task is |
| 429 // running. This is taken care of with a manual ref() & deref() pair; | 430 // running. This is taken care of with a manual ref() & deref() pair; |
| 430 // the corresponding deref() is in streamingComplete. | 431 // the corresponding deref() is in streamingComplete. |
| 431 ref(); | 432 ref(); |
| 432 ScriptStreamingTask* task = new ScriptStreamingTask(scriptStreamingTask.
release(), this); | 433 ScriptStreamerThread::shared()->postTask(new Task(threadSafeBind(&Script
StreamerThread::runScriptStreamingTask, scriptStreamingTask.release(), AllowCros
sThreadAccess(this)))); |
| 433 ScriptStreamerThread::shared()->postTask(task); | |
| 434 Platform::current()->histogramEnumeration(startedStreamingHistogramName(
m_scriptType), 1, 2); | 434 Platform::current()->histogramEnumeration(startedStreamingHistogramName(
m_scriptType), 1, 2); |
| 435 } | 435 } |
| 436 if (m_stream) | 436 if (m_stream) |
| 437 m_stream->didReceiveData(this, lengthOfBOM); | 437 m_stream->didReceiveData(this, lengthOfBOM); |
| 438 } | 438 } |
| 439 | 439 |
| 440 void ScriptStreamer::notifyFinished(Resource* resource) | 440 void ScriptStreamer::notifyFinished(Resource* resource) |
| 441 { | 441 { |
| 442 ASSERT(isMainThread()); | 442 ASSERT(isMainThread()); |
| 443 ASSERT(m_resource == resource); | 443 ASSERT(m_resource == resource); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 567 |
| 568 // The Resource might go out of scope if the script is no longer | 568 // The Resource might go out of scope if the script is no longer |
| 569 // needed. This makes PendingScript notify the ScriptStreamer when it is | 569 // needed. This makes PendingScript notify the ScriptStreamer when it is |
| 570 // destroyed. | 570 // destroyed. |
| 571 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption)); | 571 script.setStreamer(ScriptStreamer::create(resource, scriptType, scriptState,
compileOption)); |
| 572 | 572 |
| 573 return true; | 573 return true; |
| 574 } | 574 } |
| 575 | 575 |
| 576 } // namespace blink | 576 } // namespace blink |
| OLD | NEW |