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

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

Issue 892693006: Revert of 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
« 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_pausedFrame(nullptr) 102 , m_pausedPage(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_pausedFrame); 115 visitor->trace(m_pausedPage);
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, LocalFram e* localFrameRoot) 121 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* pag e)
122 { 122 {
123 ASSERT(localFrameRoot == localFrameRoot->localFrameRoot()); 123 ScriptController& scriptController = page->deprecatedLocalMainFrame()->scrip t();
124
125 ScriptController& scriptController = localFrameRoot->script();
126 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript)) 124 if (!scriptController.canExecuteScripts(NotAboutToExecuteScript))
127 return; 125 return;
128 126
129 v8::HandleScope scope(m_isolate); 127 v8::HandleScope scope(m_isolate);
130 128
131 if (!m_listenersMap.size()) { 129 if (!m_listenersMap.size()) {
132 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));
133 ensureDebuggerScriptCompiled(); 131 ensureDebuggerScriptCompiled();
134 } 132 }
135 133
136 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); 134 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext();
137 v8::Context::Scope contextScope(debuggerContext); 135 v8::Context::Scope contextScope(debuggerContext);
138 136
139 v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate); 137 v8::Local<v8::Object> debuggerScript = m_debuggerScript.newLocal(m_isolate);
140 ASSERT(!debuggerScript->IsUndefined()); 138 ASSERT(!debuggerScript->IsUndefined());
141 m_listenersMap.set(localFrameRoot, listener); 139 m_listenersMap.set(page, listener);
142 140
143 WindowProxy* windowProxy = scriptController.existingWindowProxy(DOMWrapperWo rld::mainWorld()); 141 WindowProxy* windowProxy = scriptController.existingWindowProxy(DOMWrapperWo rld::mainWorld());
144 if (!windowProxy || !windowProxy->isContextInitialized()) 142 if (!windowProxy || !windowProxy->isContextInitialized())
145 return; 143 return;
146 v8::Local<v8::Context> context = windowProxy->context(); 144 v8::Local<v8::Context> context = windowProxy->context();
147 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")));
148 v8::Handle<v8::Value> argv[] = { V8PerContextDebugData::contextDebugData(con text) }; 146 v8::Handle<v8::Value> argv[] = { V8PerContextDebugData::contextDebugData(con text) };
149 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);
150 if (value.IsEmpty()) 148 if (value.IsEmpty())
151 return; 149 return;
152 ASSERT(!value->IsUndefined() && value->IsArray()); 150 ASSERT(!value->IsUndefined() && value->IsArray());
153 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value); 151 v8::Handle<v8::Array> scriptsArray = v8::Handle<v8::Array>::Cast(value);
154 for (unsigned i = 0; i < scriptsArray->Length(); ++i) 152 for (unsigned i = 0; i < scriptsArray->Length(); ++i)
155 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);
156 } 154 }
157 155
158 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, LocalF rame* localFrame) 156 void PageScriptDebugServer::removeListener(ScriptDebugListener* listener, Page* page)
159 { 157 {
160 if (!m_listenersMap.contains(localFrame)) 158 if (!m_listenersMap.contains(page))
161 return; 159 return;
162 160
163 if (m_pausedFrame == localFrame) 161 if (m_pausedPage == page)
164 continueProgram(); 162 continueProgram();
165 163
166 m_listenersMap.remove(localFrame); 164 m_listenersMap.remove(page);
167 165
168 if (m_listenersMap.isEmpty()) { 166 if (m_listenersMap.isEmpty()) {
169 discardDebuggerScript(); 167 discardDebuggerScript();
170 v8::Debug::SetDebugEventListener(0); 168 v8::Debug::SetDebugEventListener(0);
171 // FIXME: Remove all breakpoints set by the agent. 169 // FIXME: Remove all breakpoints set by the agent.
172 } 170 }
173 } 171 }
174 172
175 void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task) 173 void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task)
176 { 174 {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 InspectorInstrumentation::didEvaluateScript(cookie); 214 InspectorInstrumentation::didEvaluateScript(cookie);
217 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());
218 } 216 }
219 217
220 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handl e<v8::Context> context) 218 ScriptDebugListener* PageScriptDebugServer::getDebugListenerForContext(v8::Handl e<v8::Context> context)
221 { 219 {
222 v8::HandleScope scope(m_isolate); 220 v8::HandleScope scope(m_isolate);
223 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); 221 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
224 if (!frame) 222 if (!frame)
225 return 0; 223 return 0;
226 return m_listenersMap.get(frame->localFrameRoot()); 224 return m_listenersMap.get(frame->page());
227 } 225 }
228 226
229 void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> contex t) 227 void PageScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> contex t)
230 { 228 {
231 v8::HandleScope scope(m_isolate); 229 v8::HandleScope scope(m_isolate);
232 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context); 230 LocalFrame* frame = retrieveFrameWithGlobalObjectCheck(context);
233 m_pausedFrame = frame->localFrameRoot(); 231 m_pausedPage = frame->page();
234 232
235 // Wait for continue or step command. 233 // Wait for continue or step command.
236 m_clientMessageLoop->run(m_pausedFrame); 234 m_clientMessageLoop->run(m_pausedPage);
237 235
238 // The listener may have been removed in the nested loop. 236 // The listener may have been removed in the nested loop.
239 if (ScriptDebugListener* listener = m_listenersMap.get(m_pausedFrame)) 237 if (ScriptDebugListener* listener = m_listenersMap.get(m_pausedPage))
240 listener->didContinue(); 238 listener->didContinue();
241 239
242 m_pausedFrame = 0; 240 m_pausedPage = 0;
243 } 241 }
244 242
245 void PageScriptDebugServer::quitMessageLoopOnPause() 243 void PageScriptDebugServer::quitMessageLoopOnPause()
246 { 244 {
247 m_clientMessageLoop->quitNow(); 245 m_clientMessageLoop->quitNow();
248 } 246 }
249 247
250 void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetail s& eventDetails) 248 void PageScriptDebugServer::preprocessBeforeCompile(const v8::Debug::EventDetail s& eventDetails)
251 { 249 {
252 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
332 UseCounter::muteForInspector(); 330 UseCounter::muteForInspector();
333 } 331 }
334 332
335 void PageScriptDebugServer::unmuteWarningsAndDeprecations() 333 void PageScriptDebugServer::unmuteWarningsAndDeprecations()
336 { 334 {
337 FrameConsole::unmute(); 335 FrameConsole::unmute();
338 UseCounter::unmuteForInspector(); 336 UseCounter::unmuteForInspector();
339 } 337 }
340 338
341 } // namespace blink 339 } // 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