OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 if (!scriptStateWrapper.IsEmpty() && scriptStateWrapper->IsExternal()) | 76 if (!scriptStateWrapper.IsEmpty() && scriptStateWrapper->IsExternal()) |
77 return static_cast<ScriptState*>(v8::External::Cast(*scriptStateWrapper)
->Value()); | 77 return static_cast<ScriptState*>(v8::External::Cast(*scriptStateWrapper)
->Value()); |
78 | 78 |
79 ScriptState* scriptState = new ScriptState(context); | 79 ScriptState* scriptState = new ScriptState(context); |
80 innerGlobal->SetHiddenValue(V8HiddenPropertyName::scriptState(), v8::Externa
l::New(scriptState)); | 80 innerGlobal->SetHiddenValue(V8HiddenPropertyName::scriptState(), v8::Externa
l::New(scriptState)); |
81 return scriptState; | 81 return scriptState; |
82 } | 82 } |
83 | 83 |
84 ScriptState* ScriptState::current() | 84 ScriptState* ScriptState::current() |
85 { | 85 { |
86 v8::HandleScope handleScope; | 86 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
87 v8::Local<v8::Context> context = v8::Context::GetCurrent(); | 87 v8::HandleScope handleScope(isolate); |
| 88 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
88 ASSERT(!context.IsEmpty()); | 89 ASSERT(!context.IsEmpty()); |
89 return ScriptState::forContext(context); | 90 return ScriptState::forContext(context); |
90 } | 91 } |
91 | 92 |
92 void ScriptState::makeWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Cont
ext>* object, ScriptState* scriptState) | 93 void ScriptState::makeWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Cont
ext>* object, ScriptState* scriptState) |
93 { | 94 { |
94 delete scriptState; | 95 delete scriptState; |
95 } | 96 } |
96 | 97 |
97 bool ScriptState::evalEnabled() const | 98 bool ScriptState::evalEnabled() const |
98 { | 99 { |
99 v8::HandleScope handleScope(m_isolate); | 100 v8::HandleScope handleScope(m_isolate); |
100 return context()->IsCodeGenerationFromStringsAllowed(); | 101 return context()->IsCodeGenerationFromStringsAllowed(); |
101 } | 102 } |
102 | 103 |
103 void ScriptState::setEvalEnabled(bool enabled) | 104 void ScriptState::setEvalEnabled(bool enabled) |
104 { | 105 { |
105 v8::HandleScope handleScope(m_isolate); | 106 v8::HandleScope handleScope(m_isolate); |
106 return context()->AllowCodeGenerationFromStrings(enabled); | 107 return context()->AllowCodeGenerationFromStrings(enabled); |
107 } | 108 } |
108 | 109 |
109 ScriptState* mainWorldScriptState(Frame* frame) | 110 ScriptState* mainWorldScriptState(Frame* frame) |
110 { | 111 { |
111 v8::HandleScope handleScope; | 112 v8::HandleScope handleScope(frame->script()->isolate()); |
112 return ScriptState::forContext(frame->script()->mainWorldContext()); | 113 return ScriptState::forContext(frame->script()->mainWorldContext()); |
113 } | 114 } |
114 | 115 |
115 ScriptState* scriptStateFromWorkerGlobalScope(WorkerGlobalScope* workerGlobalSco
pe) | 116 ScriptState* scriptStateFromWorkerGlobalScope(WorkerGlobalScope* workerGlobalSco
pe) |
116 { | 117 { |
117 WorkerScriptController* script = workerGlobalScope->script(); | 118 WorkerScriptController* script = workerGlobalScope->script(); |
118 if (!script) | 119 if (!script) |
119 return 0; | 120 return 0; |
120 | 121 |
121 v8::HandleScope handleScope; | 122 v8::HandleScope handleScope(script->isolate()); |
122 return ScriptState::forContext(script->context()); | 123 return ScriptState::forContext(script->context()); |
123 } | 124 } |
124 | 125 |
125 } | 126 } |
OLD | NEW |