Chromium Code Reviews| Index: third_party/WebKit/Source/core/dom/PendingScript.h |
| diff --git a/third_party/WebKit/Source/core/dom/PendingScript.h b/third_party/WebKit/Source/core/dom/PendingScript.h |
| index 0be3dcfaacfa6df6aabdf69964b4fca89ff747e7..5969ac60e97c9dd80d305384b2326392b90df568 100644 |
| --- a/third_party/WebKit/Source/core/dom/PendingScript.h |
| +++ b/third_party/WebKit/Source/core/dom/PendingScript.h |
| @@ -28,18 +28,17 @@ |
| #include "bindings/core/v8/ScriptStreamer.h" |
| #include "core/CoreExport.h" |
| +#include "core/dom/Script.h" |
| #include "core/dom/ScriptElementBase.h" |
| -#include "core/loader/resource/ScriptResource.h" |
| -#include "platform/MemoryCoordinator.h" |
| #include "platform/heap/Handle.h" |
| -#include "platform/loader/fetch/ResourceOwner.h" |
| +#include "platform/weborigin/KURL.h" |
| #include "platform/wtf/Noncopyable.h" |
| #include "platform/wtf/text/TextPosition.h" |
| namespace blink { |
| +class Document; |
| class PendingScript; |
| -class ClassicScript; |
| class CORE_EXPORT PendingScriptClient : public GarbageCollectedMixin { |
| public: |
| @@ -54,30 +53,13 @@ class CORE_EXPORT PendingScriptClient : public GarbageCollectedMixin { |
| DEFINE_INLINE_VIRTUAL_TRACE() {} |
| }; |
| -// A container for an external script which may be loaded and executed. |
| -// |
| -// TODO(kochi): The comment below is from pre-oilpan age and may not be correct |
| -// now. |
| -// A RefPtr alone does not prevent the underlying Resource from purging its data |
| -// buffer. This class holds a dummy client open for its lifetime in order to |
| -// guarantee that the data buffer will not be purged. |
| -class CORE_EXPORT PendingScript final |
| - : public GarbageCollectedFinalized<PendingScript>, |
| - public ResourceOwner<ScriptResource>, |
| - public MemoryCoordinatorClient { |
| - USING_GARBAGE_COLLECTED_MIXIN(PendingScript); |
| +class CORE_EXPORT PendingScript |
|
haraken
2017/04/13 01:03:58
Add a class-level comment.
hiroshige
2017/04/13 17:08:31
Done.
|
| + : public GarbageCollectedFinalized<PendingScript> { |
| USING_PRE_FINALIZER(PendingScript, Dispose); |
| WTF_MAKE_NONCOPYABLE(PendingScript); |
| public: |
| - // For script from an external file. |
| - static PendingScript* Create(ScriptElementBase*, ScriptResource*); |
| - // For inline script. |
| - static PendingScript* Create(ScriptElementBase*, const TextPosition&); |
| - |
| - static PendingScript* CreateForTesting(ScriptResource*); |
| - |
| - ~PendingScript() override; |
| + virtual ~PendingScript(); |
| TextPosition StartingPosition() const { return starting_position_; } |
| void MarkParserBlockingLoadStartTime(); |
| @@ -93,37 +75,39 @@ class CORE_EXPORT PendingScript final |
| ScriptElementBase* GetElement() const; |
| - DECLARE_TRACE(); |
| + virtual ScriptType GetScriptType() const = 0; |
| + |
| + DECLARE_VIRTUAL_TRACE(); |
| + |
| + virtual Script* GetSource(const KURL& document_url, |
| + bool& error_occurred) const = 0; |
| - ClassicScript* GetSource(const KURL& document_url, |
| - bool& error_occurred) const; |
| + // https://html.spec.whatwg.org/#the-script-is-ready |
| + virtual bool IsReady() const = 0; |
| - void SetStreamer(ScriptStreamer*); |
| - void StreamingFinished(); |
| + virtual KURL Url() const = 0; |
| + virtual bool IsExternal() const = 0; |
| + virtual bool ErrorOccurred() const = 0; |
| + virtual bool WasCanceled() const = 0; |
| + virtual void StartStreamingIfPossible(Document*, ScriptStreamer::Type) = 0; |
| - bool IsReady() const; |
| - bool ErrorOccurred() const; |
| + // Used for document.write() intervention. |
| + // Has effects only for classic scripts. |
| + virtual void RemoveFromMemoryCache() = 0; |
| - void StartStreamingIfPossible(Document*, ScriptStreamer::Type); |
| void Dispose(); |
| - private: |
| - PendingScript(ScriptElementBase*, |
| - ScriptResource*, |
| - const TextPosition&, |
| - bool is_for_testing = false); |
| - PendingScript() = delete; |
| + protected: |
| + PendingScript(ScriptElementBase*, const TextPosition& starting_position); |
| - void CheckState() const; |
| + virtual void DisposeInternal() = 0; |
| - // ScriptResourceClient |
| - void NotifyFinished(Resource*) override; |
| - String DebugName() const override { return "PendingScript"; } |
| - void NotifyAppendData(ScriptResource*) override; |
| + PendingScriptClient* Client() { return client_; } |
| + bool IsWatchingForLoad() const { return watching_for_load_; } |
| - // MemoryCoordinatorClient |
| - void OnPurgeMemory() override; |
| + virtual void CheckState() const = 0; |
| + private: |
| bool watching_for_load_; |
| // |m_element| must points to the corresponding ScriptLoader's |
| @@ -132,15 +116,9 @@ class CORE_EXPORT PendingScript final |
| Member<ScriptElementBase> element_; |
| TextPosition starting_position_; // Only used for inline script tags. |
| - bool integrity_failure_; |
| double parser_blocking_load_start_time_; |
| - Member<ScriptStreamer> streamer_; |
| Member<PendingScriptClient> client_; |
| - |
| - // This flag is used to skip non-null checks of |m_element| in unit |
| - // tests, because |m_element| can be null in unit tests. |
| - const bool is_for_testing_; |
| }; |
| } // namespace blink |