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

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

Issue 40433002: Make wrapperTypeInfo static member const in bindings classes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 7 years, 2 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
« no previous file with comments | « Source/bindings/v8/V8Initializer.cpp ('k') | Source/bindings/v8/V8PerContextData.cpp » ('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) 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool init(); 73 bool init();
74 74
75 static V8PerContextData* from(v8::Handle<v8::Context> context) 75 static V8PerContextData* from(v8::Handle<v8::Context> context)
76 { 76 {
77 return static_cast<V8PerContextData*>(context->GetAlignedPointerFromEmbe dderData(v8ContextPerContextDataIndex)); 77 return static_cast<V8PerContextData*>(context->GetAlignedPointerFromEmbe dderData(v8ContextPerContextDataIndex));
78 } 78 }
79 79
80 // To create JS Wrapper objects, we create a cache of a 'boiler plate' 80 // To create JS Wrapper objects, we create a cache of a 'boiler plate'
81 // object, and then simply Clone that object each time we need a new one. 81 // object, and then simply Clone that object each time we need a new one.
82 // This is faster than going through the full object creation process. 82 // This is faster than going through the full object creation process.
83 v8::Local<v8::Object> createWrapperFromCache(WrapperTypeInfo* type) 83 v8::Local<v8::Object> createWrapperFromCache(const WrapperTypeInfo* type)
84 { 84 {
85 UnsafePersistent<v8::Object> boilerplate = m_wrapperBoilerplates.get(typ e); 85 UnsafePersistent<v8::Object> boilerplate = m_wrapperBoilerplates.get(typ e);
86 return !boilerplate.isEmpty() ? boilerplate.newLocal(v8::Isolate::GetCur rent())->Clone() : createWrapperFromCacheSlowCase(type); 86 return !boilerplate.isEmpty() ? boilerplate.newLocal(v8::Isolate::GetCur rent())->Clone() : createWrapperFromCacheSlowCase(type);
87 } 87 }
88 88
89 v8::Local<v8::Function> constructorForType(WrapperTypeInfo* type) 89 v8::Local<v8::Function> constructorForType(const WrapperTypeInfo* type)
90 { 90 {
91 UnsafePersistent<v8::Function> function = m_constructorMap.get(type); 91 UnsafePersistent<v8::Function> function = m_constructorMap.get(type);
92 if (!function.isEmpty()) 92 if (!function.isEmpty())
93 return function.newLocal(v8::Isolate::GetCurrent()); 93 return function.newLocal(v8::Isolate::GetCurrent());
94 return constructorForTypeSlowCase(type); 94 return constructorForTypeSlowCase(type);
95 } 95 }
96 96
97 v8::Local<v8::Object> prototypeForType(WrapperTypeInfo*); 97 v8::Local<v8::Object> prototypeForType(const WrapperTypeInfo*);
98 98
99 V8NPObjectMap* v8NPObjectMap() 99 V8NPObjectMap* v8NPObjectMap()
100 { 100 {
101 return &m_v8NPObjectMap; 101 return &m_v8NPObjectMap;
102 } 102 }
103 103
104 V8DOMActivityLogger* activityLogger() 104 V8DOMActivityLogger* activityLogger()
105 { 105 {
106 return m_activityLogger; 106 return m_activityLogger;
107 } 107 }
(...skipping 11 matching lines...) Expand all
119 explicit V8PerContextData(v8::Handle<v8::Context> context) 119 explicit V8PerContextData(v8::Handle<v8::Context> context)
120 : m_activityLogger(0) 120 : m_activityLogger(0)
121 , m_isolate(v8::Isolate::GetCurrent()) 121 , m_isolate(v8::Isolate::GetCurrent())
122 , m_context(m_isolate, context) 122 , m_context(m_isolate, context)
123 , m_customElementBindings(adoptPtr(new CustomElementBindingMap())) 123 , m_customElementBindings(adoptPtr(new CustomElementBindingMap()))
124 { 124 {
125 } 125 }
126 126
127 void dispose(); 127 void dispose();
128 128
129 v8::Local<v8::Object> createWrapperFromCacheSlowCase(WrapperTypeInfo*); 129 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*) ;
130 v8::Local<v8::Function> constructorForTypeSlowCase(WrapperTypeInfo*); 130 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*);
131 131
132 // For each possible type of wrapper, we keep a boilerplate object. 132 // For each possible type of wrapper, we keep a boilerplate object.
133 // The boilerplate is used to create additional wrappers of the same type. 133 // The boilerplate is used to create additional wrappers of the same type.
134 typedef WTF::HashMap<WrapperTypeInfo*, UnsafePersistent<v8::Object> > Wrappe rBoilerplateMap; 134 typedef WTF::HashMap<const WrapperTypeInfo*, UnsafePersistent<v8::Object> > WrapperBoilerplateMap;
135 WrapperBoilerplateMap m_wrapperBoilerplates; 135 WrapperBoilerplateMap m_wrapperBoilerplates;
136 136
137 typedef WTF::HashMap<WrapperTypeInfo*, UnsafePersistent<v8::Function> > Cons tructorMap; 137 typedef WTF::HashMap<const WrapperTypeInfo*, UnsafePersistent<v8::Function> > ConstructorMap;
138 ConstructorMap m_constructorMap; 138 ConstructorMap m_constructorMap;
139 139
140 V8NPObjectMap m_v8NPObjectMap; 140 V8NPObjectMap m_v8NPObjectMap;
141 // We cache a pointer to the V8DOMActivityLogger associated with the world 141 // We cache a pointer to the V8DOMActivityLogger associated with the world
142 // corresponding to this context. The ownership of the pointer is retained 142 // corresponding to this context. The ownership of the pointer is retained
143 // by the DOMActivityLoggerMap in DOMWrapperWorld. 143 // by the DOMActivityLoggerMap in DOMWrapperWorld.
144 V8DOMActivityLogger* m_activityLogger; 144 V8DOMActivityLogger* m_activityLogger;
145 v8::Isolate* m_isolate; 145 v8::Isolate* m_isolate;
146 v8::Persistent<v8::Context> m_context; 146 v8::Persistent<v8::Context> m_context;
147 ScopedPersistent<v8::Value> m_errorPrototype; 147 ScopedPersistent<v8::Value> m_errorPrototype;
148 148
149 typedef WTF::HashMap<CustomElementDefinition*, OwnPtr<CustomElementBinding> > CustomElementBindingMap; 149 typedef WTF::HashMap<CustomElementDefinition*, OwnPtr<CustomElementBinding> > CustomElementBindingMap;
150 OwnPtr<CustomElementBindingMap> m_customElementBindings; 150 OwnPtr<CustomElementBindingMap> m_customElementBindings;
151 }; 151 };
152 152
153 class V8PerContextDebugData { 153 class V8PerContextDebugData {
154 public: 154 public:
155 static bool setContextDebugData(v8::Handle<v8::Context>, const char* worldNa me, int debugId); 155 static bool setContextDebugData(v8::Handle<v8::Context>, const char* worldNa me, int debugId);
156 static int contextDebugId(v8::Handle<v8::Context>); 156 static int contextDebugId(v8::Handle<v8::Context>);
157 }; 157 };
158 158
159 } // namespace WebCore 159 } // namespace WebCore
160 160
161 #endif // V8PerContextData_h 161 #endif // V8PerContextData_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Initializer.cpp ('k') | Source/bindings/v8/V8PerContextData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698