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

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

Issue 2199643003: binding: Uses the current context if attribute/method is static. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 4 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/templates/attributes.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 "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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 private: 47 private:
48 v8::HandleScope m_handleScope; 48 v8::HandleScope m_handleScope;
49 v8::Local<v8::Context> m_context; 49 v8::Local<v8::Context> m_context;
50 }; 50 };
51 51
52 static PassRefPtr<ScriptState> create(v8::Local<v8::Context>, PassRefPtr<DOM WrapperWorld>); 52 static PassRefPtr<ScriptState> create(v8::Local<v8::Context>, PassRefPtr<DOM WrapperWorld>);
53 virtual ~ScriptState(); 53 virtual ~ScriptState();
54 54
55 static ScriptState* current(v8::Isolate* isolate) 55 static ScriptState* current(v8::Isolate* isolate) // DEPRECATED
56 { 56 {
57 return from(isolate->GetCurrentContext()); 57 return from(isolate->GetCurrentContext());
58 } 58 }
59 59
60 static ScriptState* forHolderObject(const v8::FunctionCallbackInfo<v8::Value >& info) 60 static ScriptState* forFunctionObject(const v8::FunctionCallbackInfo<v8::Val ue>& info)
61 {
62 // We're assuming that the current context is not yet changed since
63 // the callback function has got called back.
64 // TODO(yukishiino): Once info.GetFunctionContext() gets implemented,
65 // we should use it instead.
66 return from(info.GetIsolate()->GetCurrentContext());
67 }
68
69 static ScriptState* forReceiverObject(const v8::FunctionCallbackInfo<v8::Val ue>& info)
61 { 70 {
62 return from(info.Holder()->CreationContext()); 71 return from(info.Holder()->CreationContext());
63 } 72 }
64 73
65 static ScriptState* forHolderObject(const v8::PropertyCallbackInfo<v8::Value >& info) 74 static ScriptState* forReceiverObject(const v8::PropertyCallbackInfo<v8::Val ue>& info)
66 { 75 {
67 return from(info.Holder()->CreationContext()); 76 return from(info.Holder()->CreationContext());
68 } 77 }
69 78
70 // Debugger context doesn't have associated ScriptState and when current 79 // Debugger context doesn't have associated ScriptState and when current
71 // context is debugger it should be treated as if context stack was empty. 80 // context is debugger it should be treated as if context stack was empty.
72 static bool hasCurrentScriptState(v8::Isolate* isolate) 81 static bool hasCurrentScriptState(v8::Isolate* isolate)
73 { 82 {
74 v8::HandleScope scope(isolate); 83 v8::HandleScope scope(isolate);
75 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 84 v8::Local<v8::Context> context = isolate->GetCurrentContext();
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 167 }
159 168
160 private: 169 private:
161 RefPtr<ScriptState> m_scriptState; 170 RefPtr<ScriptState> m_scriptState;
162 ScopedPersistent<v8::Context> m_context; 171 ScopedPersistent<v8::Context> m_context;
163 }; 172 };
164 173
165 } // namespace blink 174 } // namespace blink
166 175
167 #endif // ScriptState_h 176 #endif // ScriptState_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/templates/attributes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698