Oilpan: move ScriptLoader to the heap.

So as to be able to trace its PendingScript part object.

R=haraken
BUG=

Review URL: https://codereview.chromium.org/660233002

git-svn-id: svn://svn.chromium.org/blink/trunk@183909 bbb929c8-8fbe-4397-9dbb-9b2b20218538
diff --git a/third_party/WebKit/Source/core/dom/PendingScript.h b/third_party/WebKit/Source/core/dom/PendingScript.h
index 049d34c5..d0694da 100644
--- a/third_party/WebKit/Source/core/dom/PendingScript.h
+++ b/third_party/WebKit/Source/core/dom/PendingScript.h
@@ -128,6 +128,6 @@
     RefPtr<ScriptStreamer> m_streamer;
 };
 
-}
+} // namespace blink
 
-#endif
+#endif // PendingScript_h
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
index e51592d..f9ba836 100644
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
@@ -78,6 +78,12 @@
     m_pendingScript.stopWatchingForLoad(this);
 }
 
+void ScriptLoader::trace(Visitor* visitor)
+{
+    visitor->trace(m_element);
+    visitor->trace(m_pendingScript);
+}
+
 void ScriptLoader::didNotifySubtreeInsertionsToDocument()
 {
     if (!m_parserInserted)
@@ -366,7 +372,8 @@
     ASSERT(m_pendingScript.resource());
     bool errorOccurred = false;
     ScriptSourceCode source = m_pendingScript.getSource(KURL(), errorOccurred);
-    RefPtr<Element> element = m_pendingScript.releaseElementAndClear();
+    RefPtrWillBeRawPtr<Element> element = m_pendingScript.releaseElementAndClear();
+    ALLOW_UNUSED_LOCAL(element);
     if (errorOccurred) {
         dispatchErrorEvent();
     } else if (!m_resource->wasCanceled()) {
@@ -449,4 +456,4 @@
     return 0;
 }
 
-}
+} // namespace blink
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.h b/third_party/WebKit/Source/core/dom/ScriptLoader.h
index d657e831..128b1fee 100644
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.h
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.h
@@ -36,10 +36,15 @@
 class ScriptSourceCode;
 
 
-class ScriptLoader final : private ScriptResourceClient {
+class ScriptLoader final : public NoBaseWillBeGarbageCollectedFinalized<ScriptLoader>, private ScriptResourceClient {
 public:
-    static PassOwnPtr<ScriptLoader> create(Element*, bool createdByParser, bool isEvaluated);
+    static PassOwnPtrWillBeRawPtr<ScriptLoader> create(Element* element, bool createdByParser, bool isEvaluated)
+    {
+        return adoptPtrWillBeNoop(new ScriptLoader(element, createdByParser, isEvaluated));
+    }
+
     virtual ~ScriptLoader();
+    virtual void trace(Visitor*);
 
     Element* element() const { return m_element; }
 
@@ -88,10 +93,14 @@
     // ResourceClient
     virtual void notifyFinished(Resource*) override;
 
-    // FIXME: Oilpan: This should become a Member once ResourceClient is moved to the heap.
-    Element* m_element;
+    RawPtrWillBeMember<Element> m_element;
     ResourcePtr<ScriptResource> m_resource;
     WTF::OrdinalNumber m_startLineNumber;
+    String m_characterEncoding;
+    String m_fallbackCharacterEncoding;
+
+    PendingScript m_pendingScript;
+
     bool m_parserInserted : 1;
     bool m_isExternalScript : 1;
     bool m_alreadyStarted : 1;
@@ -101,20 +110,10 @@
     bool m_willExecuteWhenDocumentFinishedParsing : 1;
     bool m_forceAsync : 1;
     bool m_willExecuteInOrder : 1;
-    String m_characterEncoding;
-    String m_fallbackCharacterEncoding;
-
-    PendingScript m_pendingScript;
 };
 
 ScriptLoader* toScriptLoaderIfPossible(Element*);
 
-inline PassOwnPtr<ScriptLoader> ScriptLoader::create(Element* element, bool createdByParser, bool isEvaluated)
-{
-    return adoptPtr(new ScriptLoader(element, createdByParser, isEvaluated));
-}
+} // namespace blink
 
