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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return false; | 67 return false; |
68 return context != v8::Debug::GetDebugContext(isolate); | 68 return context != v8::Debug::GetDebugContext(isolate); |
69 } | 69 } |
70 | 70 |
71 static ScriptState* from(v8::Local<v8::Context> context) | 71 static ScriptState* from(v8::Local<v8::Context> context) |
72 { | 72 { |
73 ASSERT(!context.IsEmpty()); | 73 ASSERT(!context.IsEmpty()); |
74 ScriptState* scriptState = static_cast<ScriptState*>(context->GetAligned
PointerFromEmbedderData(v8ContextPerContextDataIndex)); | 74 ScriptState* scriptState = static_cast<ScriptState*>(context->GetAligned
PointerFromEmbedderData(v8ContextPerContextDataIndex)); |
75 // ScriptState::from() must not be called for a context that does not ha
ve | 75 // ScriptState::from() must not be called for a context that does not ha
ve |
76 // valid embedder data in the embedder field. | 76 // valid embedder data in the embedder field. |
77 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState); | 77 SECURITY_CHECK(scriptState); |
78 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(scriptState->context() == conte
xt); | 78 SECURITY_CHECK(scriptState->context() == context); |
79 return scriptState; | 79 return scriptState; |
80 } | 80 } |
81 | 81 |
82 // These methods can return nullptr if the context associated with the | 82 // These methods can return nullptr if the context associated with the |
83 // ScriptState has already been detached. | 83 // ScriptState has already been detached. |
84 static ScriptState* forMainWorld(LocalFrame*); | 84 static ScriptState* forMainWorld(LocalFrame*); |
85 static ScriptState* forWorld(LocalFrame*, DOMWrapperWorld&); | 85 static ScriptState* forWorld(LocalFrame*, DOMWrapperWorld&); |
86 | 86 |
87 v8::Isolate* isolate() const { return m_isolate; } | 87 v8::Isolate* isolate() const { return m_isolate; } |
88 DOMWrapperWorld& world() const { return *m_world; } | 88 DOMWrapperWorld& world() const { return *m_world; } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 } | 152 } |
153 | 153 |
154 private: | 154 private: |
155 RefPtr<ScriptState> m_scriptState; | 155 RefPtr<ScriptState> m_scriptState; |
156 ScopedPersistent<v8::Context> m_context; | 156 ScopedPersistent<v8::Context> m_context; |
157 }; | 157 }; |
158 | 158 |
159 } // namespace blink | 159 } // namespace blink |
160 | 160 |
161 #endif // ScriptState_h | 161 #endif // ScriptState_h |
OLD | NEW |