| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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 #include "core/dom/PendingScript.h" | 26 #include "core/dom/PendingScript.h" |
| 27 | 27 |
| 28 #include "bindings/core/v8/ScriptSourceCode.h" | 28 #include "bindings/core/v8/ScriptSourceCode.h" |
| 29 #include "bindings/core/v8/ScriptStreamer.h" | |
| 30 #include "core/dom/Element.h" | 29 #include "core/dom/Element.h" |
| 31 #include "core/fetch/ScriptResource.h" | 30 #include "core/fetch/ScriptResource.h" |
| 32 #include "core/frame/SubresourceIntegrity.h" | 31 #include "core/frame/SubresourceIntegrity.h" |
| 33 #include "platform/SharedBuffer.h" | 32 #include "platform/SharedBuffer.h" |
| 34 | 33 |
| 35 namespace blink { | 34 namespace blink { |
| 36 | 35 |
| 37 PendingScript::PendingScript() | 36 PassOwnPtrWillBeRawPtr<PendingScript> PendingScript::create(Element* element, Sc
riptResource* resource) |
| 38 : m_watchingForLoad(false) | |
| 39 , m_startingPosition(TextPosition::belowRangePosition()) | |
| 40 , m_integrityFailure(false) | |
| 41 { | 37 { |
| 38 return adoptPtrWillBeNoop(new PendingScript(element, resource)); |
| 42 } | 39 } |
| 43 | 40 |
| 44 PendingScript::PendingScript(Element* element, ScriptResource* resource) | 41 PendingScript::PendingScript(Element* element, ScriptResource* resource) |
| 45 : m_watchingForLoad(false) | 42 : m_watchingForLoad(false) |
| 46 , m_element(element) | 43 , m_element(element) |
| 47 , m_integrityFailure(false) | 44 , m_integrityFailure(false) |
| 48 { | 45 { |
| 49 setScriptResource(resource); | 46 setScriptResource(resource); |
| 50 } | 47 } |
| 51 | 48 |
| 52 PendingScript::PendingScript(const PendingScript& other) | |
| 53 : ResourceOwner(other) | |
| 54 , m_watchingForLoad(other.m_watchingForLoad) | |
| 55 , m_element(other.m_element) | |
| 56 , m_startingPosition(other.m_startingPosition) | |
| 57 , m_integrityFailure(other.m_integrityFailure) | |
| 58 , m_streamer(other.m_streamer) | |
| 59 { | |
| 60 setScriptResource(other.resource()); | |
| 61 } | |
| 62 | |
| 63 PendingScript::~PendingScript() | 49 PendingScript::~PendingScript() |
| 64 { | 50 { |
| 65 } | 51 } |
| 66 | 52 |
| 67 PendingScript& PendingScript::operator=(const PendingScript& other) | 53 PendingScript& PendingScript::operator=(const PendingScript& other) |
| 68 { | 54 { |
| 69 if (this == &other) | 55 if (this == &other) |
| 70 return *this; | 56 return *this; |
| 71 | 57 |
| 72 m_watchingForLoad = other.m_watchingForLoad; | 58 m_watchingForLoad = other.m_watchingForLoad; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 void PendingScript::notifyAppendData(ScriptResource* resource) | 164 void PendingScript::notifyAppendData(ScriptResource* resource) |
| 179 { | 165 { |
| 180 if (m_streamer) | 166 if (m_streamer) |
| 181 m_streamer->notifyAppendData(resource); | 167 m_streamer->notifyAppendData(resource); |
| 182 } | 168 } |
| 183 | 169 |
| 184 DEFINE_TRACE(PendingScript) | 170 DEFINE_TRACE(PendingScript) |
| 185 { | 171 { |
| 186 visitor->trace(m_element); | 172 visitor->trace(m_element); |
| 187 visitor->trace(m_streamer); | 173 visitor->trace(m_streamer); |
| 174 ResourceOwner<ScriptResource>::trace(visitor); |
| 188 } | 175 } |
| 189 | 176 |
| 190 ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOc
curred) const | 177 ScriptSourceCode PendingScript::getSource(const KURL& documentURL, bool& errorOc
curred) const |
| 191 { | 178 { |
| 192 if (resource()) { | 179 if (resource()) { |
| 193 errorOccurred = resource()->errorOccurred() || m_integrityFailure; | 180 errorOccurred = resource()->errorOccurred() || m_integrityFailure; |
| 194 ASSERT(resource()->isLoaded()); | 181 ASSERT(resource()->isLoaded()); |
| 195 if (m_streamer && !m_streamer->streamingSuppressed()) | 182 if (m_streamer && !m_streamer->streamingSuppressed()) |
| 196 return ScriptSourceCode(m_streamer, resource()); | 183 return ScriptSourceCode(m_streamer, resource()); |
| 197 return ScriptSourceCode(resource()); | 184 return ScriptSourceCode(resource()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 210 bool PendingScript::isReady() const | 197 bool PendingScript::isReady() const |
| 211 { | 198 { |
| 212 if (resource() && !resource()->isLoaded()) | 199 if (resource() && !resource()->isLoaded()) |
| 213 return false; | 200 return false; |
| 214 if (m_streamer && !m_streamer->isFinished()) | 201 if (m_streamer && !m_streamer->isFinished()) |
| 215 return false; | 202 return false; |
| 216 return true; | 203 return true; |
| 217 } | 204 } |
| 218 | 205 |
| 219 } | 206 } |
| OLD | NEW |