| 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 : public RefCounted<ScriptStateForErrorEvent> { |
| 187 public: |
| 188 class Scope { |
| 189 STACK_ALLOCATED(); |
| 190 |
| 191 public: |
| 192 explicit Scope(ScriptState*, v8::Local<v8::Context>); |
| 193 ~Scope(); |
| 194 |
| 195 private: |
| 196 RefPtr<ScriptState> m_scriptState; |
| 197 }; |
| 198 |
| 199 static PassRefPtr<ScriptStateForErrorEvent> create(v8::Local<v8::Context>); |
| 200 ScriptState* scriptState() { |
| 201 return ScriptState::from(m_context.newLocal(m_isolate)); |
| 202 } |
| 203 v8::Local<v8::Context> context() const { |
| 204 return m_context.newLocal(m_isolate); |
| 205 } |
| 206 |
| 207 private: |
| 208 ScriptStateForErrorEvent(v8::Local<v8::Context> context) |
| 209 : m_isolate(context->GetIsolate()), m_context(m_isolate, context) {} |
| 210 v8::Isolate* m_isolate; |
| 211 ScopedPersistent<v8::Context> m_context; |
| 212 }; |
| 213 |
| 186 } // namespace blink | 214 } // namespace blink |
| 187 | 215 |
| 188 #endif // ScriptState_h | 216 #endif // ScriptState_h |
| OLD | NEW |