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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) |
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) |
| 61 { |
| 62 return from(info.Holder()->CreationContext()); |
| 63 } |
| 64 |
| 65 static ScriptState* forHolderObject(const v8::PropertyCallbackInfo<v8::Value
>& info) |
| 66 { |
| 67 return from(info.Holder()->CreationContext()); |
| 68 } |
| 69 |
60 // Debugger context doesn't have associated ScriptState and when current | 70 // Debugger context doesn't have associated ScriptState and when current |
61 // context is debugger it should be treated as if context stack was empty. | 71 // context is debugger it should be treated as if context stack was empty. |
62 static bool hasCurrentScriptState(v8::Isolate* isolate) | 72 static bool hasCurrentScriptState(v8::Isolate* isolate) |
63 { | 73 { |
64 v8::HandleScope scope(isolate); | 74 v8::HandleScope scope(isolate); |
65 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 75 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
66 if (context.IsEmpty()) | 76 if (context.IsEmpty()) |
67 return false; | 77 return false; |
68 return context != v8::Debug::GetDebugContext(isolate); | 78 return context != v8::Debug::GetDebugContext(isolate); |
69 } | 79 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 158 } |
149 | 159 |
150 private: | 160 private: |
151 RefPtr<ScriptState> m_scriptState; | 161 RefPtr<ScriptState> m_scriptState; |
152 ScopedPersistent<v8::Context> m_context; | 162 ScopedPersistent<v8::Context> m_context; |
153 }; | 163 }; |
154 | 164 |
155 } // namespace blink | 165 } // namespace blink |
156 | 166 |
157 #endif // ScriptState_h | 167 #endif // ScriptState_h |
OLD | NEW |