| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
| 44 #include "wtf/Vector.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 struct V8NPObject; | |
| 54 typedef WTF::Vector<V8NPObject*> V8NPObjectVector; | |
| 55 typedef WTF::HashMap<int, V8NPObjectVector> V8NPObjectMap; | |
| 56 | 53 |
| 57 enum V8ContextEmbedderDataField { | 54 enum V8ContextEmbedderDataField { |
| 58 v8ContextPerContextDataIndex = static_cast<int>(gin::kPerContextDataStartInd
ex + gin::kEmbedderBlink), | 55 v8ContextPerContextDataIndex = static_cast<int>(gin::kPerContextDataStartInd
ex + gin::kEmbedderBlink), |
| 59 }; | 56 }; |
| 60 | 57 |
| 61 class CORE_EXPORT V8PerContextData final { | 58 class CORE_EXPORT V8PerContextData final { |
| 62 USING_FAST_MALLOC(V8PerContextData); | 59 USING_FAST_MALLOC(V8PerContextData); |
| 63 WTF_MAKE_NONCOPYABLE(V8PerContextData); | 60 WTF_MAKE_NONCOPYABLE(V8PerContextData); |
| 64 public: | 61 public: |
| 65 static PassOwnPtr<V8PerContextData> create(v8::Local<v8::Context>); | 62 static PassOwnPtr<V8PerContextData> create(v8::Local<v8::Context>); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 80 } | 77 } |
| 81 | 78 |
| 82 v8::Local<v8::Function> constructorForType(const WrapperTypeInfo* type) | 79 v8::Local<v8::Function> constructorForType(const WrapperTypeInfo* type) |
| 83 { | 80 { |
| 84 v8::Local<v8::Function> interfaceObject = m_constructorMap.Get(type); | 81 v8::Local<v8::Function> interfaceObject = m_constructorMap.Get(type); |
| 85 return (!interfaceObject.IsEmpty()) ? interfaceObject : constructorForTy
peSlowCase(type); | 82 return (!interfaceObject.IsEmpty()) ? interfaceObject : constructorForTy
peSlowCase(type); |
| 86 } | 83 } |
| 87 | 84 |
| 88 v8::Local<v8::Object> prototypeForType(const WrapperTypeInfo*); | 85 v8::Local<v8::Object> prototypeForType(const WrapperTypeInfo*); |
| 89 | 86 |
| 90 V8NPObjectMap* getV8NPObjectMap() { return &m_v8NPObjectMap; } | |
| 91 | |
| 92 void addCustomElementBinding(PassOwnPtr<CustomElementBinding>); | 87 void addCustomElementBinding(PassOwnPtr<CustomElementBinding>); |
| 93 | 88 |
| 94 V8DOMActivityLogger* activityLogger() const { return m_activityLogger; } | 89 V8DOMActivityLogger* activityLogger() const { return m_activityLogger; } |
| 95 void setActivityLogger(V8DOMActivityLogger* activityLogger) { m_activityLogg
er = activityLogger; } | 90 void setActivityLogger(V8DOMActivityLogger* activityLogger) { m_activityLogg
er = activityLogger; } |
| 96 | 91 |
| 97 v8::Local<v8::Value> compiledPrivateScript(String); | 92 v8::Local<v8::Value> compiledPrivateScript(String); |
| 98 void setCompiledPrivateScript(String, v8::Local<v8::Value>); | 93 void setCompiledPrivateScript(String, v8::Local<v8::Value>); |
| 99 | 94 |
| 100 private: | 95 private: |
| 101 V8PerContextData(v8::Local<v8::Context>); | 96 V8PerContextData(v8::Local<v8::Context>); |
| 102 | 97 |
| 103 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*)
; | 98 v8::Local<v8::Object> createWrapperFromCacheSlowCase(const WrapperTypeInfo*)
; |
| 104 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*); | 99 v8::Local<v8::Function> constructorForTypeSlowCase(const WrapperTypeInfo*); |
| 105 | 100 |
| 106 v8::Isolate* m_isolate; | 101 v8::Isolate* m_isolate; |
| 107 | 102 |
| 108 // For each possible type of wrapper, we keep a boilerplate object. | 103 // For each possible type of wrapper, we keep a boilerplate object. |
| 109 // 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. |
| 110 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Object, v8::kNotWeak> W
rapperBoilerplateMap; | 105 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Object, v8::kNotWeak> W
rapperBoilerplateMap; |
| 111 WrapperBoilerplateMap m_wrapperBoilerplates; | 106 WrapperBoilerplateMap m_wrapperBoilerplates; |
| 112 | 107 |
| 113 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak>
ConstructorMap; | 108 typedef V8GlobalValueMap<const WrapperTypeInfo*, v8::Function, v8::kNotWeak>
ConstructorMap; |
| 114 ConstructorMap m_constructorMap; | 109 ConstructorMap m_constructorMap; |
| 115 | 110 |
| 116 V8NPObjectMap m_v8NPObjectMap; | |
| 117 | |
| 118 OwnPtr<gin::ContextHolder> m_contextHolder; | 111 OwnPtr<gin::ContextHolder> m_contextHolder; |
| 119 | 112 |
| 120 ScopedPersistent<v8::Context> m_context; | 113 ScopedPersistent<v8::Context> m_context; |
| 121 ScopedPersistent<v8::Value> m_errorPrototype; | 114 ScopedPersistent<v8::Value> m_errorPrototype; |
| 122 | 115 |
| 123 typedef Vector<OwnPtr<CustomElementBinding>> CustomElementBindingList; | 116 typedef Vector<OwnPtr<CustomElementBinding>> CustomElementBindingList; |
| 124 CustomElementBindingList m_customElementBindings; | 117 CustomElementBindingList m_customElementBindings; |
| 125 | 118 |
| 126 // This is owned by a static hash map in V8DOMActivityLogger. | 119 // This is owned by a static hash map in V8DOMActivityLogger. |
| 127 V8DOMActivityLogger* m_activityLogger; | 120 V8DOMActivityLogger* m_activityLogger; |
| 128 | 121 |
| 129 V8GlobalValueMap<String, v8::Value, v8::kNotWeak> m_compiledPrivateScript; | 122 V8GlobalValueMap<String, v8::Value, v8::kNotWeak> m_compiledPrivateScript; |
| 130 }; | 123 }; |
| 131 | 124 |
| 132 } // namespace blink | 125 } // namespace blink |
| 133 | 126 |
| 134 #endif // V8PerContextData_h | 127 #endif // V8PerContextData_h |
| OLD | NEW |