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

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

Issue 2811213002: Move ScriptState::GetExecutionContext (Part 6) (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 "platform/wtf/RefCounted.h" 13 #include "platform/wtf/RefCounted.h"
14 #include "v8/include/v8-debug.h" 14 #include "v8/include/v8-debug.h"
15 #include "v8/include/v8.h" 15 #include "v8/include/v8.h"
16 16
17 namespace blink { 17 namespace blink {
18 18
19 class DOMWrapperWorld; 19 class DOMWrapperWorld;
20 class ExecutionContext;
21 class ScriptValue; 20 class ScriptValue;
22 21
23 // ScriptState is an abstraction class that holds all information about script 22 // ScriptState is an abstraction class that holds all information about script
24 // exectuion (e.g., v8::Isolate, v8::Context, DOMWrapperWorld, ExecutionContext 23 // exectuion (e.g., v8::Isolate, v8::Context, DOMWrapperWorld, ExecutionContext
25 // etc). If you need any info about the script execution, you're expected to 24 // etc). If you need any info about the script execution, you're expected to
26 // pass around ScriptState in the code base. ScriptState is in a 1:1 25 // pass around ScriptState in the code base. ScriptState is in a 1:1
27 // relationship with v8::Context. 26 // relationship with v8::Context.
28 // 27 //
29 // When you need ScriptState, you can add [CallWith=ScriptState] to IDL files 28 // When you need ScriptState, you can add [CallWith=ScriptState] to IDL files
30 // and pass around ScriptState into a place where you need ScriptState. 29 // and pass around ScriptState into a place where you need ScriptState.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 kV8ContextPerContextDataIndex)); 128 kV8ContextPerContextDataIndex));
130 // ScriptState::from() must not be called for a context that does not have 129 // ScriptState::from() must not be called for a context that does not have
131 // valid embedder data in the embedder field. 130 // valid embedder data in the embedder field.
132 SECURITY_CHECK(script_state); 131 SECURITY_CHECK(script_state);
133 SECURITY_CHECK(script_state->GetContext() == context); 132 SECURITY_CHECK(script_state->GetContext() == context);
134 return script_state; 133 return script_state;
135 } 134 }
136 135
137 v8::Isolate* GetIsolate() const { return isolate_; } 136 v8::Isolate* GetIsolate() const { return isolate_; }
138 DOMWrapperWorld& World() const { return *world_; } 137 DOMWrapperWorld& World() const { return *world_; }
139 // DEPRECATED: Use ExecutionContext::From instead
140 virtual ExecutionContext* GetExecutionContext() const;
141 138
142 // This can return an empty handle if the v8::Context is gone. 139 // This can return an empty handle if the v8::Context is gone.
143 v8::Local<v8::Context> GetContext() const { 140 v8::Local<v8::Context> GetContext() const {
144 return context_.NewLocal(isolate_); 141 return context_.NewLocal(isolate_);
145 } 142 }
146 bool ContextIsValid() const { 143 bool ContextIsValid() const {
147 return !context_.IsEmpty() && per_context_data_; 144 return !context_.IsEmpty() && per_context_data_;
148 } 145 }
149 void DetachGlobalObject(); 146 void DetachGlobalObject();
150 void ClearContext() { return context_.Clear(); } 147 void ClearContext() { return context_.Clear(); }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 194 }
198 195
199 private: 196 private:
200 RefPtr<ScriptState> script_state_; 197 RefPtr<ScriptState> script_state_;
201 ScopedPersistent<v8::Context> context_; 198 ScopedPersistent<v8::Context> context_;
202 }; 199 };
203 200
204 } // namespace blink 201 } // namespace blink
205 202
206 #endif // ScriptState_h 203 #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