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

Side by Side Diff: Source/bindings/v8/ScriptValue.h

Issue 146523002: Limit the usage of SharedPersistent to ScriptValue only (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « Source/bindings/v8/ScriptController.cpp ('k') | Source/bindings/v8/SharedPersistent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13 matching lines...) Expand all
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 ScriptValue_h 31 #ifndef ScriptValue_h
32 #define ScriptValue_h 32 #define ScriptValue_h
33 33
34 #include "bindings/v8/SharedPersistent.h" 34 #include "bindings/v8/ScopedPersistent.h"
35 #include "wtf/PassRefPtr.h" 35 #include "wtf/RefCounted.h"
36 #include "wtf/RefPtr.h" 36 #include "wtf/RefPtr.h"
37 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
38 #include <v8.h> 38 #include <v8.h>
39 39
40 namespace WebCore { 40 namespace WebCore {
41 41
42 class JSONValue; 42 class JSONValue;
43 class ScriptState; 43 class ScriptState;
44 44
45 template <typename T>
46 class SharedPersistent : public RefCounted<SharedPersistent<T> > {
jochen (gone - plz use gerrit) 2014/01/24 12:19:21 doesn't need to be a template anymore, does it? y
haraken 2014/01/24 12:31:06 Good point, fixed.
47 WTF_MAKE_NONCOPYABLE(SharedPersistent);
48 public:
49 static PassRefPtr<SharedPersistent<T> > create(v8::Handle<T> value, v8::Isol ate* isolate)
50 {
51 return adoptRef(new SharedPersistent<T>(value, isolate));
52 }
53
54 v8::Local<T> newLocal(v8::Isolate* isolate) const
55 {
56 return m_value.newLocal(isolate);
57 }
58
59 bool isEmpty() { return m_value.isEmpty(); }
60
61 bool operator==(const SharedPersistent<T>& other)
62 {
63 return m_value == other.m_value;
64 }
65
66 private:
67 SharedPersistent(v8::Handle<T> value, v8::Isolate* isolate) : m_value(isolat e, value) { }
68 ScopedPersistent<T> m_value;
69 };
70
45 class ScriptValue { 71 class ScriptValue {
46 public: 72 public:
47 ScriptValue() 73 ScriptValue()
48 : m_isolate(0) 74 : m_isolate(0)
49 { } 75 { }
50 76
51 virtual ~ScriptValue(); 77 virtual ~ScriptValue();
52 78
53 ScriptValue(v8::Handle<v8::Value> value, v8::Isolate* isolate) 79 ScriptValue(v8::Handle<v8::Value> value, v8::Isolate* isolate)
54 : m_isolate(isolate) 80 : m_isolate(isolate)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 PassRefPtr<JSONValue> toJSONValue(ScriptState*) const; 191 PassRefPtr<JSONValue> toJSONValue(ScriptState*) const;
166 192
167 private: 193 private:
168 mutable v8::Isolate* m_isolate; 194 mutable v8::Isolate* m_isolate;
169 RefPtr<SharedPersistent<v8::Value> > m_value; 195 RefPtr<SharedPersistent<v8::Value> > m_value;
170 }; 196 };
171 197
172 } // namespace WebCore 198 } // namespace WebCore
173 199
174 #endif // ScriptValue_h 200 #endif // ScriptValue_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/ScriptController.cpp ('k') | Source/bindings/v8/SharedPersistent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698