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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 v8::HandleScope handleScope(m_isolate); | 65 v8::HandleScope handleScope(m_isolate); |
66 return toScriptExecutionContext(m_context.newLocal(m_isolate)); | 66 return toScriptExecutionContext(m_context.newLocal(m_isolate)); |
67 } | 67 } |
68 | 68 |
69 ScriptState* ScriptState::forContext(v8::Handle<v8::Context> context) | 69 ScriptState* ScriptState::forContext(v8::Handle<v8::Context> context) |
70 { | 70 { |
71 v8::Context::Scope contextScope(context); | 71 v8::Context::Scope contextScope(context); |
72 | 72 |
73 v8::Local<v8::Object> innerGlobal = v8::Local<v8::Object>::Cast(context->Glo
bal()->GetPrototype()); | 73 v8::Local<v8::Object> innerGlobal = v8::Local<v8::Object>::Cast(context->Glo
bal()->GetPrototype()); |
74 | 74 |
75 v8::Local<v8::Value> scriptStateWrapper = innerGlobal->GetHiddenValue(V8Hidd
enPropertyName::scriptState()); | 75 v8::Local<v8::Value> scriptStateWrapper = innerGlobal->GetHiddenValue(V8Hidd
enPropertyName::scriptState(context->GetIsolate())); |
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(context->GetIs
olate()), v8::External::New(scriptState)); |
81 return scriptState; | 81 return scriptState; |
82 } | 82 } |
83 | 83 |
84 ScriptState* ScriptState::current() | 84 ScriptState* ScriptState::current() |
85 { | 85 { |
86 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 86 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
87 v8::HandleScope handleScope(isolate); | 87 v8::HandleScope handleScope(isolate); |
88 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 88 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
89 ASSERT(!context.IsEmpty()); | 89 ASSERT(!context.IsEmpty()); |
90 return ScriptState::forContext(context); | 90 return ScriptState::forContext(context); |
(...skipping 26 matching lines...) Expand all Loading... |
117 { | 117 { |
118 WorkerScriptController* script = workerGlobalScope->script(); | 118 WorkerScriptController* script = workerGlobalScope->script(); |
119 if (!script) | 119 if (!script) |
120 return 0; | 120 return 0; |
121 | 121 |
122 v8::HandleScope handleScope(script->isolate()); | 122 v8::HandleScope handleScope(script->isolate()); |
123 return ScriptState::forContext(script->context()); | 123 return ScriptState::forContext(script->context()); |
124 } | 124 } |
125 | 125 |
126 } | 126 } |
OLD | NEW |