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

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

Issue 1622213002: DevTools: make InjectedScript heap-allocated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
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 #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 "core/inspector/v8/V8Debugger.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 {
16 RefPtr<ScriptState> scriptState = adoptRef(new ScriptState(context, world)); 17 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. 18 // 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. 19 // This is deref()ed in the weak callback of the v8::Context.
19 scriptState->ref(); 20 scriptState->ref();
20 return scriptState; 21 return scriptState;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 { 121 {
121 ASSERT_NOT_REACHED(); 122 ASSERT_NOT_REACHED();
122 } 123 }
123 124
124 LocalDOMWindow* ScriptState::domWindow() const 125 LocalDOMWindow* ScriptState::domWindow() const
125 { 126 {
126 v8::HandleScope scope(m_isolate); 127 v8::HandleScope scope(m_isolate);
127 return toLocalDOMWindow(toDOMWindow(context())); 128 return toLocalDOMWindow(toDOMWindow(context()));
128 } 129 }
129 130
131 int ScriptState::contextIdInDebugger()
132 {
133 v8::HandleScope scope(m_isolate);
134 return V8Debugger::contextId(m_context.newLocal(m_isolate));
135 }
136
130 ScriptState* ScriptState::forMainWorld(LocalFrame* frame) 137 ScriptState* ScriptState::forMainWorld(LocalFrame* frame)
131 { 138 {
132 return ScriptState::forWorld(frame, DOMWrapperWorld::mainWorld()); 139 return ScriptState::forWorld(frame, DOMWrapperWorld::mainWorld());
133 } 140 }
134 141
135 ScriptState* ScriptState::forWorld(LocalFrame* frame, DOMWrapperWorld& world) 142 ScriptState* ScriptState::forWorld(LocalFrame* frame, DOMWrapperWorld& world)
136 { 143 {
137 ASSERT(frame); 144 ASSERT(frame);
138 v8::HandleScope handleScope(toIsolate(frame)); 145 v8::HandleScope handleScope(toIsolate(frame));
139 v8::Local<v8::Context> context = toV8Context(frame, world); 146 v8::Local<v8::Context> context = toV8Context(frame, world);
140 if (context.IsEmpty()) 147 if (context.IsEmpty())
141 return nullptr; 148 return nullptr;
142 ScriptState* scriptState = ScriptState::from(context); 149 ScriptState* scriptState = ScriptState::from(context);
143 ASSERT(scriptState->contextIsValid()); 150 ASSERT(scriptState->contextIsValid());
144 return scriptState; 151 return scriptState;
145 } 152 }
146 153
147 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698