| 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 #include "bindings/core/v8/ScriptState.h" | 5 #include "bindings/core/v8/ScriptState.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 #include "core/dom/ExecutionContext.h" | 8 #include "core/dom/ExecutionContext.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 11 #include "platform/TraceEvent.h" |
| 11 | 12 |
| 12 namespace blink { | 13 namespace blink { |
| 13 | 14 |
| 14 PassRefPtr<ScriptState> ScriptState::create(v8::Local<v8::Context> context, Pass
RefPtr<DOMWrapperWorld> world) | 15 PassRefPtr<ScriptState> ScriptState::create(v8::Local<v8::Context> context, Pass
RefPtr<DOMWrapperWorld> world) |
| 15 { | 16 { |
| 17 TRACE_EVENT0("v8", "ScriptState::create"); |
| 16 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); | 18 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); |
| 17 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. | 19 // This ref() is for keeping this ScriptState alive as long as the v8::Conte
xt is alive. |
| 18 // This is deref()ed in the weak callback of the v8::Context. | 20 // This is deref()ed in the weak callback of the v8::Context. |
| 19 scriptState->ref(); | 21 scriptState->ref(); |
| 20 return scriptState; | 22 return scriptState; |
| 21 } | 23 } |
| 22 | 24 |
| 23 static void derefCallback(const v8::WeakCallbackInfo<ScriptState>& data) | 25 static void derefCallback(const v8::WeakCallbackInfo<ScriptState>& data) |
| 24 { | 26 { |
| 25 data.GetParameter()->deref(); | 27 data.GetParameter()->deref(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 v8::HandleScope handleScope(toIsolate(frame)); | 104 v8::HandleScope handleScope(toIsolate(frame)); |
| 103 v8::Local<v8::Context> context = toV8Context(frame, world); | 105 v8::Local<v8::Context> context = toV8Context(frame, world); |
| 104 if (context.IsEmpty()) | 106 if (context.IsEmpty()) |
| 105 return nullptr; | 107 return nullptr; |
| 106 ScriptState* scriptState = ScriptState::from(context); | 108 ScriptState* scriptState = ScriptState::from(context); |
| 107 ASSERT(scriptState->contextIsValid()); | 109 ASSERT(scriptState->contextIsValid()); |
| 108 return scriptState; | 110 return scriptState; |
| 109 } | 111 } |
| 110 | 112 |
| 111 } // namespace blink | 113 } // namespace blink |
| OLD | NEW |