Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ScriptState_h | 5 #ifndef ScriptState_h |
| 6 #define ScriptState_h | 6 #define ScriptState_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScopedPersistent.h" | 8 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "bindings/core/v8/V8PerContextData.h" | 9 #include "bindings/core/v8/V8PerContextData.h" |
| 10 #include "core/CoreExport.h" | 10 #include "core/CoreExport.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 void clear() { | 176 void clear() { |
| 177 m_scriptState = nullptr; | 177 m_scriptState = nullptr; |
| 178 m_context.clear(); | 178 m_context.clear(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 RefPtr<ScriptState> m_scriptState; | 182 RefPtr<ScriptState> m_scriptState; |
| 183 ScopedPersistent<v8::Context> m_context; | 183 ScopedPersistent<v8::Context> m_context; |
| 184 }; | 184 }; |
| 185 | 185 |
| 186 class ScriptStateForErrorEvent { | |
| 187 STACK_ALLOCATED(); | |
| 188 WTF_MAKE_NONCOPYABLE(ScriptStateForErrorEvent); | |
| 189 | |
| 190 public: | |
| 191 static ScriptStateForErrorEvent* current() { return s_topOfStack; } | |
| 192 | |
| 193 ScriptStateForErrorEvent(v8::Local<v8::Context> context) | |
|
haraken
2016/11/02 01:40:18
Add explicit.
| |
| 194 : m_prev(s_topOfStack), | |
| 195 m_isolate(context->GetIsolate()), | |
| 196 m_context(m_isolate, context) { | |
| 197 s_topOfStack = this; | |
| 198 } | |
| 199 | |
| 200 ~ScriptStateForErrorEvent() { | |
| 201 s_topOfStack = s_topOfStack->m_prev; | |
| 202 } | |
| 203 | |
| 204 ScriptState* scriptState() { | |
| 205 return ScriptState::from(m_context.newLocal(m_isolate)); | |
| 206 } | |
| 207 | |
| 208 v8::Local<v8::Context> context() const { | |
| 209 return m_context.newLocal(m_isolate); | |
| 210 } | |
| 211 | |
| 212 private: | |
| 213 static ScriptStateForErrorEvent* s_topOfStack; | |
| 214 ScriptStateForErrorEvent* m_prev; | |
| 215 | |
| 216 v8::Isolate* m_isolate; | |
| 217 ScopedPersistent<v8::Context> m_context; | |
|
haraken
2016/11/02 01:40:18
You can use v8::Local<v8::Context> because ScriptS
| |
| 218 }; | |
| 219 | |
| 186 } // namespace blink | 220 } // namespace blink |
| 187 | 221 |
| 188 #endif // ScriptState_h | 222 #endif // ScriptState_h |
| OLD | NEW |