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/v8/ScopedPersistent.h" | 8 #include "bindings/v8/ScopedPersistent.h" |
9 #include "bindings/v8/V8PerContextData.h" | 9 #include "bindings/v8/V8PerContextData.h" |
10 #include "wtf/RefCounted.h" | 10 #include "wtf/RefCounted.h" |
11 #include <v8.h> | 11 #include <v8.h> |
12 | 12 |
13 namespace WebCore { | 13 namespace WebCore { |
14 | 14 |
15 class DOMWindow; | 15 class LocalDOMWindow; |
16 class DOMWrapperWorld; | 16 class DOMWrapperWorld; |
17 class ExecutionContext; | 17 class ExecutionContext; |
18 class LocalFrame; | 18 class LocalFrame; |
19 class ScriptValue; | 19 class ScriptValue; |
20 | 20 |
21 // ScriptState is created when v8::Context is created. | 21 // ScriptState is created when v8::Context is created. |
22 // ScriptState is destroyed when v8::Context is garbage-collected and | 22 // ScriptState is destroyed when v8::Context is garbage-collected and |
23 // all V8 proxy objects that have references to the ScriptState are destructed. | 23 // all V8 proxy objects that have references to the ScriptState are destructed. |
24 class ScriptState : public RefCounted<ScriptState> { | 24 class ScriptState : public RefCounted<ScriptState> { |
25 WTF_MAKE_NONCOPYABLE(ScriptState); | 25 WTF_MAKE_NONCOPYABLE(ScriptState); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 // valid embedder data in the embedder field. | 61 // valid embedder data in the embedder field. |
62 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState); | 62 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState); |
63 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState->context() == conte
xt); | 63 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState->context() == conte
xt); |
64 return scriptState; | 64 return scriptState; |
65 } | 65 } |
66 | 66 |
67 static ScriptState* forMainWorld(LocalFrame*); | 67 static ScriptState* forMainWorld(LocalFrame*); |
68 | 68 |
69 v8::Isolate* isolate() const { return m_isolate; } | 69 v8::Isolate* isolate() const { return m_isolate; } |
70 DOMWrapperWorld& world() const { return *m_world; } | 70 DOMWrapperWorld& world() const { return *m_world; } |
71 DOMWindow* domWindow() const; | 71 LocalDOMWindow* domWindow() const; |
72 virtual ExecutionContext* executionContext() const; | 72 virtual ExecutionContext* executionContext() const; |
73 virtual void setExecutionContext(ExecutionContext*); | 73 virtual void setExecutionContext(ExecutionContext*); |
74 | 74 |
75 // This can return an empty handle if the v8::Context is gone. | 75 // This can return an empty handle if the v8::Context is gone. |
76 v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolat
e); } | 76 v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolat
e); } |
77 bool contextIsEmpty() const { return m_context.isEmpty(); } | 77 bool contextIsEmpty() const { return m_context.isEmpty(); } |
78 void clearContext() { return m_context.clear(); } | 78 void clearContext() { return m_context.clear(); } |
79 | 79 |
80 V8PerContextData* perContextData() const { return m_perContextData.get(); } | 80 V8PerContextData* perContextData() const { return m_perContextData.get(); } |
81 void disposePerContextData() { m_perContextData = nullptr; } | 81 void disposePerContextData() { m_perContextData = nullptr; } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 136 } |
137 | 137 |
138 private: | 138 private: |
139 RefPtr<ScriptState> m_scriptState; | 139 RefPtr<ScriptState> m_scriptState; |
140 ScopedPersistent<v8::Context> m_context; | 140 ScopedPersistent<v8::Context> m_context; |
141 }; | 141 }; |
142 | 142 |
143 } | 143 } |
144 | 144 |
145 #endif // ScriptState_h | 145 #endif // ScriptState_h |
OLD | NEW |