-}
-
-
-#endif
+#endif // ScriptLoader_h
diff --git a/third_party/WebKit/Source/core/dom/ScriptRunner.cpp b/third_party/WebKit/Source/core/dom/ScriptRunner.cpp
index 6246a00a..539d9c9 100644
--- a/third_party/WebKit/Source/core/dom/ScriptRunner.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptRunner.cpp
@@ -123,7 +123,7 @@
 
     RefPtrWillBeRawPtr<Document> protect(m_document.get());
 
-    Vector<ScriptLoader*> scriptLoaders;
+    WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > scriptLoaders;
     scriptLoaders.swap(m_scriptsToExecuteSoon);
 
     size_t numInOrderScriptsToExecute = 0;
diff --git a/third_party/WebKit/Source/core/dom/ScriptRunner.h b/third_party/WebKit/Source/core/dom/ScriptRunner.h
index e323647..6cc7568 100644
--- a/third_party/WebKit/Source/core/dom/ScriptRunner.h
+++ b/third_party/WebKit/Source/core/dom/ScriptRunner.h
@@ -69,9 +69,10 @@
     void addPendingAsyncScript(ScriptLoader*);
 
     RawPtrWillBeMember<Document> m_document;
-    Vector<ScriptLoader*> m_scriptsToExecuteInOrder;
-    Vector<ScriptLoader*> m_scriptsToExecuteSoon; // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible
-    HashSet<ScriptLoader*> m_pendingAsyncScripts;
+    WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > m_scriptsToExecuteInOrder;
+    // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible
+    WillBeHeapVector<RawPtrWillBeMember<ScriptLoader> > m_scriptsToExecuteSoon;
+    WillBeHeapHashSet<RawPtrWillBeMember<ScriptLoader> > m_pendingAsyncScripts;
     Timer<ScriptRunner> m_timer;
 };
 
diff --git a/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp b/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
index bdf6202..7379934 100644
--- a/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLScriptElement.cpp
@@ -208,4 +208,10 @@
     return adoptRefWillBeNoop(new HTMLScriptElement(document(), false, m_loader->alreadyStarted()));
 }
 
+void HTMLScriptElement::trace(Visitor* visitor)
+{
+    visitor->trace(m_loader);
+    HTMLElement::trace(visitor);
+}
+
 }
diff --git a/third_party/WebKit/Source/core/html/HTMLScriptElement.h b/third_party/WebKit/Source/core/html/HTMLScriptElement.h
index f829b6d..21a1396 100644
--- a/third_party/WebKit/Source/core/html/HTMLScriptElement.h
+++ b/third_party/WebKit/Source/core/html/HTMLScriptElement.h
@@ -46,6 +46,8 @@
 
     ScriptLoader* loader() const { return m_loader.get(); }
 
+    virtual void trace(Visitor*) override;
+
 private:
     HTMLScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted);
 
@@ -74,7 +76,7 @@
 
     virtual PassRefPtrWillBeRawPtr<Element> cloneElementWithoutAttributesAndChildren() override;
 
-    OwnPtr<ScriptLoader> m_loader;
+    OwnPtrWillBeMember<ScriptLoader> m_loader;
 };
 
 } // namespace blink
diff --git a/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp b/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
index 0cccde2..6ad25fec 100644
--- a/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
+++ b/third_party/WebKit/Source/core/svg/SVGScriptElement.cpp
@@ -178,4 +178,10 @@
 }
 #endif
 
+void SVGScriptElement::trace(Visitor* visitor)
+{
+    visitor->trace(m_loader);
+    SVGElement::trace(visitor);
 }
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/core/svg/SVGScriptElement.h b/third_party/WebKit/Source/core/svg/SVGScriptElement.h
index cd32c659..3b728a17 100644
--- a/third_party/WebKit/Source/core/svg/SVGScriptElement.h
+++ b/third_party/WebKit/Source/core/svg/SVGScriptElement.h
@@ -46,6 +46,8 @@
     virtual bool isAnimatableAttribute(const QualifiedName&) const override;
 #endif
 
+    virtual void trace(Visitor*) override;
+
 private:
     SVGScriptElement(Document&, bool wasInsertedByParser, bool alreadyStarted);
     virtual ~SVGScriptElement();
@@ -80,9 +82,8 @@
 
     virtual Timer<SVGElement>* svgLoadEventTimer() override { return &m_svgLoadEventTimer; }
 
-
     Timer<SVGElement> m_svgLoadEventTimer;
-    OwnPtr<ScriptLoader> m_loader;
+    OwnPtrWillBeMember<ScriptLoader> m_loader;
 };
 
 } // namespace blink