Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.h

Issue 2830533002: Split ScriptStreamer and ScriptStreamerImpl, preparing for unit testing (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.h
similarity index 63%
copy from third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h
copy to third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.h
index 81c2f92db03a8ad5b2fd4671fd7677a5bee2de32..5a4c94401eb8c3f46e60bf7fc4d61e26e42d06a0 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamerImpl.h
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ScriptStreamer_h
-#define ScriptStreamer_h
+#ifndef ScriptStreamerImpl_h
+#define ScriptStreamerImpl_h
#include <memory>
+#include "bindings/core/v8/ScriptStreamer.h"
#include "core/CoreExport.h"
#include "platform/heap/Handle.h"
#include "platform/wtf/Noncopyable.h"
@@ -23,21 +24,11 @@ class Settings;
class SourceStream;
class WebTaskRunner;
-// ScriptStreamer streams incomplete script data to V8 so that it can be parsed
-// while it's loaded. PendingScript holds a reference to ScriptStreamer. At the
-// moment, ScriptStreamer is only used for parser blocking scripts; this means
-// that the Document stays stable and no other scripts are executing while we're
-// streaming. It is possible, though, that Document and the PendingScript are
-// destroyed while the streaming is in progress, and ScriptStreamer handles it
-// gracefully.
-class CORE_EXPORT ScriptStreamer final
- : public GarbageCollectedFinalized<ScriptStreamer> {
- WTF_MAKE_NONCOPYABLE(ScriptStreamer);
+class CORE_EXPORT ScriptStreamerImpl final : public ScriptStreamer {
+ WTF_MAKE_NONCOPYABLE(ScriptStreamerImpl);
public:
- enum Type { kParsingBlocking, kDeferred, kAsync };
-
- ~ScriptStreamer();
+ ~ScriptStreamerImpl();
DECLARE_TRACE();
// Launches a task (on a background thread) which will stream the given
@@ -52,29 +43,12 @@ class CORE_EXPORT ScriptStreamer final
static bool ConvertEncoding(const char* encoding_name,
v8::ScriptCompiler::StreamedSource::Encoding*);
- bool IsFinished() const;
-
- v8::ScriptCompiler::StreamedSource* Source() { return source_.get(); }
- ScriptResource* GetResource() const { return resource_; }
-
- // Called when the script is not needed any more (e.g., loading was
- // cancelled). After calling cancel, PendingScript can drop its reference to
- // ScriptStreamer, and ScriptStreamer takes care of eventually deleting
- // itself (after the V8 side has finished too).
- void Cancel();
+ v8::ScriptCompiler::StreamedSource* Source() override {
+ return source_.get();
+ }
+ ScriptResource* GetResource() const override { return resource_; }
- // When the streaming is suppressed, the data is not given to V8, but
- // ScriptStreamer still watches the resource load and notifies the upper
- // layers when loading is finished. It is used in situations when we have
- // started streaming but then we detect we don't want to stream (e.g., when
- // we have the code cache for the script) and we still want to parse and
- // execute it when it has finished loading.
void SuppressStreaming();
- bool StreamingSuppressed() const { return streaming_suppressed_; }
-
- // Called by PendingScript when data arrives from the network.
- void NotifyAppendData(ScriptResource*);
- void NotifyFinished(Resource*);
// Called by ScriptStreamingTask when it has streamed all data to V8 and V8
// has processed it.
@@ -94,24 +68,31 @@ class CORE_EXPORT ScriptStreamer final
// streamed. Non-const for testing.
static size_t small_script_threshold_;
- static ScriptStreamer* Create(
+ static ScriptStreamerImpl* Create(
PendingScript* script,
Type script_type,
ScriptState* script_state,
v8::ScriptCompiler::CompileOptions compile_options,
RefPtr<WebTaskRunner> loading_task_runner) {
- return new ScriptStreamer(script, script_type, script_state,
- compile_options, std::move(loading_task_runner));
+ return new ScriptStreamerImpl(script, script_type, script_state,
+ compile_options,
+ std::move(loading_task_runner));
}
- ScriptStreamer(PendingScript*,
- Type,
- ScriptState*,
- v8::ScriptCompiler::CompileOptions,
- RefPtr<WebTaskRunner>);
+ ScriptStreamerImpl(PendingScript*,
+ Type,
+ ScriptState*,
+ v8::ScriptCompiler::CompileOptions,
+ RefPtr<WebTaskRunner>);
void StreamingComplete();
void NotifyFinishedToClient();
+ bool IsFinished() const override;
+ bool StreamingSuppressed() const override { return streaming_suppressed_; }
+ void NotifyAppendData(ScriptResource*) override;
+ void NotifyFinished(Resource*) override;
+ void Cancel() override;
+
static bool StartStreamingInternal(PendingScript*,
Type,
Settings*,

Powered by Google App Engine
This is Rietveld 408576698