| 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 15 matching lines...) Expand all Loading... |
| 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 "core/dom/Element.h" | 29 #include "core/dom/Element.h" |
| 30 #include "core/fetch/ScriptResource.h" | 30 #include "core/fetch/ScriptResource.h" |
| 31 #include "core/frame/SubresourceIntegrity.h" | 31 #include "core/frame/SubresourceIntegrity.h" |
| 32 #include "platform/SharedBuffer.h" | 32 #include "platform/SharedBuffer.h" |
| 33 | 33 |
| 34 namespace blink { | 34 namespace blink { |
| 35 | 35 |
| 36 PassOwnPtrWillBeRawPtr<PendingScript> PendingScript::create(Element* element, Sc
riptResource* resource) | 36 RawPtr<PendingScript> PendingScript::create(Element* element, ScriptResource* re
source) |
| 37 { | 37 { |
| 38 return adoptPtrWillBeNoop(new PendingScript(element, resource)); | 38 return 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 , m_client(nullptr) |
| 46 { | 46 { |
| 47 setScriptResource(resource); | 47 setScriptResource(resource); |
| 48 #if ENABLE(OILPAN) | 48 #if ENABLE(OILPAN) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 ASSERT(resource()); | 106 ASSERT(resource()); |
| 107 if (m_client) | 107 if (m_client) |
| 108 m_client->notifyFinished(resource()); | 108 m_client->notifyFinished(resource()); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void PendingScript::setElement(Element* element) | 111 void PendingScript::setElement(Element* element) |
| 112 { | 112 { |
| 113 m_element = element; | 113 m_element = element; |
| 114 } | 114 } |
| 115 | 115 |
| 116 PassRefPtrWillBeRawPtr<Element> PendingScript::releaseElementAndClear() | 116 RawPtr<Element> PendingScript::releaseElementAndClear() |
| 117 { | 117 { |
| 118 setScriptResource(0); | 118 setScriptResource(0); |
| 119 m_watchingForLoad = false; | 119 m_watchingForLoad = false; |
| 120 m_startingPosition = TextPosition::belowRangePosition(); | 120 m_startingPosition = TextPosition::belowRangePosition(); |
| 121 m_integrityFailure = false; | 121 m_integrityFailure = false; |
| 122 if (m_streamer) | 122 if (m_streamer) |
| 123 m_streamer->cancel(); | 123 m_streamer->cancel(); |
| 124 m_streamer.release(); | 124 m_streamer.release(); |
| 125 return m_element.release(); | 125 return m_element.release(); |
| 126 } | 126 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 errorOccurred = resource()->errorOccurred() || m_integrityFailure; | 201 errorOccurred = resource()->errorOccurred() || m_integrityFailure; |
| 202 ASSERT(resource()->isLoaded()); | 202 ASSERT(resource()->isLoaded()); |
| 203 if (m_streamer && !m_streamer->streamingSuppressed()) | 203 if (m_streamer && !m_streamer->streamingSuppressed()) |
| 204 return ScriptSourceCode(m_streamer, resource()); | 204 return ScriptSourceCode(m_streamer, resource()); |
| 205 return ScriptSourceCode(resource()); | 205 return ScriptSourceCode(resource()); |
| 206 } | 206 } |
| 207 errorOccurred = false; | 207 errorOccurred = false; |
| 208 return ScriptSourceCode(m_element->textContent(), documentURL, startingPosit
ion()); | 208 return ScriptSourceCode(m_element->textContent(), documentURL, startingPosit
ion()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void PendingScript::setStreamer(PassRefPtrWillBeRawPtr<ScriptStreamer> streamer) | 211 void PendingScript::setStreamer(RawPtr<ScriptStreamer> streamer) |
| 212 { | 212 { |
| 213 ASSERT(!m_streamer); | 213 ASSERT(!m_streamer); |
| 214 ASSERT(!m_watchingForLoad); | 214 ASSERT(!m_watchingForLoad); |
| 215 m_streamer = streamer; | 215 m_streamer = streamer; |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool PendingScript::isReady() const | 218 bool PendingScript::isReady() const |
| 219 { | 219 { |
| 220 if (resource() && !resource()->isLoaded()) | 220 if (resource() && !resource()->isLoaded()) |
| 221 return false; | 221 return false; |
| 222 if (m_streamer && !m_streamer->isFinished()) | 222 if (m_streamer && !m_streamer->isFinished()) |
| 223 return false; | 223 return false; |
| 224 return true; | 224 return true; |
| 225 } | 225 } |
| 226 | 226 |
| 227 bool PendingScript::errorOccurred() const | 227 bool PendingScript::errorOccurred() const |
| 228 { | 228 { |
| 229 if (resource()) | 229 if (resource()) |
| 230 return resource()->errorOccurred(); | 230 return resource()->errorOccurred(); |
| 231 if (m_streamer && m_streamer->resource()) | 231 if (m_streamer && m_streamer->resource()) |
| 232 return m_streamer->resource()->errorOccurred(); | 232 return m_streamer->resource()->errorOccurred(); |
| 233 return false; | 233 return false; |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace blink | 236 } // namespace blink |
| OLD | NEW |