Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: Source/bindings/core/v8/ScriptSourceCode.h

Issue 847803002: Make ScriptStreamer and dependents Oilpan friendly. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: another rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
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 "bindings/core/v8/ScriptStreamer.h"
35 #include "core/fetch/ResourcePtr.h" 35 #include "core/fetch/ResourcePtr.h"
36 #include "core/fetch/ScriptResource.h" 36 #include "core/fetch/ScriptResource.h"
37 #include "platform/heap/Handle.h"
37 #include "platform/weborigin/KURL.h" 38 #include "platform/weborigin/KURL.h"
38 #include "wtf/PassOwnPtr.h"
39 #include "wtf/text/TextPosition.h" 39 #include "wtf/text/TextPosition.h"
40 #include "wtf/text/WTFString.h" 40 #include "wtf/text/WTFString.h"
41 41
42 namespace blink { 42 namespace blink {
43 43
44 class ScriptSourceCode { 44 template <class R> class ResourcePtr;
45 class ScriptResource;
46
47 class ScriptSourceCode final {
48 ALLOW_ONLY_INLINE_ALLOCATION();
45 public: 49 public:
46 ScriptSourceCode(const String& source, const KURL& url = KURL(), const TextP osition& startPosition = TextPosition::minimumPosition()) 50 ScriptSourceCode();
47 : m_source(source)
48 , m_resource(0)
49 , m_url(url)
50 , m_startPosition(startPosition)
51 {
52 if (!m_url.isEmpty())
53 m_url.removeFragmentIdentifier();
54 }
55
56 // We lose the encoding information from ScriptResource. 51 // We lose the encoding information from ScriptResource.
57 // Not sure if that matters. 52 // Not sure if that matters.
58 ScriptSourceCode(ScriptResource* resource) 53 explicit ScriptSourceCode(ScriptResource*);
59 : m_source(resource->script()) 54 ScriptSourceCode(const String&, const KURL& = KURL(), const TextPosition& st artPosition = TextPosition::minimumPosition());
60 , m_resource(resource) 55 ScriptSourceCode(PassRefPtrWillBeRawPtr<ScriptStreamer>, ScriptResource*);
61 , m_startPosition(TextPosition::minimumPosition())
62 {
63 }
64 56
65 ScriptSourceCode(PassRefPtr<ScriptStreamer> streamer, ScriptResource* resour ce) 57 ~ScriptSourceCode();
66 : m_source(resource->script()) 58 void trace(Visitor*);
67 , m_resource(resource)
68 , m_streamer(streamer)
69 , m_startPosition(TextPosition::minimumPosition())
70 {
71 }
72 59
73 bool isEmpty() const { return m_source.isEmpty(); } 60 bool isEmpty() const { return m_source.isEmpty(); }
61 bool isNull() const { return m_source.isNull(); }
haraken 2015/01/22 13:38:36 Shall we add a comment about the difference?
sof 2015/01/22 14:04:12 Added.
74 62
75 const String& source() const { return m_source; } 63 const String& source() const { return m_source; }
76 ScriptResource* resource() const { return m_resource.get(); } 64 ScriptResource* resource() const { return m_resource.get(); }
77 const KURL& url() const 65 const KURL& url() const;
78 {
79 if (m_url.isEmpty() && m_resource) {
80 m_url = m_resource->response().url();
81 if (!m_url.isEmpty())
82 m_url.removeFragmentIdentifier();
83 }
84 return m_url;
85 }
86 int startLine() const { return m_startPosition.m_line.oneBasedInt(); } 66 int startLine() const { return m_startPosition.m_line.oneBasedInt(); }
87 const TextPosition& startPosition() const { return m_startPosition; } 67 const TextPosition& startPosition() const { return m_startPosition; }
88 68
89 ScriptStreamer* streamer() const { return m_streamer.get(); } 69 ScriptStreamer* streamer() const { return m_streamer.get(); }
90 70
91 private: 71 private:
72 void treatNullSourceAsEmpty();
73
92 String m_source; 74 String m_source;
93 ResourcePtr<ScriptResource> m_resource; 75 ResourcePtr<ScriptResource> m_resource;
94 RefPtr<ScriptStreamer> m_streamer; 76 RefPtrWillBeMember<ScriptStreamer> m_streamer;
95 mutable KURL m_url; 77 mutable KURL m_url;
96 TextPosition m_startPosition; 78 TextPosition m_startPosition;
97 }; 79 };
98 80
99 } // namespace blink 81 } // namespace blink
100 82
83 WTF_ALLOW_INIT_WITH_MEM_FUNCTIONS(blink::ScriptSourceCode);
84
101 #endif // ScriptSourceCode_h 85 #endif // ScriptSourceCode_h
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/ScriptPreprocessor.cpp ('k') | Source/bindings/core/v8/ScriptSourceCode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698