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 "wtf/RefCounted.h" | 10 #include "wtf/RefCounted.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class ScriptState : public RefCounted<ScriptState> { | 25 class ScriptState : public RefCounted<ScriptState> { |
26 WTF_MAKE_NONCOPYABLE(ScriptState); | 26 WTF_MAKE_NONCOPYABLE(ScriptState); |
27 public: | 27 public: |
28 class Scope { | 28 class Scope { |
29 public: | 29 public: |
30 // You need to make sure that scriptState->context() is not empty before
creating a Scope. | 30 // You need to make sure that scriptState->context() is not empty before
creating a Scope. |
31 explicit Scope(ScriptState* scriptState) | 31 explicit Scope(ScriptState* scriptState) |
32 : m_handleScope(scriptState->isolate()) | 32 : m_handleScope(scriptState->isolate()) |
33 , m_context(scriptState->context()) | 33 , m_context(scriptState->context()) |
34 { | 34 { |
35 ASSERT(!m_context.IsEmpty()); | 35 ASSERT(scriptState->contextIsValid()); |
36 m_context->Enter(); | 36 m_context->Enter(); |
37 } | 37 } |
38 | 38 |
39 ~Scope() | 39 ~Scope() |
40 { | 40 { |
41 m_context->Exit(); | 41 m_context->Exit(); |
42 } | 42 } |
43 | 43 |
44 private: | 44 private: |
45 v8::HandleScope m_handleScope; | 45 v8::HandleScope m_handleScope; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 | 150 |
151 private: | 151 private: |
152 RefPtr<ScriptState> m_scriptState; | 152 RefPtr<ScriptState> m_scriptState; |
153 ScopedPersistent<v8::Context> m_context; | 153 ScopedPersistent<v8::Context> m_context; |
154 }; | 154 }; |
155 | 155 |
156 } | 156 } |
157 | 157 |
158 #endif // ScriptState_h | 158 #endif // ScriptState_h |
OLD | NEW |