Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptState.h

Issue 2793003003: Move ScriptState::forWorld/ScriptState::forMainWorld (Part 3) (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptState.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 8 #include <memory>
9 9
10 #include "bindings/core/v8/ScopedPersistent.h" 10 #include "bindings/core/v8/ScopedPersistent.h"
11 #include "bindings/core/v8/V8PerContextData.h" 11 #include "bindings/core/v8/V8PerContextData.h"
12 #include "core/CoreExport.h" 12 #include "core/CoreExport.h"
13 #include "v8/include/v8-debug.h" 13 #include "v8/include/v8-debug.h"
14 #include "v8/include/v8.h" 14 #include "v8/include/v8.h"
15 #include "wtf/RefCounted.h" 15 #include "wtf/RefCounted.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class LocalDOMWindow; 19 class LocalDOMWindow;
20 class DOMWrapperWorld; 20 class DOMWrapperWorld;
21 class ExecutionContext; 21 class ExecutionContext;
22 class LocalFrame;
23 class ScriptValue; 22 class ScriptValue;
24 23
25 // ScriptState is an abstraction class that holds all information about script 24 // ScriptState is an abstraction class that holds all information about script
26 // exectuion (e.g., v8::Isolate, v8::Context, DOMWrapperWorld, ExecutionContext 25 // exectuion (e.g., v8::Isolate, v8::Context, DOMWrapperWorld, ExecutionContext
27 // etc). If you need any info about the script execution, you're expected to 26 // etc). If you need any info about the script execution, you're expected to
28 // pass around ScriptState in the code base. ScriptState is in a 1:1 27 // pass around ScriptState in the code base. ScriptState is in a 1:1
29 // relationship with v8::Context. 28 // relationship with v8::Context.
30 // 29 //
31 // When you need ScriptState, you can add [CallWith=ScriptState] to IDL files 30 // When you need ScriptState, you can add [CallWith=ScriptState] to IDL files
32 // and pass around ScriptState into a place where you need ScriptState. 31 // and pass around ScriptState into a place where you need ScriptState.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 ScriptState* scriptState = 128 ScriptState* scriptState =
130 static_cast<ScriptState*>(context->GetAlignedPointerFromEmbedderData( 129 static_cast<ScriptState*>(context->GetAlignedPointerFromEmbedderData(
131 v8ContextPerContextDataIndex)); 130 v8ContextPerContextDataIndex));
132 // ScriptState::from() must not be called for a context that does not have 131 // ScriptState::from() must not be called for a context that does not have
133 // valid embedder data in the embedder field. 132 // valid embedder data in the embedder field.
134 SECURITY_CHECK(scriptState); 133 SECURITY_CHECK(scriptState);
135 SECURITY_CHECK(scriptState->context() == context); 134 SECURITY_CHECK(scriptState->context() == context);
136 return scriptState; 135 return scriptState;
137 } 136 }
138 137
139 // These methods can return nullptr if the context associated with the
140 // ScriptState has already been detached.
141
142 // DEPRECATED: Use toScriptStateForMainWorld.
143 static ScriptState* forMainWorld(LocalFrame*);
144 // DEPRECATED: Use toScriptState.
145 static ScriptState* forWorld(LocalFrame*, DOMWrapperWorld&);
146
147 v8::Isolate* isolate() const { return m_isolate; } 138 v8::Isolate* isolate() const { return m_isolate; }
148 DOMWrapperWorld& world() const { return *m_world; } 139 DOMWrapperWorld& world() const { return *m_world; }
149 LocalDOMWindow* domWindow() const; 140 LocalDOMWindow* domWindow() const;
150 virtual ExecutionContext* getExecutionContext() const; 141 virtual ExecutionContext* getExecutionContext() const;
151 virtual void setExecutionContext(ExecutionContext*); 142 virtual void setExecutionContext(ExecutionContext*);
152 143
153 // This can return an empty handle if the v8::Context is gone. 144 // This can return an empty handle if the v8::Context is gone.
154 v8::Local<v8::Context> context() const { 145 v8::Local<v8::Context> context() const {
155 return m_context.newLocal(m_isolate); 146 return m_context.newLocal(m_isolate);
156 } 147 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 199 }
209 200
210 private: 201 private:
211 RefPtr<ScriptState> m_scriptState; 202 RefPtr<ScriptState> m_scriptState;
212 ScopedPersistent<v8::Context> m_context; 203 ScopedPersistent<v8::Context> m_context;
213 }; 204 };
214 205
215 } // namespace blink 206 } // namespace blink
216 207
217 #endif // ScriptState_h 208 #endif // ScriptState_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ScriptState.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698