Chromium Code Reviews| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 void setThreadDebugger(std::unique_ptr<ThreadDebugger>); | 160 void setThreadDebugger(std::unique_ptr<ThreadDebugger>); |
| 161 ThreadDebugger* threadDebugger(); | 161 ThreadDebugger* threadDebugger(); |
| 162 | 162 |
| 163 using ActiveScriptWrappableSet = | 163 using ActiveScriptWrappableSet = |
| 164 HeapHashSet<WeakMember<ActiveScriptWrappableBase>>; | 164 HeapHashSet<WeakMember<ActiveScriptWrappableBase>>; |
| 165 void addActiveScriptWrappable(ActiveScriptWrappableBase*); | 165 void addActiveScriptWrappable(ActiveScriptWrappableBase*); |
| 166 const ActiveScriptWrappableSet* activeScriptWrappables() const { | 166 const ActiveScriptWrappableSet* activeScriptWrappables() const { |
| 167 return m_activeScriptWrappables.get(); | 167 return m_activeScriptWrappables.get(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 class TemporaryScriptWrappableVisitorScope { | |
| 171 WTF_MAKE_NONCOPYABLE(TemporaryScriptWrappableVisitorScope); | |
| 172 STACK_ALLOCATED(); | |
| 173 | |
| 174 public: | |
| 175 TemporaryScriptWrappableVisitorScope(v8::Isolate* isolate, | |
| 176 ScriptWrappableVisitor* visitor) | |
| 177 : m_isolate(isolate) { | |
| 178 m_savedVisitor = currentVisitor(m_isolate); | |
| 179 swapInNewVisitor(visitor); | |
| 180 } | |
| 181 ~TemporaryScriptWrappableVisitorScope() { | |
| 182 swapInNewVisitor(m_savedVisitor); | |
| 183 } | |
| 184 | |
| 185 private: | |
| 186 inline ScriptWrappableVisitor* currentVisitor(v8::Isolate* isolate) { | |
| 187 return V8PerIsolateData::from(m_isolate)->scriptWrappableVisitor(); | |
| 188 } | |
| 189 | |
| 190 void swapInNewVisitor(ScriptWrappableVisitor*); | |
|
haraken
2017/01/12 16:25:18
Nit: swapInNewVisitor => setVisitor ?
(Swap sound
Michael Lippautz
2017/01/13 15:08:40
Done.
| |
| 191 | |
| 192 v8::Isolate* m_isolate; | |
| 193 ScriptWrappableVisitor* m_savedVisitor; | |
| 194 }; | |
| 195 | |
| 170 void setScriptWrappableVisitor( | 196 void setScriptWrappableVisitor( |
| 171 std::unique_ptr<ScriptWrappableVisitor> visitor) { | 197 std::unique_ptr<ScriptWrappableVisitor> visitor) { |
| 172 m_scriptWrappableVisitor = std::move(visitor); | 198 m_scriptWrappableVisitor = std::move(visitor); |
| 173 } | 199 } |
| 174 ScriptWrappableVisitor* scriptWrappableVisitor() { | 200 ScriptWrappableVisitor* scriptWrappableVisitor() { |
| 175 return m_scriptWrappableVisitor.get(); | 201 return m_scriptWrappableVisitor.get(); |
| 176 } | 202 } |
| 177 | 203 |
| 178 private: | 204 private: |
| 179 explicit V8PerIsolateData(WebTaskRunner*); | 205 explicit V8PerIsolateData(WebTaskRunner*); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 Vector<std::unique_ptr<EndOfScopeTask>> m_endOfScopeTasks; | 247 Vector<std::unique_ptr<EndOfScopeTask>> m_endOfScopeTasks; |
| 222 std::unique_ptr<ThreadDebugger> m_threadDebugger; | 248 std::unique_ptr<ThreadDebugger> m_threadDebugger; |
| 223 | 249 |
| 224 Persistent<ActiveScriptWrappableSet> m_activeScriptWrappables; | 250 Persistent<ActiveScriptWrappableSet> m_activeScriptWrappables; |
| 225 std::unique_ptr<ScriptWrappableVisitor> m_scriptWrappableVisitor; | 251 std::unique_ptr<ScriptWrappableVisitor> m_scriptWrappableVisitor; |
| 226 }; | 252 }; |
| 227 | 253 |
| 228 } // namespace blink | 254 } // namespace blink |
| 229 | 255 |
| 230 #endif // V8PerIsolateData_h | 256 #endif // V8PerIsolateData_h |
| OLD | NEW |