| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef ScriptSourceCode_h | 31 #ifndef ScriptSourceCode_h |
| 32 #define ScriptSourceCode_h | 32 #define ScriptSourceCode_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptStreamer.h" |
| 34 #include "core/fetch/ResourcePtr.h" | 35 #include "core/fetch/ResourcePtr.h" |
| 35 #include "core/fetch/ScriptResource.h" | 36 #include "core/fetch/ScriptResource.h" |
| 36 #include "platform/weborigin/KURL.h" | 37 #include "platform/weborigin/KURL.h" |
| 37 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
| 38 #include "wtf/text/TextPosition.h" | 39 #include "wtf/text/TextPosition.h" |
| 39 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
| 40 | 41 |
| 41 namespace blink { | 42 namespace blink { |
| 42 | 43 |
| 43 class ScriptSourceCode { | 44 class ScriptSourceCode { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 // We lose the encoding information from ScriptResource. | 56 // We lose the encoding information from ScriptResource. |
| 56 // Not sure if that matters. | 57 // Not sure if that matters. |
| 57 ScriptSourceCode(ScriptResource* cs) | 58 ScriptSourceCode(ScriptResource* cs) |
| 58 : m_source(cs->script()) | 59 : m_source(cs->script()) |
| 59 , m_resource(cs) | 60 , m_resource(cs) |
| 60 , m_startPosition(TextPosition::minimumPosition()) | 61 , m_startPosition(TextPosition::minimumPosition()) |
| 61 { | 62 { |
| 62 } | 63 } |
| 63 | 64 |
| 65 ScriptSourceCode(PassRefPtr<ScriptStreamer> streamer, ScriptResource* cs) |
| 66 : m_source(cs->script()) |
| 67 , m_resource(cs) |
| 68 , m_streamer(streamer) |
| 69 , m_startPosition(TextPosition::minimumPosition()) |
| 70 { |
| 71 } |
| 72 |
| 64 bool isEmpty() const { return m_source.isEmpty(); } | 73 bool isEmpty() const { return m_source.isEmpty(); } |
| 65 | 74 |
| 66 const String& source() const { return m_source; } | 75 const String& source() const { return m_source; } |
| 67 ScriptResource* resource() const { return m_resource.get(); } | 76 ScriptResource* resource() const { return m_resource.get(); } |
| 68 const KURL& url() const | 77 const KURL& url() const |
| 69 { | 78 { |
| 70 if (m_url.isEmpty() && m_resource) { | 79 if (m_url.isEmpty() && m_resource) { |
| 71 m_url = m_resource->response().url(); | 80 m_url = m_resource->response().url(); |
| 72 if (!m_url.isEmpty()) | 81 if (!m_url.isEmpty()) |
| 73 m_url.removeFragmentIdentifier(); | 82 m_url.removeFragmentIdentifier(); |
| 74 } | 83 } |
| 75 return m_url; | 84 return m_url; |
| 76 } | 85 } |
| 77 int startLine() const { return m_startPosition.m_line.oneBasedInt(); } | 86 int startLine() const { return m_startPosition.m_line.oneBasedInt(); } |
| 78 const TextPosition& startPosition() const { return m_startPosition; } | 87 const TextPosition& startPosition() const { return m_startPosition; } |
| 79 | 88 |
| 89 ScriptStreamer* streamer() const { return m_streamer.get(); } |
| 90 |
| 80 private: | 91 private: |
| 81 String m_source; | 92 String m_source; |
| 82 ResourcePtr<ScriptResource> m_resource; | 93 ResourcePtr<ScriptResource> m_resource; |
| 94 RefPtr<ScriptStreamer> m_streamer; |
| 83 mutable KURL m_url; | 95 mutable KURL m_url; |
| 84 TextPosition m_startPosition; | 96 TextPosition m_startPosition; |
| 85 }; | 97 }; |
| 86 | 98 |
| 87 } // namespace blink | 99 } // namespace blink |
| 88 | 100 |
| 89 #endif // ScriptSourceCode_h | 101 #endif // ScriptSourceCode_h |
| OLD | NEW |