OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google, Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef PendingScript_h | 26 #ifndef PendingScript_h |
27 #define PendingScript_h | 27 #define PendingScript_h |
28 | 28 |
29 #include "core/fetch/ResourceClient.h" | 29 #include "core/fetch/ResourceClient.h" |
30 #include "core/fetch/ResourceOwner.h" | 30 #include "core/fetch/ResourceOwner.h" |
31 #include "core/fetch/ScriptResource.h" | 31 #include "core/fetch/ScriptResource.h" |
32 #include "platform/heap/Handle.h" | |
32 #include "wtf/PassRefPtr.h" | 33 #include "wtf/PassRefPtr.h" |
33 #include "wtf/RefPtr.h" | 34 #include "wtf/RefPtr.h" |
34 #include "wtf/text/TextPosition.h" | 35 #include "wtf/text/TextPosition.h" |
35 | 36 |
36 namespace WebCore { | 37 namespace WebCore { |
37 | 38 |
38 class Element; | 39 class Element; |
39 class ScriptResource; | 40 class ScriptResource; |
40 | 41 |
41 // A container for an external script which may be loaded and executed. | 42 // A container for an external script which may be loaded and executed. |
42 // | 43 // |
43 // A ResourcePtr alone does not prevent the underlying Resource | 44 // A ResourcePtr alone does not prevent the underlying Resource |
44 // from purging its data buffer. This class holds a dummy client open for its | 45 // from purging its data buffer. This class holds a dummy client open for its |
45 // lifetime in order to guarantee that the data buffer will not be purged. | 46 // lifetime in order to guarantee that the data buffer will not be purged. |
46 class PendingScript : public ResourceOwner<ScriptResource> { | 47 class PendingScript FINAL : public ResourceOwner<ScriptResource> { |
47 public: | 48 public: |
48 PendingScript() | 49 PendingScript() |
49 : m_watchingForLoad(false) | 50 : m_watchingForLoad(false) |
50 , m_startingPosition(TextPosition::belowRangePosition()) | 51 , m_startingPosition(TextPosition::belowRangePosition()) |
51 { | 52 { |
52 } | 53 } |
53 | 54 |
54 PendingScript(Element* element, ScriptResource* resource) | 55 PendingScript(Element* element, ScriptResource* resource) |
55 : m_watchingForLoad(false) | 56 : m_watchingForLoad(false) |
56 , m_element(element) | 57 , m_element(element) |
(...skipping 26 matching lines...) Expand all Loading... | |
83 } | 84 } |
84 | 85 |
85 TextPosition startingPosition() const { return m_startingPosition; } | 86 TextPosition startingPosition() const { return m_startingPosition; } |
86 void setStartingPosition(const TextPosition& position) { m_startingPosition = position; } | 87 void setStartingPosition(const TextPosition& position) { m_startingPosition = position; } |
87 | 88 |
88 bool watchingForLoad() const { return m_watchingForLoad; } | 89 bool watchingForLoad() const { return m_watchingForLoad; } |
89 void setWatchingForLoad(bool b) { m_watchingForLoad = b; } | 90 void setWatchingForLoad(bool b) { m_watchingForLoad = b; } |
90 | 91 |
91 Element* element() const { return m_element.get(); } | 92 Element* element() const { return m_element.get(); } |
92 void setElement(Element* element) { m_element = element; } | 93 void setElement(Element* element) { m_element = element; } |
93 PassRefPtr<Element> releaseElementAndClear(); | 94 PassRefPtrWillBeRawPtr<Element> releaseElementAndClear(); |
94 | 95 |
95 void setScriptResource(ScriptResource*); | 96 void setScriptResource(ScriptResource*); |
96 | 97 |
97 virtual void notifyFinished(Resource*); | 98 virtual void notifyFinished(Resource*); |
98 | 99 |
100 void trace(Visitor*); | |
101 | |
99 private: | 102 private: |
100 bool m_watchingForLoad; | 103 bool m_watchingForLoad; |
101 RefPtr<Element> m_element; | 104 // FIXME: Oilpan: PendingScript must trace its script element, but |
105 // turning the object into a GCed object is problematic. Due to | |
106 // external ownership arrangements: a PendingScript is | |
107 // conceptually owned by a script runner object, which when | |
108 // finalized will have to coordinate the release of the pending | |
109 // script resource with that of its owner/host | |
110 // (cf. HTMLScriptRunner finalization.) Doing that when host + | |
111 // owner + PendingScript are all heap allocated and independently | |
112 // finalized is not easily achieveable, hence we currently keep | |
113 // PendingScript off heap, along with its immediate owner. | |
haraken
2014/05/26 01:08:25
Hmm, can we probably address the issue using weak
sof
2014/05/26 09:41:34
If HTMLScriptRunner and HTMLDocumentParser both di
Mads Ager (chromium)
2014/05/26 13:55:36
Yeah, I see the issue. For now I think we need to
sof
2014/05/26 21:10:18
That gave me an idea -- if HTMLScriptRunner is mad
| |
114 // | |
115 // Do want to trace() PendingScripts, so we do annotate the | |
116 // element as being a Member, but disable GC plugin checks for it. | |
117 GC_PLUGIN_IGNORE("357163") | |
118 RefPtrWillBeMember<Element> m_element; | |
102 TextPosition m_startingPosition; // Only used for inline script tags. | 119 TextPosition m_startingPosition; // Only used for inline script tags. |
103 }; | 120 }; |
104 | 121 |
105 } | 122 } |
106 | 123 |
107 #endif | 124 #endif |
OLD | NEW |