OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "bindings/core/v8/ScriptState.h" | 30 #include "bindings/core/v8/ScriptState.h" |
31 #include "bindings/core/v8/ScriptWrappableVisitor.h" | 31 #include "bindings/core/v8/ScriptWrappableVisitor.h" |
32 #include "bindings/core/v8/V8HiddenValue.h" | 32 #include "bindings/core/v8/V8HiddenValue.h" |
33 #include "bindings/core/v8/WrapperTypeInfo.h" | 33 #include "bindings/core/v8/WrapperTypeInfo.h" |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "gin/public/isolate_holder.h" | 35 #include "gin/public/isolate_holder.h" |
36 #include "gin/public/v8_idle_task_runner.h" | 36 #include "gin/public/v8_idle_task_runner.h" |
37 #include "platform/heap/Handle.h" | 37 #include "platform/heap/Handle.h" |
38 #include "wtf/HashMap.h" | 38 #include "wtf/HashMap.h" |
39 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
| 40 #include "wtf/OwnPtr.h" |
40 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
41 #include <memory> | |
42 #include <v8.h> | 42 #include <v8.h> |
43 | 43 |
44 namespace blink { | 44 namespace blink { |
45 | 45 |
46 class ActiveScriptWrappable; | 46 class ActiveScriptWrappable; |
47 class DOMDataStore; | 47 class DOMDataStore; |
48 class StringCache; | 48 class StringCache; |
49 class ThreadDebugger; | 49 class ThreadDebugger; |
50 class V8PrivateProperty; | 50 class V8PrivateProperty; |
51 struct WrapperTypeInfo; | 51 struct WrapperTypeInfo; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 { | 94 { |
95 ASSERT(isolate); | 95 ASSERT(isolate); |
96 ASSERT(isolate->GetData(gin::kEmbedderBlink)); | 96 ASSERT(isolate->GetData(gin::kEmbedderBlink)); |
97 return static_cast<V8PerIsolateData*>(isolate->GetData(gin::kEmbedderBli
nk)); | 97 return static_cast<V8PerIsolateData*>(isolate->GetData(gin::kEmbedderBli
nk)); |
98 } | 98 } |
99 | 99 |
100 static void willBeDestroyed(v8::Isolate*); | 100 static void willBeDestroyed(v8::Isolate*); |
101 static void destroy(v8::Isolate*); | 101 static void destroy(v8::Isolate*); |
102 static v8::Isolate* mainThreadIsolate(); | 102 static v8::Isolate* mainThreadIsolate(); |
103 | 103 |
104 static void enableIdleTasks(v8::Isolate*, std::unique_ptr<gin::V8IdleTaskRun
ner>); | 104 static void enableIdleTasks(v8::Isolate*, PassOwnPtr<gin::V8IdleTaskRunner>)
; |
105 | 105 |
106 v8::Isolate* isolate() { return m_isolateHolder->isolate(); } | 106 v8::Isolate* isolate() { return m_isolateHolder->isolate(); } |
107 | 107 |
108 StringCache* getStringCache() { return m_stringCache.get(); } | 108 StringCache* getStringCache() { return m_stringCache.get(); } |
109 | 109 |
110 v8::Persistent<v8::Value>& ensureLiveRoot(); | 110 v8::Persistent<v8::Value>& ensureLiveRoot(); |
111 | 111 |
112 bool isHandlingRecursionLevelError() const { return m_isHandlingRecursionLev
elError; } | 112 bool isHandlingRecursionLevelError() const { return m_isHandlingRecursionLev
elError; } |
113 void setIsHandlingRecursionLevelError(bool value) { m_isHandlingRecursionLev
elError = value; } | 113 void setIsHandlingRecursionLevelError(bool value) { m_isHandlingRecursionLev
elError = value; } |
114 | 114 |
(...skipping 14 matching lines...) Expand all Loading... |
129 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>); | 129 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>); |
130 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v
8::Local<v8::Value>); | 130 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v
8::Local<v8::Value>); |
131 | 131 |
132 v8::Local<v8::Context> ensureScriptRegexpContext(); | 132 v8::Local<v8::Context> ensureScriptRegexpContext(); |
133 void clearScriptRegexpContext(); | 133 void clearScriptRegexpContext(); |
134 | 134 |
135 // EndOfScopeTasks are run when control is returning | 135 // EndOfScopeTasks are run when control is returning |
136 // to C++ from script, after executing a script task (e.g. callback, | 136 // to C++ from script, after executing a script task (e.g. callback, |
137 // event) or microtasks (e.g. promise). This is explicitly needed for | 137 // event) or microtasks (e.g. promise). This is explicitly needed for |
138 // Indexed DB transactions per spec, but should in general be avoided. | 138 // Indexed DB transactions per spec, but should in general be avoided. |
139 void addEndOfScopeTask(std::unique_ptr<EndOfScopeTask>); | 139 void addEndOfScopeTask(PassOwnPtr<EndOfScopeTask>); |
140 void runEndOfScopeTasks(); | 140 void runEndOfScopeTasks(); |
141 void clearEndOfScopeTasks(); | 141 void clearEndOfScopeTasks(); |
142 | 142 |
143 void setThreadDebugger(std::unique_ptr<ThreadDebugger>); | 143 void setThreadDebugger(PassOwnPtr<ThreadDebugger>); |
144 ThreadDebugger* threadDebugger(); | 144 ThreadDebugger* threadDebugger(); |
145 | 145 |
146 using ActiveScriptWrappableSet = HeapHashSet<WeakMember<ActiveScriptWrappabl
e>>; | 146 using ActiveScriptWrappableSet = HeapHashSet<WeakMember<ActiveScriptWrappabl
e>>; |
147 void addActiveScriptWrappable(ActiveScriptWrappable*); | 147 void addActiveScriptWrappable(ActiveScriptWrappable*); |
148 const ActiveScriptWrappableSet* activeScriptWrappables() const { return m_ac
tiveScriptWrappables.get(); } | 148 const ActiveScriptWrappableSet* activeScriptWrappables() const { return m_ac
tiveScriptWrappables.get(); } |
149 | 149 |
150 void setScriptWrappableVisitor(std::unique_ptr<ScriptWrappableVisitor> visit
or) { m_scriptWrappableVisitor = std::move(visitor); } | 150 void setScriptWrappableVisitor(std::unique_ptr<ScriptWrappableVisitor> visit
or) { m_scriptWrappableVisitor = std::move(visitor); } |
151 ScriptWrappableVisitor* scriptWrappableVisitor() { return m_scriptWrappableV
isitor.get(); } | 151 ScriptWrappableVisitor* scriptWrappableVisitor() { return m_scriptWrappableV
isitor.get(); } |
152 | 152 |
153 private: | 153 private: |
154 V8PerIsolateData(); | 154 V8PerIsolateData(); |
155 ~V8PerIsolateData(); | 155 ~V8PerIsolateData(); |
156 | 156 |
157 static void useCounterCallback(v8::Isolate*, v8::Isolate::UseCounterFeature)
; | 157 static void useCounterCallback(v8::Isolate*, v8::Isolate::UseCounterFeature)
; |
158 | 158 |
159 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> V8FunctionTe
mplateMap; | 159 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> V8FunctionTe
mplateMap; |
160 V8FunctionTemplateMap& selectInterfaceTemplateMap(const DOMWrapperWorld&); | 160 V8FunctionTemplateMap& selectInterfaceTemplateMap(const DOMWrapperWorld&); |
161 V8FunctionTemplateMap& selectOperationTemplateMap(const DOMWrapperWorld&); | 161 V8FunctionTemplateMap& selectOperationTemplateMap(const DOMWrapperWorld&); |
162 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>, V8F
unctionTemplateMap&); | 162 bool hasInstance(const WrapperTypeInfo* untrusted, v8::Local<v8::Value>, V8F
unctionTemplateMap&); |
163 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v
8::Local<v8::Value>, V8FunctionTemplateMap&); | 163 v8::Local<v8::Object> findInstanceInPrototypeChain(const WrapperTypeInfo*, v
8::Local<v8::Value>, V8FunctionTemplateMap&); |
164 | 164 |
165 std::unique_ptr<gin::IsolateHolder> m_isolateHolder; | 165 OwnPtr<gin::IsolateHolder> m_isolateHolder; |
166 | 166 |
167 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for | 167 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for |
168 // the inerface objects. | 168 // the inerface objects. |
169 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld; | 169 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld; |
170 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld; | 170 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld; |
171 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for | 171 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for |
172 // the cross-origin accessible DOM operations. | 172 // the cross-origin accessible DOM operations. |
173 V8FunctionTemplateMap m_operationTemplateMapForMainWorld; | 173 V8FunctionTemplateMap m_operationTemplateMapForMainWorld; |
174 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld; | 174 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld; |
175 | 175 |
176 std::unique_ptr<StringCache> m_stringCache; | 176 OwnPtr<StringCache> m_stringCache; |
177 std::unique_ptr<V8HiddenValue> m_hiddenValue; | 177 OwnPtr<V8HiddenValue> m_hiddenValue; |
178 std::unique_ptr<V8PrivateProperty> m_privateProperty; | 178 std::unique_ptr<V8PrivateProperty> m_privateProperty; |
179 ScopedPersistent<v8::Value> m_liveRoot; | 179 ScopedPersistent<v8::Value> m_liveRoot; |
180 RefPtr<ScriptState> m_scriptRegexpScriptState; | 180 RefPtr<ScriptState> m_scriptRegexpScriptState; |
181 | 181 |
182 bool m_constructorMode; | 182 bool m_constructorMode; |
183 friend class ConstructorMode; | 183 friend class ConstructorMode; |
184 | 184 |
185 bool m_useCounterDisabled; | 185 bool m_useCounterDisabled; |
186 friend class UseCounterDisabledScope; | 186 friend class UseCounterDisabledScope; |
187 | 187 |
188 bool m_isHandlingRecursionLevelError; | 188 bool m_isHandlingRecursionLevelError; |
189 bool m_isReportingException; | 189 bool m_isReportingException; |
190 | 190 |
191 Vector<std::unique_ptr<EndOfScopeTask>> m_endOfScopeTasks; | 191 Vector<OwnPtr<EndOfScopeTask>> m_endOfScopeTasks; |
192 std::unique_ptr<ThreadDebugger> m_threadDebugger; | 192 OwnPtr<ThreadDebugger> m_threadDebugger; |
193 | 193 |
194 Persistent<ActiveScriptWrappableSet> m_activeScriptWrappables; | 194 Persistent<ActiveScriptWrappableSet> m_activeScriptWrappables; |
195 std::unique_ptr<ScriptWrappableVisitor> m_scriptWrappableVisitor; | 195 std::unique_ptr<ScriptWrappableVisitor> m_scriptWrappableVisitor; |
196 }; | 196 }; |
197 | 197 |
198 } // namespace blink | 198 } // namespace blink |
199 | 199 |
200 #endif // V8PerIsolateData_h | 200 #endif // V8PerIsolateData_h |
OLD | NEW |