Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 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 V8PerContextData_h | 31 #ifndef V8PerContextData_h |
| 32 #define V8PerContextData_h | 32 #define V8PerContextData_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScopedPersistent.h" | 34 #include "bindings/core/v8/ScopedPersistent.h" |
| 35 #include "bindings/core/v8/V0CustomElementBinding.h" | 35 #include "bindings/core/v8/V8CustomElementPerContextData.h" |
| 36 #include "bindings/core/v8/V8GlobalValueMap.h" | 36 #include "bindings/core/v8/V8GlobalValueMap.h" |
| 37 #include "bindings/core/v8/WrapperTypeInfo.h" | 37 #include "bindings/core/v8/WrapperTypeInfo.h" |
| 38 #include "core/CoreExport.h" | 38 #include "core/CoreExport.h" |
| 39 #include "gin/public/context_holder.h" | 39 #include "gin/public/context_holder.h" |
| 40 #include "gin/public/gin_embedders.h" | 40 #include "gin/public/gin_embedders.h" |
| 41 #include "platform/heap/Handle.h" | |
| 41 #include "wtf/Allocator.h" | 42 #include "wtf/Allocator.h" |
| 42 #include "wtf/HashMap.h" | 43 #include "wtf/HashMap.h" |
| 43 #include "wtf/PassOwnPtr.h" | 44 #include "wtf/PassOwnPtr.h" |
| 44 #include "wtf/Vector.h" | |
| 45 #include "wtf/text/AtomicString.h" | 45 #include "wtf/text/AtomicString.h" |
| 46 #include "wtf/text/AtomicStringHash.h" | 46 #include "wtf/text/AtomicStringHash.h" |
| 47 #include <v8.h> | 47 #include <v8.h> |
| 48 | 48 |
| 49 namespace blink { | 49 namespace blink { |
| 50 | 50 |
| 51 class V8DOMActivityLogger; | 51 class V8DOMActivityLogger; |
| 52 class V8PerContextData; | 52 class V8PerContextData; |
| 53 | 53 |
| 54 enum V8ContextEmbedderDataField { | 54 enum V8ContextEmbedderDataField { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 77 } | 77 } |
| 78 | 78 |
| 79 v8::Local<v8::Function> constructorForType(const WrapperTypeInfo* type) | 79 v8::Local<v8::Function> constructorForType(const WrapperTypeInfo* type) |
| 80 { | 80 { |
| 81 v8::Local<v8::Function> interfaceObject = m_constructorMap.Get(type); | 81 v8::Local<v8::Function> interfaceObject = m_constructorMap.Get(type); |
| 82 return (!interfaceObject.IsEmpty()) ? interfaceObject : constructorForTy peSlowCase(type); | 82 return (!interfaceObject.IsEmpty()) ? interfaceObject : constructorForTy peSlowCase(type); |
| 83 } | 83 } |
| 84 | 84 |
| 85 v8::Local<v8::Object> prototypeForType(const WrapperTypeInfo*); | 85 v8::Local<v8::Object> prototypeForType(const WrapperTypeInfo*); |
| 86 | 86 |
| 87 void addCustomElementBinding(PassOwnPtr<V0CustomElementBinding>); | 87 V8CustomElementPerContextData* customElements(); |
| 88 | 88 |
| 89 V8DOMActivityLogger* activityLogger() const { return m_activityLogger; } | 89 V8DOMActivityLogger* activityLogger() const { return m_activityLogger; } |
| 90 void setActivityLogger(V8DOMActivityLogger* activityLogger) { m_activityLogg er = activityLogger; } | 90 void setActivityLogger(V8DOMActivityLogger* activityLogger) { m_activityLogg er = activityLogger; } |
| 91 | 91 |
| 92 v8::Local<v8::Value> compiledPrivateScript(String); | 92 v8::Local<v8::Value> compiledPrivateScript(String); |
| 93 void setCompiledPrivateScript(String, v8::Local<v8::Value>); | 93 void setCompiledPrivateScript(String, v8::Local<v8::Value>); |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 V8PerContextData(v8::Local<v8::Context>); | 96 V8PerContextData(v8::Local<v8::Context>); |
| 97 | 97 |
| 98 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*) ; | 98 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*) ; |
| 99 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*); | 99 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*); |
| 100 | 100 |
| 101 v8::Isolate* m_isolate; | 101 v8::Isolate* m_isolate; |
| 102 | 102 |
| 103 // For each possible type of wrapper, we keep a boilerplate object. | 103 // For each possible type of wrapper, we keep a boilerplate object. |
| 104 // The boilerplate is used to create additional wrappers of the same type. | 104 // The boilerplate is used to create additional wrappers of the same type. |
| 105 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Object, v8::kNotWeak> W rapperBoilerplateMap; | 105 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Object, v8::kNotWeak> W rapperBoilerplateMap; |
| 106 WrapperBoilerplateMap m_wrapperBoilerplates; | 106 WrapperBoilerplateMap m_wrapperBoilerplates; |
| 107 | 107 |
| 108 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak> ConstructorMap; | 108 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak> ConstructorMap; |
| 109 ConstructorMap m_constructorMap; | 109 ConstructorMap m_constructorMap; |
| 110 | 110 |
| 111 OwnPtr<gin::ContextHolder> m_contextHolder; | 111 OwnPtr<gin::ContextHolder> m_contextHolder; |
| 112 | 112 |
| 113 ScopedPersistent<v8::Context> m_context; | 113 ScopedPersistent<v8::Context> m_context; |
| 114 ScopedPersistent<v8::Value> m_errorPrototype; | 114 ScopedPersistent<v8::Value> m_errorPrototype; |
| 115 | 115 |
| 116 typedef Vector<OwnPtr<V0CustomElementBinding>> V0CustomElementBindingList; | 116 Persistent<V8CustomElementPerContextData> m_customElements; |
|
haraken
2016/05/26 08:33:46
Does this need to be a member of V8PerContextData?
dominicc (has gone to gerrit)
2016/05/27 04:54:17
OK, I tried to do this. Because putting things in
| |
| 117 V0CustomElementBindingList m_customElementBindings; | |
| 118 | 117 |
| 119 // This is owned by a static hash map in V8DOMActivityLogger. | 118 // This is owned by a static hash map in V8DOMActivityLogger. |
| 120 V8DOMActivityLogger* m_activityLogger; | 119 V8DOMActivityLogger* m_activityLogger; |
| 121 | 120 |
| 122 V8GlobalValueMap<String, v8::Value, v8::kNotWeak> m_compiledPrivateScript; | 121 V8GlobalValueMap<String, v8::Value, v8::kNotWeak> m_compiledPrivateScript; |
| 123 }; | 122 }; |
| 124 | 123 |
| 125 } // namespace blink | 124 } // namespace blink |
| 126 | 125 |
| 127 #endif // V8PerContextData_h | 126 #endif // V8PerContextData_h |
| OLD | NEW |