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

Side by Side Diff: Source/bindings/core/v8/PageScriptDebugServer.cpp

Issue 898593002: DevTools: use per-LocalFrame instrumenting agents instead of per-Page ones. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 Google Inc. All rights reserved. 2 * Copyright (c) 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 v8::Isolate* PageScriptDebugServer::s_mainThreadIsolate = 0; 93 v8::Isolate* PageScriptDebugServer::s_mainThreadIsolate = 0;
94 94
95 void PageScriptDebugServer::setMainThreadIsolate(v8::Isolate* isolate) 95 void PageScriptDebugServer::setMainThreadIsolate(v8::Isolate* isolate)
96 { 96 {
97 s_mainThreadIsolate = isolate; 97 s_mainThreadIsolate = isolate;
98 } 98 }
99 99
100 PageScriptDebugServer::PageScriptDebugServer() 100 PageScriptDebugServer::PageScriptDebugServer()
101 : ScriptDebugServer(s_mainThreadIsolate) 101 : ScriptDebugServer(s_mainThreadIsolate)
102 , m_pausedPage(nullptr) 102 , m_pausedFrame(nullptr)
103 , m_preprocessorSourceCode() 103 , m_preprocessorSourceCode()
104 { 104 {
105 } 105 }
106 106
107 PageScriptDebugServer::~PageScriptDebugServer() 107 PageScriptDebugServer::~PageScriptDebugServer()
108 { 108 {
109 } 109 }
110 110
111 void PageScriptDebugServer::trace(Visitor* visitor) 111 void PageScriptDebugServer::trace(Visitor* visitor)
112 { 112 {
113 #if ENABLE(OILPAN) 113 #if ENABLE(OILPAN)
114 visitor->trace(m_listenersMap); 114 visitor->trace(m_listenersMap);
115 visitor->trace(m_pausedPage); 115 visitor->trace(m_pausedFrame);
116 visitor->trace(m_preprocessorSourceCode); 116 visitor->trace(m_preprocessorSourceCode);
117 #endif 117 #endif
118 ScriptDebugServer::trace(visitor); 118 ScriptDebugServer::trace(visitor);
119 } 119 }
120 120
121 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag e) 121 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, LocalFram e* localFrame)
yurys 2015/02/03 06:44:00 It'd be less ambiguous it were called localFrameRo
pfeldman 2015/02/03 07:09:16 Done.
122 { 122 {
123 ScriptController& scriptController = page->deprecatedLocalMainFrame()->scrip t(); 123 ScriptController& scriptController = localFrame->script();
124 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) 124 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript))
125 return; 125 return;
126 126
127 v8::HandleScope scope(m_isolate); 127 v8::HandleScope scope(m_isolate);
128 128
129 if (!m_listenersMap.size()) { 129 if (!m_listenersMap.size()) {
130 v8::Debug::SetDebugEventListener(&PageScriptDebugServer::v8DebugEventCal lback, v8::External::New(m_isolate, this)); 130 v8::Debug::SetDebugEventListener(&PageScriptDebugServer::v8DebugEventCal lback, v8::External::New(m_isolate, this));
131 ensureDebuggerScriptCompiled(); 131 ensureDebuggerScriptCompiled();
132 } 132 }
133 133
134 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); 134 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
135 v8::Context::Scope contextScope(debuggerContext); 135 v8::Context::Scope contextScope(debuggerContext);
136 136
137 v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate); 137 v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate);
138 ASSERT(!debuggerScript->IsUndefined()); 138 ASSERT(!debuggerScript->IsUndefined());
139 m_listenersMap.set(page, listener); 139 m_listenersMap.set(localFrame, listener);
140 140
141 WindowProxy* windowProxy = scriptController.existingWindowProxy(DOMWrapperWo rld::mainWorld()); 141 WindowProxy* windowProxy = scriptController.existingWindowProxy(DOMWrapperWo rld::mainWorld());
142 if (!windowProxy || !windowProxy->isContextInitialized()) 142 if (!windowProxy || !windowProxy->isContextInitialized())
143 return; 143 return;
144 v8::Local<v8::Context> context = windowProxy->context(); 144 v8::Local<v8::Context> context = windowProxy->context();
145 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast( debuggerScript->Get(v8AtomicString(m_isolate, "getScripts"))); 145 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast( debuggerScript->Get(v8AtomicString(m_isolate, "getScripts")));
146 v8::Handle<v8::Value> argv[] = { V8PerContextDebugData::contextDebugData(con text) }; 146 v8::Handle<v8::Value> argv[] = { V8PerContextDebugData::contextDebugData(con text) };
147 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScript sFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate); 147 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScript sFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate);
148 if (value.IsEmpty()) 148 if (value.IsEmpty())
149 return; 149 return;
150 ASSERT(!value->IsUndefined() && value->IsArray()); 150 ASSERT(!value->IsUndefined() && value->IsArray());
151 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value); 151 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value);
152 for (unsigned i = 0; i < scriptsArray->Length(); ++i) 152 for (unsigned i = 0; i < scriptsArray->Length(); ++i)
153 dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArr ay->Get(v8::Integer::New(m_isolate, i))), CompileSuccess); 153 dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArr ay->Get(v8::Integer::New(m_isolate, i))), CompileSuccess);
154 } 154 }
155 155
156 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page) 156 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, LocalF rame* localFrame)
157 { 157 {
158 if (!m_listenersMap.contains(page)) 158 if (!m_listenersMap.contains(localFrame))
159 return; 159 return;
160 160
161 if (m_pausedPage == page) 161 if (m_pausedFrame == localFrame)
162 continueProgram(); 162 continueProgram();
163 163
164 m_listenersMap.remove(page); 164 m_listenersMap.remove(localFrame);
165 165
166 if (m_listenersMap.isEmpty()) { 166 if (m_listenersMap.isEmpty()) {
167 discardDebuggerScript(); 167 discardDebuggerScript();
168 v8::Debug::SetDebugEventListener(0); 168 v8::Debug::SetDebugEventListener(0);
169 // FIXME: Remove all breakpoints set by the agent. 169 // FIXME: Remove all breakpoints set by the agent.
170 } 170 }
171 } 171 }
172 172
173 void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task) 173 void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task)
174 { 174 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 InspectorInstrumentation::didEvaluateScript(cookie); 214 InspectorInstrumentation::didEvaluateScript(cookie);
215 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data()); 215 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data());
216 } 216 }
217 217
218 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handl e<v8::Context> context) 218 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handl e<v8::Context> context)
219 { 219 {
220 v8::HandleScope scope(m_isolate); 220 v8::HandleScope scope(m_isolate);
221 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); 221 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
222 if (!frame) 222 if (!frame)
223 return 0; 223 return 0;
224 return m_listenersMap.get(frame->page()); 224 return m_listenersMap.get(frame->localFrameRoot());
225 } 225 }
226 226
227 void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> contex t) 227 void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> contex t)
228 { 228 {
229 v8::HandleScope scope(m_isolate); 229 v8::HandleScope scope(m_isolate);
230 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); 230 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
231 m_pausedPage = frame->page(); 231 m_pausedFrame = frame->localFrameRoot();
232 232
233 // Wait for continue or step command. 233 // Wait for continue or step command.
234 m_clientMessageLoop->run(m_pausedPage); 234 m_clientMessageLoop->run(m_pausedFrame);
235 235
236 // The listener may have been removed in the nested loop. 236 // The listener may have been removed in the nested loop.
237 if (ScriptDebugListener* listener = m_listenersMap.get(m_pausedPage)) 237 if (ScriptDebugListener* listener = m_listenersMap.get(m_pausedFrame))
238 listener->didContinue(); 238 listener->didContinue();
239 239
240 m_pausedPage = 0; 240 m_pausedFrame = 0;
241 } 241 }
242 242
243 void PageScriptDebugServer::quitMessageLoopOnPause() 243 void PageScriptDebugServer::quitMessageLoopOnPause()
244 { 244 {
245 m_clientMessageLoop->quitNow(); 245 m_clientMessageLoop->quitNow();
246 } 246 }
247 247
248 void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetail s& eventDetails) 248 void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetail s& eventDetails)
249 { 249 {
250 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); 250 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 UseCounter::muteForInspector(); 330 UseCounter::muteForInspector();
331 } 331 }
332 332
333 void PageScriptDebugServer::unmuteWarningsAndDeprecations() 333 void PageScriptDebugServer::unmuteWarningsAndDeprecations()
334 { 334 {
335 FrameConsole::unmute(); 335 FrameConsole::unmute();
336 UseCounter::unmuteForInspector(); 336 UseCounter::unmuteForInspector();
337 } 337 }
338 338
339 } // namespace blink 339 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698