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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 class V8PerContextData { | 57 class V8PerContextData { |
58 public: | 58 public: |
59 static PassOwnPtr<V8PerContextData> create(v8::Handle<v8::Context>); | 59 static PassOwnPtr<V8PerContextData> create(v8::Handle<v8::Context>); |
60 | 60 |
61 static V8PerContextData* from(v8::Handle<v8::Context>); | 61 static V8PerContextData* from(v8::Handle<v8::Context>); |
62 | 62 |
63 ~V8PerContextData(); | 63 ~V8PerContextData(); |
64 | 64 |
65 v8::Handle<v8::Context> context() { return m_context.newLocal(m_isolate); } | 65 v8::Handle<v8::Context> context() { return m_context.newLocal(m_isolate); } |
66 v8::Handle<v8::Function> functionConstructor() { return m_functionConstructo
r.newLocal(m_isolate); } | |
67 | 66 |
68 // To create JS Wrapper objects, we create a cache of a 'boiler plate' | 67 // To create JS Wrapper objects, we create a cache of a 'boiler plate' |
69 // object, and then simply Clone that object each time we need a new one. | 68 // object, and then simply Clone that object each time we need a new one. |
70 // This is faster than going through the full object creation process. | 69 // This is faster than going through the full object creation process. |
71 v8::Local<v8::Object> createWrapperFromCache(const WrapperTypeInfo* type) | 70 v8::Local<v8::Object> createWrapperFromCache(const WrapperTypeInfo* type) |
72 { | 71 { |
73 v8::Local<v8::Object> boilerplate = m_wrapperBoilerplates.Get(type); | 72 v8::Local<v8::Object> boilerplate = m_wrapperBoilerplates.Get(type); |
74 return !boilerplate.IsEmpty() ? boilerplate->Clone() : createWrapperFrom
CacheSlowCase(type); | 73 return !boilerplate.IsEmpty() ? boilerplate->Clone() : createWrapperFrom
CacheSlowCase(type); |
75 } | 74 } |
76 | 75 |
(...skipping 22 matching lines...) Expand all Loading... |
99 typedef V8PersistentValueMap<const WrapperTypeInfo*, v8::Object, false> Wrap
perBoilerplateMap; | 98 typedef V8PersistentValueMap<const WrapperTypeInfo*, v8::Object, false> Wrap
perBoilerplateMap; |
100 WrapperBoilerplateMap m_wrapperBoilerplates; | 99 WrapperBoilerplateMap m_wrapperBoilerplates; |
101 | 100 |
102 typedef V8PersistentValueMap<const WrapperTypeInfo*, v8::Function, false> Co
nstructorMap; | 101 typedef V8PersistentValueMap<const WrapperTypeInfo*, v8::Function, false> Co
nstructorMap; |
103 ConstructorMap m_constructorMap; | 102 ConstructorMap m_constructorMap; |
104 | 103 |
105 OwnPtr<gin::ContextHolder> m_contextHolder; | 104 OwnPtr<gin::ContextHolder> m_contextHolder; |
106 | 105 |
107 ScopedPersistent<v8::Context> m_context; | 106 ScopedPersistent<v8::Context> m_context; |
108 ScopedPersistent<v8::Value> m_errorPrototype; | 107 ScopedPersistent<v8::Value> m_errorPrototype; |
109 ScopedPersistent<v8::Function> m_functionConstructor; | |
110 | 108 |
111 typedef WTF::HashMap<CustomElementDefinition*, OwnPtr<CustomElementBinding>
> CustomElementBindingMap; | 109 typedef WTF::HashMap<CustomElementDefinition*, OwnPtr<CustomElementBinding>
> CustomElementBindingMap; |
112 OwnPtr<CustomElementBindingMap> m_customElementBindings; | 110 OwnPtr<CustomElementBindingMap> m_customElementBindings; |
113 }; | 111 }; |
114 | 112 |
115 class V8PerContextDebugData { | 113 class V8PerContextDebugData { |
116 public: | 114 public: |
117 static bool setContextDebugData(v8::Handle<v8::Context>, const char* worldNa
me, int debugId); | 115 static bool setContextDebugData(v8::Handle<v8::Context>, const char* worldNa
me, int debugId); |
118 static int contextDebugId(v8::Handle<v8::Context>); | 116 static int contextDebugId(v8::Handle<v8::Context>); |
119 }; | 117 }; |
120 | 118 |
121 } // namespace blink | 119 } // namespace blink |
122 | 120 |
123 #endif // V8PerContextData_h | 121 #endif // V8PerContextData_h |
OLD | NEW |