| Index: third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.cpp
|
| similarity index 92%
|
| rename from third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
|
| rename to third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.cpp
|
| index b60b02b9cf4110718e8006e4e30cff44e567b863..33371b16fe92ae558f97a5c387645be307e5aea1 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.cpp
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "bindings/core/v8/ScriptStreamer.h"
|
| +#include "bindings/core/v8/ScriptStreamerImpl.h"
|
|
|
| #include <memory>
|
| #include "bindings/core/v8/ScriptStreamerThread.h"
|
| @@ -185,7 +185,7 @@ class SourceStream : public v8::ScriptCompiler::ExternalSourceStream {
|
| queue_tail_position_(0),
|
| loading_task_runner_(std::move(loading_task_runner)) {}
|
|
|
| - virtual ~SourceStream() override {}
|
| + ~SourceStream() override {}
|
|
|
| // Called by V8 on a background thread. Should block until we can return
|
| // some data.
|
| @@ -214,7 +214,7 @@ class SourceStream : public v8::ScriptCompiler::ExternalSourceStream {
|
| data_queue_.Finish();
|
| }
|
|
|
| - void DidReceiveData(ScriptStreamer* streamer) {
|
| + void DidReceiveData(ScriptStreamerImpl* streamer) {
|
| DCHECK(IsMainThread());
|
| PrepareDataOnMainThread(streamer);
|
| }
|
| @@ -234,7 +234,7 @@ class SourceStream : public v8::ScriptCompiler::ExternalSourceStream {
|
| }
|
|
|
| private:
|
| - void PrepareDataOnMainThread(ScriptStreamer* streamer) {
|
| + void PrepareDataOnMainThread(ScriptStreamerImpl* streamer) {
|
| DCHECK(IsMainThread());
|
|
|
| if (cancelled_) {
|
| @@ -325,13 +325,14 @@ class SourceStream : public v8::ScriptCompiler::ExternalSourceStream {
|
| RefPtr<WebTaskRunner> loading_task_runner_;
|
| };
|
|
|
| -size_t ScriptStreamer::small_script_threshold_ = 30 * 1024;
|
| +size_t ScriptStreamerImpl::small_script_threshold_ = 30 * 1024;
|
|
|
| -void ScriptStreamer::StartStreaming(PendingScript* script,
|
| - Type script_type,
|
| - Settings* settings,
|
| - ScriptState* script_state,
|
| - RefPtr<WebTaskRunner> loading_task_runner) {
|
| +void ScriptStreamerImpl::StartStreaming(
|
| + PendingScript* script,
|
| + Type script_type,
|
| + Settings* settings,
|
| + ScriptState* script_state,
|
| + RefPtr<WebTaskRunner> loading_task_runner) {
|
| // We don't yet know whether the script will really be streamed. E.g.,
|
| // suppressing streaming for short scripts is done later. Record only the
|
| // sure negative cases here.
|
| @@ -342,7 +343,7 @@ void ScriptStreamer::StartStreaming(PendingScript* script,
|
| RecordStartedStreamingHistogram(script_type, 0);
|
| }
|
|
|
| -bool ScriptStreamer::ConvertEncoding(
|
| +bool ScriptStreamerImpl::ConvertEncoding(
|
| const char* encoding_name,
|
| v8::ScriptCompiler::StreamedSource::Encoding* encoding) {
|
| // Here's a list of encodings we can use for streaming. These are
|
| @@ -364,27 +365,27 @@ bool ScriptStreamer::ConvertEncoding(
|
| return false;
|
| }
|
|
|
| -bool ScriptStreamer::IsFinished() const {
|
| +bool ScriptStreamerImpl::IsFinished() const {
|
| DCHECK(IsMainThread());
|
| return loading_finished_ && (parsing_finished_ || streaming_suppressed_);
|
| }
|
|
|
| -void ScriptStreamer::StreamingCompleteOnBackgroundThread() {
|
| +void ScriptStreamerImpl::StreamingCompleteOnBackgroundThread() {
|
| DCHECK(!IsMainThread());
|
|
|
| // notifyFinished might already be called, or it might be called in the
|
| // future (if the parsing finishes earlier because of a parse error).
|
| loading_task_runner_->PostTask(
|
| - BLINK_FROM_HERE, CrossThreadBind(&ScriptStreamer::StreamingComplete,
|
| + BLINK_FROM_HERE, CrossThreadBind(&ScriptStreamerImpl::StreamingComplete,
|
| WrapCrossThreadPersistent(this)));
|
|
|
| - // The task might delete ScriptStreamer, so it's not safe to do anything
|
| + // The task might delete ScriptStreamerImpl, so it's not safe to do anything
|
| // after posting it. Note that there's no way to guarantee that this
|
| // function has returned before the task is ran - however, we should not
|
| // access the "this" object after posting the task.
|
| }
|
|
|
| -void ScriptStreamer::Cancel() {
|
| +void ScriptStreamerImpl::Cancel() {
|
| DCHECK(IsMainThread());
|
| // The upper layer doesn't need the script any more, but streaming might
|
| // still be ongoing. Tell SourceStream to try to cancel it whenever it gets
|
| @@ -396,7 +397,7 @@ void ScriptStreamer::Cancel() {
|
| stream_->Cancel();
|
| }
|
|
|
| -void ScriptStreamer::SuppressStreaming() {
|
| +void ScriptStreamerImpl::SuppressStreaming() {
|
| DCHECK(IsMainThread());
|
| DCHECK(!loading_finished_);
|
| // It can be that the parsing task has already finished (e.g., if there was
|
| @@ -404,7 +405,7 @@ void ScriptStreamer::SuppressStreaming() {
|
| streaming_suppressed_ = true;
|
| }
|
|
|
| -void ScriptStreamer::NotifyAppendData(ScriptResource* resource) {
|
| +void ScriptStreamerImpl::NotifyAppendData(ScriptResource* resource) {
|
| DCHECK(IsMainThread());
|
| CHECK_EQ(resource_, resource);
|
| if (streaming_suppressed_)
|
| @@ -497,7 +498,7 @@ void ScriptStreamer::NotifyAppendData(ScriptResource* resource) {
|
| stream_->DidReceiveData(this);
|
| }
|
|
|
| -void ScriptStreamer::NotifyFinished(Resource* resource) {
|
| +void ScriptStreamerImpl::NotifyFinished(Resource* resource) {
|
| DCHECK(IsMainThread());
|
| CHECK_EQ(resource_, resource);
|
| // A special case: empty and small scripts. We didn't receive enough data to
|
| @@ -516,7 +517,7 @@ void ScriptStreamer::NotifyFinished(Resource* resource) {
|
| NotifyFinishedToClient();
|
| }
|
|
|
| -ScriptStreamer::ScriptStreamer(
|
| +ScriptStreamerImpl::ScriptStreamerImpl(
|
| PendingScript* script,
|
| Type script_type,
|
| ScriptState* script_state,
|
| @@ -540,14 +541,15 @@ ScriptStreamer::ScriptStreamer(
|
| encoding_(v8::ScriptCompiler::StreamedSource::TWO_BYTE),
|
| loading_task_runner_(std::move(loading_task_runner)) {}
|
|
|
| -ScriptStreamer::~ScriptStreamer() {}
|
| +ScriptStreamerImpl::~ScriptStreamerImpl() {}
|
|
|
| -DEFINE_TRACE(ScriptStreamer) {
|
| +DEFINE_TRACE(ScriptStreamerImpl) {
|
| visitor->Trace(pending_script_);
|
| visitor->Trace(resource_);
|
| + ScriptStreamer::Trace(visitor);
|
| }
|
|
|
| -void ScriptStreamer::StreamingComplete() {
|
| +void ScriptStreamerImpl::StreamingComplete() {
|
| // The background task is completed; do the necessary ramp-down in the main
|
| // thread.
|
| DCHECK(IsMainThread());
|
| @@ -567,7 +569,7 @@ void ScriptStreamer::StreamingComplete() {
|
| NotifyFinishedToClient();
|
| }
|
|
|
| -void ScriptStreamer::NotifyFinishedToClient() {
|
| +void ScriptStreamerImpl::NotifyFinishedToClient() {
|
| DCHECK(IsMainThread());
|
| // Usually, the loading will be finished first, and V8 will still need some
|
| // time to catch up. But the other way is possible too: if V8 detects a
|
| @@ -580,7 +582,7 @@ void ScriptStreamer::NotifyFinishedToClient() {
|
| pending_script_->StreamingFinished();
|
| }
|
|
|
| -bool ScriptStreamer::StartStreamingInternal(
|
| +bool ScriptStreamerImpl::StartStreamingInternal(
|
| PendingScript* script,
|
| Type script_type,
|
| Settings* settings,
|
| @@ -615,12 +617,12 @@ bool ScriptStreamer::StartStreamingInternal(
|
| if (settings->GetV8CacheOptions() == kV8CacheOptionsParse)
|
| compile_option = v8::ScriptCompiler::kProduceParserCache;
|
|
|
| - // The Resource might go out of scope if the script is no longer
|
| - // needed. This makes PendingScript notify the ScriptStreamer when it is
|
| + // The Resource might go out of scope if the script is no longer needed.
|
| + // This makes PendingScript notify the ScriptStreamerImpl when it is
|
| // destroyed.
|
| - script->SetStreamer(ScriptStreamer::Create(script, script_type, script_state,
|
| - compile_option,
|
| - std::move(loading_task_runner)));
|
| + script->SetStreamer(ScriptStreamerImpl::Create(
|
| + script, script_type, script_state, compile_option,
|
| + std::move(loading_task_runner)));
|
|
|
| return true;
|
| }
|
|
|