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

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: fixed assertion 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
« no previous file with comments | « Source/bindings/core/v8/PageScriptDebugServer.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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* localFrameRoot)
122 { 122 {
123 ScriptController& scriptController = page->deprecatedLocalMainFrame()->scrip t(); 123 ASSERT(localFrameRoot == localFrameRoot->localFrameRoot());
124
125 ScriptController& scriptController = localFrameRoot->script();
124 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) 126 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript))
125 return; 127 return;
126 128
127 v8::HandleScope scope(m_isolate); 129 v8::HandleScope scope(m_isolate);
128 130
129 if (!m_listenersMap.size()) { 131 if (!m_listenersMap.size()) {
130 v8::Debug::SetDebugEventListener(&PageScriptDebugServer::v8DebugEventCal lback, v8::External::New(m_isolate, this)); 132 v8::Debug::SetDebugEventListener(&PageScriptDebugServer::v8DebugEventCal lback, v8::External::New(m_isolate, this));
131 ensureDebuggerScriptCompiled(); 133 ensureDebuggerScriptCompiled();
132 } 134 }
133 135
134 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); 136 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
135 v8::Context::Scope contextScope(debuggerContext); 137 v8::Context::Scope contextScope(debuggerContext);
136 138
137 v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate); 139 v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate);
138 ASSERT(!debuggerScript->IsUndefined()); 140 ASSERT(!debuggerScript->IsUndefined());
139 m_listenersMap.set(page, listener); 141 m_listenersMap.set(localFrameRoot, listener);
140 142
141 WindowProxy* windowProxy = scriptController.existingWindowProxy(DOMWrapperWo rld::mainWorld()); 143 WindowProxy* windowProxy = scriptController.existingWindowProxy(DOMWrapperWo rld::mainWorld());
142 if (!windowProxy || !windowProxy->isContextInitialized()) 144 if (!windowProxy || !windowProxy->isContextInitialized())
143 return; 145 return;
144 v8::Local<v8::Context> context = windowProxy->context(); 146 v8::Local<v8::Context> context = windowProxy->context();
145 v8::Handle<v8::Function> getScriptsFunction = v8::Local<v8::Function>::Cast( debuggerScript->Get(v8AtomicString(m_isolate, "getScripts"))); 147 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) }; 148 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); 149 v8::Handle<v8::Value> value = V8ScriptRunner::callInternalFunction(getScript sFunction, debuggerScript, WTF_ARRAY_LENGTH(argv), argv, m_isolate);
148 if (value.IsEmpty()) 150 if (value.IsEmpty())
149 return; 151 return;
150 ASSERT(!value->IsUndefined() && value->IsArray()); 152 ASSERT(!value->IsUndefined() && value->IsArray());
151 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value); 153 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value);
152 for (unsigned i = 0; i < scriptsArray->Length(); ++i) 154 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); 155 dispatchDidParseSource(listener, v8::Handle<v8::Object>::Cast(scriptsArr ay->Get(v8::Integer::New(m_isolate, i))), CompileSuccess);
154 } 156 }
155 157
156 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page) 158 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, LocalF rame* localFrame)
157 { 159 {
158 if (!m_listenersMap.contains(page)) 160 if (!m_listenersMap.contains(localFrame))
159 return; 161 return;
160 162
161 if (m_pausedPage == page) 163 if (m_pausedFrame == localFrame)
162 continueProgram(); 164 continueProgram();
163 165
164 m_listenersMap.remove(page); 166 m_listenersMap.remove(localFrame);
165 167
166 if (m_listenersMap.isEmpty()) { 168 if (m_listenersMap.isEmpty()) {
167 discardDebuggerScript(); 169 discardDebuggerScript();
168 v8::Debug::SetDebugEventListener(0); 170 v8::Debug::SetDebugEventListener(0);
169 // FIXME: Remove all breakpoints set by the agent. 171 // FIXME: Remove all breakpoints set by the agent.
170 } 172 }
171 } 173 }
172 174
173 void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task) 175 void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task)
174 { 176 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 InspectorInstrumentation::didEvaluateScript(cookie); 216 InspectorInstrumentation::didEvaluateScript(cookie);
215 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data()); 217 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", "data", InspectorUpdateCountersEvent::data());
216 } 218 }
217 219
218 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handl e<v8::Context> context) 220 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handl e<v8::Context> context)
219 { 221 {
220 v8::HandleScope scope(m_isolate); 222 v8::HandleScope scope(m_isolate);
221 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); 223 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
222 if (!frame) 224 if (!frame)
223 return 0; 225 return 0;
224 return m_listenersMap.get(frame->page()); 226 return m_listenersMap.get(frame->localFrameRoot());
225 } 227 }
226 228
227 void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> contex t) 229 void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> contex t)
228 { 230 {
229 v8::HandleScope scope(m_isolate); 231 v8::HandleScope scope(m_isolate);
230 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); 232 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
231 m_pausedPage = frame->page(); 233 m_pausedFrame = frame->localFrameRoot();
232 234
233 // Wait for continue or step command. 235 // Wait for continue or step command.
234 m_clientMessageLoop->run(m_pausedPage); 236 m_clientMessageLoop->run(m_pausedFrame);
235 237
236 // The listener may have been removed in the nested loop. 238 // The listener may have been removed in the nested loop.
237 if (ScriptDebugListener* listener = m_listenersMap.get(m_pausedPage)) 239 if (ScriptDebugListener* listener = m_listenersMap.get(m_pausedFrame))
238 listener->didContinue(); 240 listener->didContinue();
239 241
240 m_pausedPage = 0; 242 m_pausedFrame = 0;
241 } 243 }
242 244
243 void PageScriptDebugServer::quitMessageLoopOnPause() 245 void PageScriptDebugServer::quitMessageLoopOnPause()
244 { 246 {
245 m_clientMessageLoop->quitNow(); 247 m_clientMessageLoop->quitNow();
246 } 248 }
247 249
248 void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetail s& eventDetails) 250 void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetail s& eventDetails)
249 { 251 {
250 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext(); 252 v8::Handle<v8::Context> eventContext = eventDetails.GetEventContext();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 UseCounter::muteForInspector(); 332 UseCounter::muteForInspector();
331 } 333 }
332 334
333 void PageScriptDebugServer::unmuteWarningsAndDeprecations() 335 void PageScriptDebugServer::unmuteWarningsAndDeprecations()
334 { 336 {
335 FrameConsole::unmute(); 337 FrameConsole::unmute();
336 UseCounter::unmuteForInspector(); 338 UseCounter::unmuteForInspector();
337 } 339 }
338 340
339 } // namespace blink 341 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/PageScriptDebugServer.h ('k') | Source/core/dom/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698