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 | 35 |
36 PassOwnPtrWillBeRawPtr<PendingScript> PendingScript::create(Element* element, Sc riptResource* resource) | 36 PassOwnPtrWillBeRawPtr<PendingScript> PendingScript::create(Element* element, Sc riptResource* resource) |
37 { | 37 { |
38 return adoptPtrWillBeNoop(new PendingScript(element, resource)); | 38 return adoptPtrWillBeNoop(new PendingScript(element, resource)); |
39 } | 39 } |
40 | 40 |
41 PendingScript::PendingScript(Element* element, ScriptResource* resource) | 41 PendingScript::PendingScript(Element* element, ScriptResource* resource) |
42 : m_watchingForLoad(false) | 42 : m_watchingForLoad(false) |
43 , m_element(element) | 43 , m_element(element) |
44 , m_integrityFailure(false) | 44 , m_integrityFailure(false) |
45 , m_client(nullptr) | |
45 { | 46 { |
46 setScriptResource(resource); | 47 setScriptResource(resource); |
48 #if ENABLE(OILPAN) | |
49 ThreadState::current()->registerPreFinalizer(this); | |
50 #endif | |
47 } | 51 } |
48 | 52 |
49 PendingScript::~PendingScript() | 53 PendingScript::~PendingScript() |
50 { | 54 { |
51 } | 55 } |
52 | 56 |
57 void PendingScript::dispose() | |
Nate Chapin
2016/02/04 23:24:38
Moving the guts of ScriptLoader::detach here fixes
| |
58 { | |
59 if (!m_client) | |
60 return; | |
61 stopWatchingForLoad(m_client); | |
62 releaseElementAndClear(); | |
63 } | |
64 | |
53 PendingScript& PendingScript::operator=(const PendingScript& other) | 65 PendingScript& PendingScript::operator=(const PendingScript& other) |
54 { | 66 { |
55 if (this == &other) | 67 if (this == &other) |
56 return *this; | 68 return *this; |
57 | 69 |
58 m_watchingForLoad = other.m_watchingForLoad; | 70 m_watchingForLoad = other.m_watchingForLoad; |
59 m_element = other.m_element; | 71 m_element = other.m_element; |
60 m_startingPosition = other.m_startingPosition; | 72 m_startingPosition = other.m_startingPosition; |
61 m_integrityFailure = other.m_integrityFailure; | 73 m_integrityFailure = other.m_integrityFailure; |
62 m_streamer = other.m_streamer; | 74 m_streamer = other.m_streamer; |
63 this->ResourceOwner<ScriptResource, ScriptResourceClient>::operator=(other); | 75 this->ResourceOwner<ScriptResource, ScriptResourceClient>::operator=(other); |
64 return *this; | 76 return *this; |
65 } | 77 } |
66 | 78 |
67 void PendingScript::watchForLoad(ScriptResourceClient* client) | 79 void PendingScript::watchForLoad(ScriptResourceClient* client) |
68 { | 80 { |
69 ASSERT(!m_watchingForLoad); | 81 ASSERT(!m_watchingForLoad); |
70 // addClient() will call notifyFinished() if the load is complete. Callers | 82 // addClient() will call streamingFinished() if the load is complete. Caller s |
71 // who do not expect to be re-entered from this call should not call | 83 // who do not expect to be re-entered from this call should not call |
72 // watchForLoad for a PendingScript which isReady. We also need to set | 84 // watchForLoad for a PendingScript which isReady. We also need to set |
73 // m_watchingForLoad early, since addClient() can result in calling | 85 // m_watchingForLoad early, since addClient() can result in calling |
74 // notifyFinished and further stopWatchingForLoad(). | 86 // notifyFinished and further stopWatchingForLoad(). |
75 m_watchingForLoad = true; | 87 m_watchingForLoad = true; |
76 if (m_streamer) { | 88 m_client = client; |
77 m_streamer->addClient(client); | 89 if (!m_streamer) |
78 } else { | |
79 resource()->addClient(client); | 90 resource()->addClient(client); |
80 } | |
81 } | 91 } |
82 | 92 |
83 void PendingScript::stopWatchingForLoad(ScriptResourceClient* client) | 93 void PendingScript::stopWatchingForLoad(ScriptResourceClient* client) |
haraken
2016/02/04 23:56:30
You won't need to pass |client| since PendingScrip
Nate Chapin
2016/02/06 00:34:07
Agreed, removed. I could see the argument for keep
| |
84 { | 94 { |
85 if (!m_watchingForLoad) | 95 if (!m_watchingForLoad) |
86 return; | 96 return; |
87 ASSERT(resource()); | 97 ASSERT(resource()); |
88 if (m_streamer) { | 98 m_client = nullptr; |
89 m_streamer->removeClient(client); | 99 if (!m_streamer) |
90 } else { | |
91 resource()->removeClient(client); | 100 resource()->removeClient(client); |
92 } | |
93 m_watchingForLoad = false; | 101 m_watchingForLoad = false; |
94 } | 102 } |
95 | 103 |
104 void PendingScript::streamingFinished() | |
105 { | |
106 ASSERT(resource()); | |
107 if (m_client) | |
108 m_client->notifyFinished(resource()); | |
109 } | |
110 | |
96 void PendingScript::setElement(Element* element) | 111 void PendingScript::setElement(Element* element) |
97 { | 112 { |
98 m_element = element; | 113 m_element = element; |
99 } | 114 } |
100 | 115 |
101 PassRefPtrWillBeRawPtr<Element> PendingScript::releaseElementAndClear() | 116 PassRefPtrWillBeRawPtr<Element> PendingScript::releaseElementAndClear() |
102 { | 117 { |
103 setScriptResource(0); | 118 setScriptResource(0); |
104 m_watchingForLoad = false; | 119 m_watchingForLoad = false; |
105 m_startingPosition = TextPosition::belowRangePosition(); | 120 m_startingPosition = TextPosition::belowRangePosition(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 bool PendingScript::isReady() const | 212 bool PendingScript::isReady() const |
198 { | 213 { |
199 if (resource() && !resource()->isLoaded()) | 214 if (resource() && !resource()->isLoaded()) |
200 return false; | 215 return false; |
201 if (m_streamer && !m_streamer->isFinished()) | 216 if (m_streamer && !m_streamer->isFinished()) |
202 return false; | 217 return false; |
203 return true; | 218 return true; |
204 } | 219 } |
205 | 220 |
206 } // namespace blink | 221 } // namespace blink |
OLD | NEW |