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

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

Issue 14362015: WIP enum / V8PerContextData solution (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Crash during GC Created 7 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 15 matching lines...) Expand all
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 V8PerContextData_h 31 #ifndef V8PerContextData_h
32 #define V8PerContextData_h 32 #define V8PerContextData_h
33 33
34 #include "ScopedPersistent.h" 34 #include "ScopedPersistent.h"
35 #include "V8DOMActivityLogger.h" 35 #include "V8DOMActivityLogger.h"
36 #include "V8PerContextDebugData.h"
36 #include "WrapperTypeInfo.h" 37 #include "WrapperTypeInfo.h"
37 #include <v8.h> 38 #include <v8.h>
38 #include <wtf/HashMap.h> 39 #include <wtf/HashMap.h>
39 #include <wtf/PassOwnPtr.h> 40 #include <wtf/PassOwnPtr.h>
40 #include <wtf/Vector.h> 41 #include <wtf/Vector.h>
41 42
42 namespace WebCore { 43 namespace WebCore {
43 44
44 struct V8NPObject; 45 struct V8NPObject;
45 typedef WTF::Vector<V8NPObject*> V8NPObjectVector; 46 typedef WTF::Vector<V8NPObject*> V8NPObjectVector;
46 typedef WTF::HashMap<int, V8NPObjectVector> V8NPObjectMap; 47 typedef WTF::HashMap<int, V8NPObjectVector> V8NPObjectMap;
47 48
48 enum V8ContextEmbedderDataField {
49 v8ContextDebugIdIndex,
50 v8ContextPerContextDataIndex,
51 v8ContextIsolatedWorld,
52 // Rather than adding more embedder data fields to v8::Context,
53 // consider adding the data to V8PerContextData instead.
54 };
55
56 class V8PerContextData { 49 class V8PerContextData {
57 public: 50 public:
58 static PassOwnPtr<V8PerContextData> create(v8::Persistent<v8::Context> conte xt) 51 static PassOwnPtr<V8PerContextData> create(v8::Persistent<v8::Context> conte xt)
59 { 52 {
60 return adoptPtr(new V8PerContextData(context)); 53 return adoptPtr(new V8PerContextData(context));
61 } 54 }
62 55
63 ~V8PerContextData() 56 ~V8PerContextData()
64 { 57 {
65 dispose(); 58 dispose();
(...skipping 30 matching lines...) Expand all
96 89
97 V8DOMActivityLogger* activityLogger() 90 V8DOMActivityLogger* activityLogger()
98 { 91 {
99 return m_activityLogger; 92 return m_activityLogger;
100 } 93 }
101 94
102 void setActivityLogger(V8DOMActivityLogger* logger) 95 void setActivityLogger(V8DOMActivityLogger* logger)
103 { 96 {
104 m_activityLogger = logger; 97 m_activityLogger = logger;
105 } 98 }
106 99
107 private: 100 private:
108 explicit V8PerContextData(v8::Persistent<v8::Context> context) 101 explicit V8PerContextData(v8::Persistent<v8::Context> context)
109 : m_context(context) 102 : m_context(context),
103 m_originCategory(CompilationOriginUnset),
104 m_contextCategory(CompilationContextUnset),
105 m_restrictions(CompilationRestrictionsNone),
106 m_debugId(0)
110 { 107 {
111 } 108 }
112 109
113 void dispose(); 110 void dispose();
114 111
115 v8::Local<v8::Object> createWrapperFromCacheSlowCase(WrapperTypeInfo*); 112 v8::Local<v8::Object> createWrapperFromCacheSlowCase(WrapperTypeInfo*);
116 v8::Local<v8::Function> constructorForTypeSlowCase(WrapperTypeInfo*); 113 v8::Local<v8::Function> constructorForTypeSlowCase(WrapperTypeInfo*);
117 114
118 // For each possible type of wrapper, we keep a boilerplate object. 115 // For each possible type of wrapper, we keep a boilerplate object.
119 // The boilerplate is used to create additional wrappers of the same type. 116 // The boilerplate is used to create additional wrappers of the same type.
120 typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Object> > WrapperB oilerplateMap; 117 typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Object> > WrapperB oilerplateMap;
121 WrapperBoilerplateMap m_wrapperBoilerplates; 118 WrapperBoilerplateMap m_wrapperBoilerplates;
122 119
123 typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Function> > Constr uctorMap; 120 typedef WTF::HashMap<WrapperTypeInfo*, v8::Persistent<v8::Function> > Constr uctorMap;
124 ConstructorMap m_constructorMap; 121 ConstructorMap m_constructorMap;
125 122
126 V8NPObjectMap m_v8NPObjectMap; 123 V8NPObjectMap m_v8NPObjectMap;
127 // We cache a pointer to the V8DOMActivityLogger associated with the world 124 // We cache a pointer to the V8DOMActivityLogger associated with the world
128 // corresponding to this context. The ownership of the pointer is retained 125 // corresponding to this context. The ownership of the pointer is retained
129 // by the DOMActivityLoggerMap in DOMWrapperWorld. 126 // by the DOMActivityLoggerMap in DOMWrapperWorld.
130 V8DOMActivityLogger* m_activityLogger; 127 V8DOMActivityLogger* m_activityLogger;
131 v8::Persistent<v8::Context> m_context; 128 v8::Persistent<v8::Context> m_context;
132 ScopedPersistent<v8::Value> m_errorPrototype; 129 ScopedPersistent<v8::Value> m_errorPrototype;
133 ScopedPersistent<v8::Value> m_objectPrototype; 130 ScopedPersistent<v8::Value> m_objectPrototype;
134 }; 131 // Transient values set during compilation into the Context for devtools
135 132 friend class V8PerContextDebugData;
136 class V8PerContextDebugData { 133 friend class V8ScopedCompilation;
137 public: 134 CompilationOriginCategory m_originCategory;
138 static bool setContextDebugData(v8::Handle<v8::Context>, const char* worldNa me, int debugId); 135 CompilationContextCategory m_contextCategory;
139 static int contextDebugId(v8::Handle<v8::Context>); 136 CompilationRestrictions m_restrictions;
137 int m_debugId;
140 }; 138 };
141 139
142 } // namespace WebCore 140 } // namespace WebCore
143 141
144 #endif // V8PerContextData_h 142 #endif // V8PerContextData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698