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 12 matching lines...) Expand all Loading... |
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 "bindings/core/v8/ScriptStreamer.h" | 29 #include "bindings/core/v8/ScriptStreamer.h" |
30 #include "core/CoreExport.h" | 30 #include "core/CoreExport.h" |
31 #include "core/fetch/ResourceOwner.h" | 31 #include "core/fetch/ResourceOwner.h" |
32 #include "core/fetch/ScriptResource.h" | 32 #include "core/fetch/ScriptResource.h" |
| 33 #include "platform/MemoryCoordinator.h" |
33 #include "platform/heap/Handle.h" | 34 #include "platform/heap/Handle.h" |
34 #include "wtf/Noncopyable.h" | 35 #include "wtf/Noncopyable.h" |
35 #include "wtf/text/TextPosition.h" | 36 #include "wtf/text/TextPosition.h" |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 class Element; | 40 class Element; |
40 class ScriptSourceCode; | 41 class ScriptSourceCode; |
41 | 42 |
42 // 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. |
43 // | 44 // |
44 // TODO(kochi): The comment below is from pre-oilpan age and may not be correct
now. | 45 // TODO(kochi): The comment below is from pre-oilpan age and may not be correct
now. |
45 // A RefPtr alone does not prevent the underlying Resource | 46 // A RefPtr alone does not prevent the underlying Resource |
46 // from purging its data buffer. This class holds a dummy client open for its | 47 // 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. | 48 // lifetime in order to guarantee that the data buffer will not be purged. |
48 class CORE_EXPORT PendingScript final : public GarbageCollectedFinalized<Pending
Script>, public ResourceOwner<ScriptResource> { | 49 class CORE_EXPORT PendingScript final : public GarbageCollectedFinalized<Pending
Script>, public ResourceOwner<ScriptResource>, public MemoryCoordinatorClient { |
49 USING_GARBAGE_COLLECTED_MIXIN(PendingScript); | 50 USING_GARBAGE_COLLECTED_MIXIN(PendingScript); |
50 USING_PRE_FINALIZER(PendingScript, dispose); | 51 USING_PRE_FINALIZER(PendingScript, dispose); |
51 WTF_MAKE_NONCOPYABLE(PendingScript); | 52 WTF_MAKE_NONCOPYABLE(PendingScript); |
52 public: | 53 public: |
53 static PendingScript* create(Element*, ScriptResource*); | 54 static PendingScript* create(Element*, ScriptResource*); |
54 ~PendingScript() override; | 55 ~PendingScript() override; |
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 void markParserBlockingLoadStartTime(); | 59 void markParserBlockingLoadStartTime(); |
(...skipping 22 matching lines...) Expand all Loading... |
81 void setStreamer(ScriptStreamer*); | 82 void setStreamer(ScriptStreamer*); |
82 void streamingFinished(); | 83 void streamingFinished(); |
83 | 84 |
84 bool isReady() const; | 85 bool isReady() const; |
85 bool errorOccurred() const; | 86 bool errorOccurred() const; |
86 | 87 |
87 void dispose(); | 88 void dispose(); |
88 | 89 |
89 private: | 90 private: |
90 PendingScript(Element*, ScriptResource*); | 91 PendingScript(Element*, ScriptResource*); |
| 92 PendingScript() = delete; |
| 93 |
| 94 void prepareToSuspend() override; |
91 | 95 |
92 bool m_watchingForLoad; | 96 bool m_watchingForLoad; |
93 Member<Element> m_element; | 97 Member<Element> m_element; |
94 TextPosition m_startingPosition; // Only used for inline script tags. | 98 TextPosition m_startingPosition; // Only used for inline script tags. |
95 bool m_integrityFailure; | 99 bool m_integrityFailure; |
96 double m_parserBlockingLoadStartTime; | 100 double m_parserBlockingLoadStartTime; |
97 | 101 |
98 Member<ScriptStreamer> m_streamer; | 102 Member<ScriptStreamer> m_streamer; |
99 Member<ScriptResourceClient> m_client; | 103 Member<ScriptResourceClient> m_client; |
100 }; | 104 }; |
101 | 105 |
102 } // namespace blink | 106 } // namespace blink |
103 | 107 |
104 #endif // PendingScript_h | 108 #endif // PendingScript_h |
OLD | NEW |