| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 m_parserBlockingLoadStartTime(0), | 45 m_parserBlockingLoadStartTime(0), |
| 46 m_client(nullptr) { | 46 m_client(nullptr) { |
| 47 setScriptResource(resource); | 47 setScriptResource(resource); |
| 48 ThreadState::current()->registerPreFinalizer(this); | 48 ThreadState::current()->registerPreFinalizer(this); |
| 49 MemoryCoordinator::instance().registerClient(this); | 49 MemoryCoordinator::instance().registerClient(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PendingScript::~PendingScript() {} | 52 PendingScript::~PendingScript() {} |
| 53 | 53 |
| 54 void PendingScript::dispose() { | 54 void PendingScript::dispose() { |
| 55 if (!m_client) | |
| 56 return; | |
| 57 stopWatchingForLoad(); | 55 stopWatchingForLoad(); |
| 58 releaseElementAndClear(); | 56 DCHECK(!m_client); |
| 57 DCHECK(!m_watchingForLoad); |
| 58 |
| 59 setScriptResource(nullptr); |
| 60 m_startingPosition = TextPosition::belowRangePosition(); |
| 61 m_integrityFailure = false; |
| 62 m_parserBlockingLoadStartTime = 0; |
| 63 if (m_streamer) |
| 64 m_streamer->cancel(); |
| 65 m_streamer = nullptr; |
| 66 m_element = nullptr; |
| 59 } | 67 } |
| 60 | 68 |
| 61 void PendingScript::watchForLoad(ScriptResourceClient* client) { | 69 void PendingScript::watchForLoad(ScriptResourceClient* client) { |
| 62 DCHECK(!m_watchingForLoad); | 70 DCHECK(!m_watchingForLoad); |
| 63 // addClient() will call streamingFinished() if the load is complete. Callers | 71 // addClient() will call streamingFinished() if the load is complete. Callers |
| 64 // who do not expect to be re-entered from this call should not call | 72 // who do not expect to be re-entered from this call should not call |
| 65 // watchForLoad for a PendingScript which isReady. We also need to set | 73 // watchForLoad for a PendingScript which isReady. We also need to set |
| 66 // m_watchingForLoad early, since addClient() can result in calling | 74 // m_watchingForLoad early, since addClient() can result in calling |
| 67 // notifyFinished and further stopWatchingForLoad(). | 75 // notifyFinished and further stopWatchingForLoad(). |
| 68 m_watchingForLoad = true; | 76 m_watchingForLoad = true; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 84 void PendingScript::streamingFinished() { | 92 void PendingScript::streamingFinished() { |
| 85 DCHECK(resource()); | 93 DCHECK(resource()); |
| 86 if (m_client) | 94 if (m_client) |
| 87 m_client->notifyFinished(resource()); | 95 m_client->notifyFinished(resource()); |
| 88 } | 96 } |
| 89 | 97 |
| 90 void PendingScript::setElement(Element* element) { | 98 void PendingScript::setElement(Element* element) { |
| 91 m_element = element; | 99 m_element = element; |
| 92 } | 100 } |
| 93 | 101 |
| 94 Element* PendingScript::releaseElementAndClear() { | |
| 95 setScriptResource(0); | |
| 96 m_watchingForLoad = false; | |
| 97 m_startingPosition = TextPosition::belowRangePosition(); | |
| 98 m_integrityFailure = false; | |
| 99 m_parserBlockingLoadStartTime = 0; | |
| 100 if (m_streamer) | |
| 101 m_streamer->cancel(); | |
| 102 m_streamer.release(); | |
| 103 return m_element.release(); | |
| 104 } | |
| 105 | |
| 106 void PendingScript::setScriptResource(ScriptResource* resource) { | 102 void PendingScript::setScriptResource(ScriptResource* resource) { |
| 107 setResource(resource); | 103 setResource(resource); |
| 108 } | 104 } |
| 109 | 105 |
| 110 void PendingScript::markParserBlockingLoadStartTime() { | 106 void PendingScript::markParserBlockingLoadStartTime() { |
| 111 DCHECK_EQ(m_parserBlockingLoadStartTime, 0.0); | 107 DCHECK_EQ(m_parserBlockingLoadStartTime, 0.0); |
| 112 m_parserBlockingLoadStartTime = monotonicallyIncreasingTime(); | 108 m_parserBlockingLoadStartTime = monotonicallyIncreasingTime(); |
| 113 } | 109 } |
| 114 | 110 |
| 115 void PendingScript::notifyFinished(Resource* resource) { | 111 void PendingScript::notifyFinished(Resource* resource) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 219 |
| 224 void PendingScript::onMemoryStateChange(MemoryState state) { | 220 void PendingScript::onMemoryStateChange(MemoryState state) { |
| 225 if (state != MemoryState::SUSPENDED) | 221 if (state != MemoryState::SUSPENDED) |
| 226 return; | 222 return; |
| 227 if (!m_streamer) | 223 if (!m_streamer) |
| 228 return; | 224 return; |
| 229 m_streamer->cancel(); | 225 m_streamer->cancel(); |
| 230 } | 226 } |
| 231 | 227 |
| 232 } // namespace blink | 228 } // namespace blink |
| OLD | NEW |