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 24 matching lines...) Expand all Loading... | |
35 #include "wtf/RefPtr.h" | 35 #include "wtf/RefPtr.h" |
36 #include "wtf/text/TextPosition.h" | 36 #include "wtf/text/TextPosition.h" |
37 | 37 |
38 namespace blink { | 38 namespace blink { |
39 | 39 |
40 class Element; | 40 class Element; |
41 class ScriptSourceCode; | 41 class ScriptSourceCode; |
42 | 42 |
43 // A container for an external script which may be loaded and executed. | 43 // A container for an external script which may be loaded and executed. |
44 // | 44 // |
45 // A ResourcePtr alone does not prevent the underlying Resource | 45 // A RefPtr alone does not prevent the underlying Resource |
46 // from purging its data buffer. This class holds a dummy client open for its | 46 // from purging its data buffer. This class holds a dummy client open for its |
47 // lifetime in order to guarantee that the data buffer will not be purged. | 47 // lifetime in order to guarantee that the data buffer will not be purged. |
48 class CORE_EXPORT PendingScript final : public NoBaseWillBeGarbageCollectedFinal ized<PendingScript>, public ResourceOwner<ScriptResource> { | 48 class CORE_EXPORT PendingScript final : public NoBaseWillBeGarbageCollectedFinal ized<PendingScript>, public ResourceOwner<ScriptResource> { |
49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PendingScript); | 49 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(PendingScript); |
50 WILL_BE_USING_PRE_FINALIZER(PendingScript, dispose); | |
50 public: | 51 public: |
51 static PassOwnPtrWillBeRawPtr<PendingScript> create(Element*, ScriptResource *); | 52 static PassOwnPtrWillBeRawPtr<PendingScript> create(Element*, ScriptResource *); |
52 ~PendingScript() override; | 53 ~PendingScript() override; |
53 | 54 |
54 PendingScript& operator=(const PendingScript&); | 55 PendingScript& operator=(const PendingScript&); |
55 | 56 |
56 TextPosition startingPosition() const { return m_startingPosition; } | 57 TextPosition startingPosition() const { return m_startingPosition; } |
57 void setStartingPosition(const TextPosition& position) { m_startingPosition = position; } | 58 void setStartingPosition(const TextPosition& position) { m_startingPosition = position; } |
58 | 59 |
59 void watchForLoad(ScriptResourceClient*); | 60 void watchForLoad(ScriptResourceClient*); |
60 void stopWatchingForLoad(ScriptResourceClient*); | 61 void stopWatchingForLoad(ScriptResourceClient*); |
61 | 62 |
62 Element* element() const { return m_element.get(); } | 63 Element* element() const { return m_element.get(); } |
63 void setElement(Element*); | 64 void setElement(Element*); |
64 PassRefPtrWillBeRawPtr<Element> releaseElementAndClear(); | 65 PassRefPtrWillBeRawPtr<Element> releaseElementAndClear(); |
65 | 66 |
66 void setScriptResource(ScriptResource*); | 67 void setScriptResource(ScriptResource*); |
67 | 68 |
68 void notifyFinished(Resource*) override; | 69 void notifyFinished(Resource*) override; |
69 String debugName() const override { return "PendingScript"; } | 70 String debugName() const override { return "PendingScript"; } |
70 void notifyAppendData(ScriptResource*) override; | 71 void notifyAppendData(ScriptResource*) override; |
71 | 72 |
72 DECLARE_TRACE(); | 73 DECLARE_TRACE(); |
73 | 74 |
74 ScriptSourceCode getSource(const KURL& documentURL, bool& errorOccurred) con st; | 75 ScriptSourceCode getSource(const KURL& documentURL, bool& errorOccurred) con st; |
75 | 76 |
76 void setStreamer(PassRefPtrWillBeRawPtr<ScriptStreamer>); | 77 void setStreamer(PassRefPtrWillBeRawPtr<ScriptStreamer>); |
78 void streamingFinished(); | |
77 | 79 |
78 bool isReady() const; | 80 bool isReady() const; |
79 | 81 |
82 void dispose(); | |
83 | |
80 private: | 84 private: |
81 PendingScript(Element*, ScriptResource*); | 85 PendingScript(Element*, ScriptResource*); |
82 | 86 |
83 bool m_watchingForLoad; | 87 bool m_watchingForLoad; |
84 RefPtrWillBeMember<Element> m_element; | 88 RefPtrWillBeMember<Element> m_element; |
85 TextPosition m_startingPosition; // Only used for inline script tags. | 89 TextPosition m_startingPosition; // Only used for inline script tags. |
86 bool m_integrityFailure; | 90 bool m_integrityFailure; |
87 | 91 |
88 RefPtrWillBeMember<ScriptStreamer> m_streamer; | 92 RefPtrWillBeMember<ScriptStreamer> m_streamer; |
93 ScriptResourceClient* m_client; | |
haraken
2016/02/04 23:56:30
In long term, we want to move ResourceClients to O
Nate Chapin
2016/02/06 00:34:07
Yep, someday :)
| |
89 }; | 94 }; |
90 | 95 |
91 } // namespace blink | 96 } // namespace blink |
92 | 97 |
93 #endif // PendingScript_h | 98 #endif // PendingScript_h |
OLD | NEW |