Changeset 79858 in webkit
- Timestamp:
- Feb 28, 2011 6:49:33 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r79857 r79858 1 2011-02-28 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: debugger agents should have same livetime as InspectorAgent 6 https://bugs.webkit.org/show_bug.cgi?id=55369 7 8 * inspector/report-protocol-errors-expected.txt: 9 * inspector/report-protocol-errors.html: 10 1 11 2011-02-28 Pavel Feldman <pfeldman@chromium.org> 2 12 -
trunk/LayoutTests/inspector/report-protocol-errors-expected.txt
r74785 r79858 79 79 } 80 80 } 81 {82 seq : 683 domain : "Debugger"84 success : false85 errors : {86 0 : "Protocol Error: Debugger handler is not available."87 1 : "Protocol Error: Argument 'breakpointId' with type 'String' was not found."88 }89 }90 {91 seq : 792 domain : "Debugger"93 success : false94 errors : {95 0 : "Protocol Error: Debugger handler is not available."96 }97 }98 81 -
trunk/LayoutTests/inspector/report-protocol-errors.html
r78717 r79858 17 17 '{"seq":4,"command":"resourceContent","arguments":{}}', 18 18 '{"seq":5,"command":"resourceContent","arguments":{"identifier":"not a number"}}', 19 '{"seq":6,"command":"removeJavaScriptBreakpoint","arguments":{}}',20 '{"seq":7,"command":"removeJavaScriptBreakpoint","arguments":{"breakpointId":"someBreakpointId"}}',21 19 ]; 22 20 var numberOfReports = 0; … … 36 34 } 37 35 38 InspectorAgent.disableDebugger(fire);36 DebuggerAgent.disable(fire); 39 37 } 40 38 -
trunk/Source/WebCore/ChangeLog
r79856 r79858 1 2011-02-28 Yury Semikhatsky <yurys@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: debugger agents should have same livetime as InspectorAgent 6 https://bugs.webkit.org/show_bug.cgi?id=55369 7 8 DOM and JS debugger agents are now created in InspectorAgent's constructor and owned 9 by the agent. Debugger state is cleared on frontend disconnect. 10 11 * inspector/Inspector.idl: 12 * inspector/InspectorAgent.cpp: 13 (WebCore::InspectorAgent::InspectorAgent): 14 (WebCore::InspectorAgent::restoreInspectorStateFromCookie): 15 (WebCore::InspectorAgent::setFrontend): 16 (WebCore::InspectorAgent::disconnectFrontend): 17 (WebCore::InspectorAgent::populateScriptObjects): 18 (WebCore::InspectorAgent::didCommitLoad): 19 (WebCore::InspectorAgent::showScriptsPanel): 20 * inspector/InspectorAgent.h: 21 * inspector/InspectorBrowserDebuggerAgent.cpp: 22 (WebCore::InspectorBrowserDebuggerAgent::create): 23 (WebCore::InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent): 24 (WebCore::InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent): 25 (WebCore::InspectorBrowserDebuggerAgent::debuggerWasEnabled): 26 (WebCore::InspectorBrowserDebuggerAgent::debuggerWasDisabled): 27 (WebCore::InspectorBrowserDebuggerAgent::disable): 28 (WebCore::InspectorBrowserDebuggerAgent::setFrontend): 29 (WebCore::InspectorBrowserDebuggerAgent::clearFrontend): 30 (WebCore::InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints): 31 (WebCore::InspectorBrowserDebuggerAgent::inspectedURLChanged): 32 (WebCore::InspectorBrowserDebuggerAgent::setDOMBreakpoint): 33 (WebCore::InspectorBrowserDebuggerAgent::removeDOMBreakpoint): 34 (WebCore::InspectorBrowserDebuggerAgent::willInsertDOMNode): 35 (WebCore::InspectorBrowserDebuggerAgent::willRemoveDOMNode): 36 (WebCore::InspectorBrowserDebuggerAgent::willModifyDOMAttr): 37 (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent): 38 (WebCore::InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded): 39 (WebCore::InspectorBrowserDebuggerAgent::willSendXMLHttpRequest): 40 (WebCore::InspectorBrowserDebuggerAgent::clear): 41 * inspector/InspectorBrowserDebuggerAgent.h: 42 * inspector/InspectorController.cpp: 43 (WebCore::InspectorController::debuggerEnabled): 44 (WebCore::InspectorController::showAndEnableDebugger): 45 (WebCore::InspectorController::disableDebugger): 46 * inspector/InspectorDebuggerAgent.cpp: 47 (WebCore::InspectorDebuggerAgent::create): 48 (WebCore::InspectorDebuggerAgent::InspectorDebuggerAgent): 49 (WebCore::InspectorDebuggerAgent::~InspectorDebuggerAgent): 50 (WebCore::InspectorDebuggerAgent::startUserInitiatedDebugging): 51 (WebCore::InspectorDebuggerAgent::enable): 52 (WebCore::InspectorDebuggerAgent::disable): 53 (WebCore::InspectorDebuggerAgent::enabled): 54 (WebCore::InspectorDebuggerAgent::restore): 55 (WebCore::InspectorDebuggerAgent::setFrontend): 56 (WebCore::InspectorDebuggerAgent::clearFrontend): 57 (WebCore::InspectorDebuggerAgent::setJavaScriptBreakpoint): 58 (WebCore::InspectorDebuggerAgent::removeJavaScriptBreakpoint): 59 (WebCore::InspectorDebuggerAgent::evaluateOnCallFrame): 60 (WebCore::InspectorDebuggerAgent::getCompletionsOnCallFrame): 61 (WebCore::InspectorDebuggerAgent::currentCallFrames): 62 (WebCore::InspectorDebuggerAgent::didParseSource): 63 (WebCore::InspectorDebuggerAgent::clear): 64 * inspector/InspectorDebuggerAgent.h: 65 (WebCore::InspectorDebuggerAgent::enable): 66 (WebCore::InspectorDebuggerAgent::disable): 67 (WebCore::InspectorDebuggerAgent::Listener::~Listener): 68 (WebCore::InspectorDebuggerAgent::setListener): 69 * inspector/InspectorInstrumentation.cpp: 70 (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl): 71 (WebCore::InspectorInstrumentation::didInsertDOMNodeImpl): 72 (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl): 73 (WebCore::InspectorInstrumentation::didRemoveDOMNodeImpl): 74 (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl): 75 (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl): 76 (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded): 77 * inspector/front-end/DebuggerModel.js: 78 (WebInspector.DebuggerModel.prototype.enableDebugger): 79 (WebInspector.DebuggerModel.prototype.disableDebugger): 80 1 81 2011-02-28 Renata Hodovan <reni@webkit.org> 2 82 -
trunk/Source/WebCore/inspector/Inspector.idl
r79583 r79858 66 66 // FIXME: dispatch on agents. 67 67 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER 68 void enableDebugger();69 void disableDebugger();70 68 void enableProfiler(); 71 69 void disableProfiler(); … … 202 200 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER 203 201 interface [Conditional=INSPECTOR] Debugger { 202 void enable(); 203 void disable(); 204 204 [event] void debuggerWasEnabled(); 205 205 [event] void debuggerWasDisabled(); -
trunk/Source/WebCore/inspector/InspectorAgent.cpp
r79850 r79858 151 151 , m_consoleAgent(new InspectorConsoleAgent(m_instrumentingAgents.get(), this, m_state.get(), m_injectedScriptHost.get(), m_domAgent.get())) 152 152 #if ENABLE(JAVASCRIPT_DEBUGGER) 153 , m_debuggerAgent(InspectorDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptHost.get())) 154 , m_browserDebuggerAgent(InspectorBrowserDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), m_domAgent.get(), m_debuggerAgent.get(), this)) 153 155 , m_profilerAgent(InspectorProfilerAgent::create(this)) 154 156 #endif … … 208 210 209 211 #if ENABLE(JAVASCRIPT_DEBUGGER) 210 restoreDebugger(false);212 m_debuggerAgent->restore(); 211 213 restoreProfiler(ProfilerRestoreResetAgent); 212 214 if (m_state->getBoolean(InspectorAgentState::userInitiatedProfiling)) … … 364 366 m_consoleAgent->setFrontend(m_frontend); 365 367 m_timelineAgent->setFrontend(m_frontend); 368 #if ENABLE(JAVASCRIPT_DEBUGGER) 369 m_debuggerAgent->setFrontend(m_frontend); 370 m_browserDebuggerAgent->setFrontend(m_frontend); 371 #endif 366 372 #if ENABLE(DATABASE) 367 373 m_databaseAgent->setFrontend(m_frontend); … … 387 393 ErrorString error; 388 394 #if ENABLE(JAVASCRIPT_DEBUGGER) 389 // If the window is being closed with the debugger enabled, 390 // remember this state to re-enable debugger on the next window 391 // opening. 392 disableDebugger(&error); 395 m_debuggerAgent->clearFrontend(); 396 m_browserDebuggerAgent->clearFrontend(); 393 397 #endif 394 398 setSearchingForNode(false); … … 461 465 } 462 466 463 restoreDebugger(true);464 467 restoreProfiler(ProfilerRestoreNoAction); 465 468 … … 480 483 m_frontend->didCreateWorker(worker->id(), worker->url(), worker->isSharedWorker()); 481 484 } 482 #endif483 }484 485 void InspectorAgent::restoreDebugger(bool eraseStickyBreakpoints)486 {487 ASSERT(m_frontend);488 #if ENABLE(JAVASCRIPT_DEBUGGER)489 if (m_state->getBoolean(InspectorAgentState::debuggerEnabled))490 enableDebugger(eraseStickyBreakpoints);491 485 #endif 492 486 } … … 532 526 533 527 #if ENABLE(JAVASCRIPT_DEBUGGER) 534 if ( m_debuggerAgent) {528 if (InspectorDebuggerAgent* debuggerAgent = m_instrumentingAgents->inspectorDebuggerAgent()) { 535 529 KURL url = inspectedURLWithoutFragment(); 536 m_debuggerAgent->inspectedURLChanged(url);537 if ( m_browserDebuggerAgent)538 m_browserDebuggerAgent->inspectedURLChanged(url);530 debuggerAgent->inspectedURLChanged(url); 531 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = m_instrumentingAgents->inspectorBrowserDebuggerAgent()) 532 browserDebuggerAgent->inspectedURLChanged(url); 539 533 } 540 534 #endif … … 836 830 837 831 #if ENABLE(JAVASCRIPT_DEBUGGER) 838 void InspectorAgent::startUserInitiatedDebugging() 839 { 840 if (debuggerEnabled()) 841 return; 842 832 void InspectorAgent::showScriptsPanel() 833 { 843 834 showPanel(scriptsPanelName); 844 if (!m_frontend) {845 // We are called after show(), set the debuggerEnabled flag so that it was enabled846 // upon frontend opening.847 m_state->setBoolean(InspectorAgentState::debuggerEnabled, true);848 } else849 enableDebugger(true);850 }851 852 void InspectorAgent::enableDebugger(bool eraseStickyBreakpoints)853 {854 if (debuggerEnabled())855 return;856 m_state->setBoolean(InspectorAgentState::debuggerEnabled, true);857 ASSERT(m_inspectedPage);858 859 m_debuggerAgent = InspectorDebuggerAgent::create(this, m_frontend, eraseStickyBreakpoints);860 m_browserDebuggerAgent = InspectorBrowserDebuggerAgent::create(this, eraseStickyBreakpoints);861 862 m_frontend->debuggerWasEnabled();863 }864 865 void InspectorAgent::disableDebugger(ErrorString*)866 {867 if (!enabled())868 return;869 ASSERT(m_inspectedPage);870 m_debuggerAgent.clear();871 m_browserDebuggerAgent.clear();872 873 if (m_frontend) {874 m_frontend->debuggerWasDisabled();875 m_state->setBoolean(InspectorAgentState::debuggerEnabled, false);876 }877 835 } 878 836 #endif -
trunk/Source/WebCore/inspector/InspectorAgent.h
r79850 r79858 207 207 bool profilerEnabled() const; 208 208 209 void startUserInitiatedDebugging(); 210 void enableDebugger(ErrorString*) { enableDebugger(false); } 211 void enableDebugger(bool eraseStickyBreakpoints); 212 void disableDebugger(ErrorString* error); 213 bool debuggerEnabled() const { return m_debuggerAgent; } 209 void showScriptsPanel(); 214 210 #endif 215 211 … … 237 233 void showPanel(const String& panel); 238 234 void pushDataCollectedOffline(); 239 void restoreDebugger(bool eraseStickyBreakpoints);240 235 enum ProfilerRestoreAction { 241 236 ProfilerRestoreNoAction = 0, -
trunk/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp
r79539 r79858 36 36 37 37 #include "HTMLElement.h" 38 #include "InspectorAgent.h"39 38 #include "InspectorDOMAgent.h" 40 39 #include "InspectorDebuggerAgent.h" 41 40 #include "InspectorState.h" 42 41 #include "InspectorValues.h" 42 #include "InstrumentingAgents.h" 43 43 #include <wtf/text/CString.h> 44 44 … … 67 67 } 68 68 69 PassOwnPtr<InspectorBrowserDebuggerAgent> InspectorBrowserDebuggerAgent::create(InspectorAgent* inspectorAgent, bool eraseStickyBreakpoints) 70 { 71 return adoptPtr(new InspectorBrowserDebuggerAgent(inspectorAgent, eraseStickyBreakpoints)); 72 } 73 74 InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent(InspectorAgent* inspectorAgent, bool eraseStickyBreakpoints) 75 : m_inspectorAgent(inspectorAgent) 69 PassOwnPtr<InspectorBrowserDebuggerAgent> InspectorBrowserDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InspectorDOMAgent* domAgent, InspectorDebuggerAgent* debuggerAgent, InspectorAgent* inspectorAgent) 70 { 71 return adoptPtr(new InspectorBrowserDebuggerAgent(instrumentingAgents, inspectorState, domAgent, debuggerAgent, inspectorAgent)); 72 } 73 74 InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InspectorDOMAgent* domAgent, InspectorDebuggerAgent* debuggerAgent, InspectorAgent* inspectorAgent) 75 : m_instrumentingAgents(instrumentingAgents) 76 , m_inspectorState(inspectorState) 77 , m_domAgent(domAgent) 78 , m_debuggerAgent(debuggerAgent) 79 , m_inspectorAgent(inspectorAgent) 76 80 , m_hasXHRBreakpointWithEmptyURL(false) 77 81 { 78 if (eraseStickyBreakpoints) 79 inspectorAgent->state()->setObject(BrowserDebuggerAgentState::browserBreakpoints, InspectorObject::create()); 82 m_debuggerAgent->setListener(this); 80 83 } 81 84 82 85 InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent() 83 86 { 87 m_debuggerAgent->setListener(0); 88 clearFrontend(); 89 } 90 91 // Browser debugger agent enabled only when JS debugger is enabled. 92 void InspectorBrowserDebuggerAgent::debuggerWasEnabled() 93 { 94 m_instrumentingAgents->setInspectorBrowserDebuggerAgent(this); 95 } 96 97 void InspectorBrowserDebuggerAgent::debuggerWasDisabled() 98 { 99 disable(); 100 } 101 102 void InspectorBrowserDebuggerAgent::disable() 103 { 104 m_instrumentingAgents->setInspectorBrowserDebuggerAgent(0); 105 clear(); 106 } 107 108 void InspectorBrowserDebuggerAgent::setFrontend(InspectorFrontend*) 109 { 110 // Erase sticky breakpoints. If we are restoring from a cookie setFrontend msut be called 111 // before the state is loaded from the cookie. 112 m_inspectorState->setObject(BrowserDebuggerAgentState::browserBreakpoints, InspectorObject::create()); 113 } 114 115 void InspectorBrowserDebuggerAgent::clearFrontend() 116 { 117 disable(); 84 118 } 85 119 86 120 void InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints(ErrorString*, PassRefPtr<InspectorObject> breakpoints) 87 121 { 88 m_inspectorAgent->state()->setObject(BrowserDebuggerAgentState::browserBreakpoints, breakpoints); 122 m_inspectorState->setObject(BrowserDebuggerAgentState::browserBreakpoints, breakpoints); 123 // FIXME: remove this call to inspector agent and dependency on the inspector agent. 89 124 inspectedURLChanged(m_inspectorAgent->inspectedURLWithoutFragment()); 90 125 } … … 92 127 void InspectorBrowserDebuggerAgent::inspectedURLChanged(const String& url) 93 128 { 129 ASSERT(m_instrumentingAgents->inspectorBrowserDebuggerAgent()); 94 130 m_eventListenerBreakpoints.clear(); 95 131 m_XHRBreakpoints.clear(); 96 132 m_hasXHRBreakpointWithEmptyURL = false; 97 133 98 RefPtr<InspectorObject> allBreakpoints = m_inspector Agent->state()->getObject(BrowserDebuggerAgentState::browserBreakpoints);134 RefPtr<InspectorObject> allBreakpoints = m_inspectorState->getObject(BrowserDebuggerAgentState::browserBreakpoints); 99 135 RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(url); 100 136 if (!breakpoints) … … 181 217 void InspectorBrowserDebuggerAgent::setDOMBreakpoint(ErrorString*, long nodeId, long type) 182 218 { 183 Node* node = m_ inspectorAgent->domAgent()->nodeForId(nodeId);219 Node* node = m_domAgent->nodeForId(nodeId); 184 220 if (!node) 185 221 return; … … 195 231 void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(ErrorString*, long nodeId, long type) 196 232 { 197 Node* node = m_ inspectorAgent->domAgent()->nodeForId(nodeId);233 Node* node = m_domAgent->nodeForId(nodeId); 198 234 if (!node) 199 235 return; … … 214 250 void InspectorBrowserDebuggerAgent::willInsertDOMNode(Node*, Node* parent) 215 251 { 216 InspectorDebuggerAgent* debuggerAgent = m_ inspectorAgent->debuggerAgent();252 InspectorDebuggerAgent* debuggerAgent = m_debuggerAgent; 217 253 if (!debuggerAgent) 218 254 return; … … 228 264 void InspectorBrowserDebuggerAgent::willRemoveDOMNode(Node* node) 229 265 { 230 InspectorDebuggerAgent* debuggerAgent = m_ inspectorAgent->debuggerAgent();266 InspectorDebuggerAgent* debuggerAgent = m_debuggerAgent; 231 267 if (!debuggerAgent) 232 268 return; … … 247 283 void InspectorBrowserDebuggerAgent::willModifyDOMAttr(Element* element) 248 284 { 249 InspectorDebuggerAgent* debuggerAgent = m_ inspectorAgent->debuggerAgent();285 InspectorDebuggerAgent* debuggerAgent = m_debuggerAgent; 250 286 if (!debuggerAgent) 251 287 return; … … 267 303 // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint. 268 304 // Target node may be unknown to frontend, so we need to push it first. 269 long targetNodeId = m_ inspectorAgent->domAgent()->pushNodePathToFrontend(target);305 long targetNodeId = m_domAgent->pushNodePathToFrontend(target); 270 306 ASSERT(targetNodeId); 271 307 description->setNumber("targetNodeId", targetNodeId); … … 284 320 } 285 321 286 long breakpointOwnerNodeId = m_ inspectorAgent->domAgent()->pushNodePathToFrontend(breakpointOwner);322 long breakpointOwnerNodeId = m_domAgent->pushNodePathToFrontend(breakpointOwner); 287 323 ASSERT(breakpointOwnerNodeId); 288 324 description->setNumber("nodeId", breakpointOwnerNodeId); … … 317 353 void InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous) 318 354 { 319 InspectorDebuggerAgent* debuggerAgent = m_ inspectorAgent->debuggerAgent();355 InspectorDebuggerAgent* debuggerAgent = m_debuggerAgent; 320 356 if (!debuggerAgent) 321 357 return; … … 352 388 void InspectorBrowserDebuggerAgent::willSendXMLHttpRequest(const String& url) 353 389 { 354 InspectorDebuggerAgent* debuggerAgent = m_ inspectorAgent->debuggerAgent();390 InspectorDebuggerAgent* debuggerAgent = m_debuggerAgent; 355 391 if (!debuggerAgent) 356 392 return; … … 378 414 } 379 415 416 void InspectorBrowserDebuggerAgent::clear() 417 { 418 m_domBreakpoints.clear(); 419 m_eventListenerBreakpoints.clear(); 420 m_XHRBreakpoints.clear(); 421 m_hasXHRBreakpointWithEmptyURL = false; 422 } 423 380 424 } // namespace WebCore 381 425 -
trunk/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h
r79539 r79858 34 34 #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) 35 35 36 #include "InspectorDebuggerAgent.h" 36 37 #include "PlatformString.h" 37 38 38 #include <wtf/HashMap.h> 39 39 #include <wtf/HashSet.h> … … 46 46 class Element; 47 47 class InspectorAgent; 48 class InspectorDOMAgent; 49 class InspectorDebuggerAgent; 50 class InspectorFrontend; 48 51 class InspectorObject; 52 class InspectorState; 53 class InstrumentingAgents; 49 54 class Node; 50 55 51 56 typedef String ErrorString; 52 57 53 class InspectorBrowserDebuggerAgent {58 class InspectorBrowserDebuggerAgent : public InspectorDebuggerAgent::Listener { 54 59 WTF_MAKE_NONCOPYABLE(InspectorBrowserDebuggerAgent); 55 60 public: 56 static PassOwnPtr<InspectorBrowserDebuggerAgent> create(Ins pectorAgent*, bool eraseStickyBreakpoints);61 static PassOwnPtr<InspectorBrowserDebuggerAgent> create(InstrumentingAgents*, InspectorState*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*); 57 62 58 63 virtual ~InspectorBrowserDebuggerAgent(); 64 65 void setFrontend(InspectorFrontend*); 66 void clearFrontend(); 59 67 60 68 void setAllBrowserBreakpoints(ErrorString* error, PassRefPtr<InspectorObject>); … … 79 87 80 88 private: 81 InspectorBrowserDebuggerAgent(InspectorAgent*, bool eraseStickyBreakpoints); 89 InspectorBrowserDebuggerAgent(InstrumentingAgents*, InspectorState*, InspectorDOMAgent*, InspectorDebuggerAgent*, InspectorAgent*); 90 91 // InspectorDebuggerAgent::Listener implementation. 92 virtual void debuggerWasEnabled(); 93 virtual void debuggerWasDisabled(); 94 void disable(); 82 95 83 96 void restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint); … … 88 101 void discardBindings(); 89 102 103 void clear(); 104 105 InstrumentingAgents* m_instrumentingAgents; 106 InspectorState* m_inspectorState; 107 InspectorDOMAgent* m_domAgent; 108 InspectorDebuggerAgent* m_debuggerAgent; 90 109 InspectorAgent* m_inspectorAgent; 91 110 HashMap<Node*, uint32_t> m_domBreakpoints; -
trunk/Source/WebCore/inspector/InspectorController.cpp
r79539 r79858 39 39 #include "InspectorAgent.h" 40 40 #include "InspectorBackendDispatcher.h" 41 #include "InspectorBrowserDebuggerAgent.h" 41 42 #include "InspectorDebuggerAgent.h" 42 43 #include "InspectorClient.h" … … 232 233 bool InspectorController::debuggerEnabled() 233 234 { 234 return m_inspectorAgent->debugger Enabled();235 return m_inspectorAgent->debuggerAgent()->enabled(); 235 236 } 236 237 … … 240 241 return; 241 242 show(); 242 m_inspectorAgent->startUserInitiatedDebugging(); 243 m_inspectorAgent->showScriptsPanel(); 244 m_inspectorAgent->debuggerAgent()->startUserInitiatedDebugging(); 243 245 } 244 246 245 247 void InspectorController::disableDebugger() 246 248 { 247 ErrorString error; 248 m_inspectorAgent->disableDebugger(&error); 249 m_inspectorAgent->debuggerAgent()->disable(); 249 250 } 250 251 -
trunk/Source/WebCore/inspector/InspectorDebuggerAgent.cpp
r79539 r79858 37 37 #include "InspectorState.h" 38 38 #include "InspectorValues.h" 39 #include "InstrumentingAgents.h" 39 40 #include "PlatformString.h" 40 41 #include "ScriptDebugServer.h" … … 44 45 45 46 namespace DebuggerAgentState { 47 static const char debuggerEnabled[] = "debuggerEnabled"; 48 static const char enableWhenShown[] = "debuggerEnableWhenShown"; 46 49 static const char javaScriptBreakpoints[] = "javaScriptBreakopints"; 47 50 }; 48 51 49 PassOwnPtr<InspectorDebuggerAgent> InspectorDebuggerAgent::create(InspectorAgent* inspectorAgent, InspectorFrontend* frontend, bool eraseStickyBreakpoints) 50 { 51 OwnPtr<InspectorDebuggerAgent> agent = adoptPtr(new InspectorDebuggerAgent(inspectorAgent, frontend, eraseStickyBreakpoints)); 52 PassOwnPtr<InspectorDebuggerAgent> InspectorDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptHost* injectedScriptHost) 53 { 54 return adoptPtr(new InspectorDebuggerAgent(instrumentingAgents, inspectorState, inspectedPage, injectedScriptHost)); 55 } 56 57 InspectorDebuggerAgent::InspectorDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptHost* injectedScriptHost) 58 : m_instrumentingAgents(instrumentingAgents) 59 , m_inspectorState(inspectorState) 60 , m_inspectedPage(inspectedPage) 61 , m_injectedScriptHost(injectedScriptHost) 62 , m_frontend(0) 63 , m_pausedScriptState(0) 64 , m_javaScriptPauseScheduled(false) 65 , m_listener(0) 66 { 67 } 68 69 InspectorDebuggerAgent::~InspectorDebuggerAgent() 70 { 71 ScriptDebugServer::shared().removeListener(this, m_inspectedPage); 72 m_pausedScriptState = 0; 73 } 74 75 void InspectorDebuggerAgent::startUserInitiatedDebugging() 76 { 77 if (m_frontend) 78 enable(false); 79 else 80 m_inspectorState->setBoolean(DebuggerAgentState::enableWhenShown, true); 81 } 82 83 void InspectorDebuggerAgent::enable(bool restoringFromState) 84 { 85 ASSERT(m_frontend); 86 if (!restoringFromState && enabled()) 87 return; 88 m_inspectorState->setBoolean(DebuggerAgentState::debuggerEnabled, true); 89 m_instrumentingAgents->setInspectorDebuggerAgent(this); 90 52 91 ScriptDebugServer::shared().clearBreakpoints(); 53 92 // FIXME(WK44513): breakpoints activated flag should be synchronized between all front-ends 54 93 ScriptDebugServer::shared().setBreakpointsActivated(true); 55 ScriptDebugServer::shared().addListener(agent.get(), inspectorAgent->inspectedPage()); 56 return agent.release(); 57 } 58 59 InspectorDebuggerAgent::InspectorDebuggerAgent(InspectorAgent* inspectorAgent, InspectorFrontend* frontend, bool eraseStickyBreakpoints) 60 : m_inspectorAgent(inspectorAgent) 61 , m_frontend(frontend) 62 , m_pausedScriptState(0) 63 , m_javaScriptPauseScheduled(false) 64 { 65 if (eraseStickyBreakpoints) 66 inspectorAgent->state()->setObject(DebuggerAgentState::javaScriptBreakpoints, InspectorObject::create()); 67 } 68 69 InspectorDebuggerAgent::~InspectorDebuggerAgent() 70 { 71 ScriptDebugServer::shared().removeListener(this, m_inspectorAgent->inspectedPage()); 72 m_pausedScriptState = 0; 94 ScriptDebugServer::shared().addListener(this, m_inspectedPage); 95 96 m_frontend->debuggerWasEnabled(); 97 if (m_listener) 98 m_listener->debuggerWasEnabled(); 99 } 100 101 void InspectorDebuggerAgent::disable() 102 { 103 if (!enabled()) 104 return; 105 m_inspectorState->setBoolean(DebuggerAgentState::debuggerEnabled, false); 106 m_instrumentingAgents->setInspectorDebuggerAgent(0); 107 108 ScriptDebugServer::shared().removeListener(this, m_inspectedPage); 109 clear(); 110 111 if (m_frontend) 112 m_frontend->debuggerWasDisabled(); 113 if (m_listener) 114 m_listener->debuggerWasDisabled(); 115 } 116 117 bool InspectorDebuggerAgent::enabled() 118 { 119 return m_inspectorState->getBoolean(DebuggerAgentState::debuggerEnabled); 120 } 121 122 void InspectorDebuggerAgent::restore() 123 { 124 if (m_inspectorState->getBoolean(DebuggerAgentState::debuggerEnabled)) 125 enable(true); 126 } 127 128 void InspectorDebuggerAgent::setFrontend(InspectorFrontend* frontend) 129 { 130 m_frontend = frontend; 131 // Erase sticky breakpoints. If we are restoring from a cookie setFrontend msut be called 132 // before the state is loaded from the cookie. 133 m_inspectorState->setObject(DebuggerAgentState::javaScriptBreakpoints, InspectorObject::create()); 134 if (m_inspectorState->getBoolean(DebuggerAgentState::enableWhenShown)) { 135 m_inspectorState->setBoolean(DebuggerAgentState::enableWhenShown, false); 136 enable(false); 137 } 138 } 139 140 void InspectorDebuggerAgent::clearFrontend() 141 { 142 m_frontend = 0; 143 144 if (!enabled()) 145 return; 146 // If the window is being closed with the debugger enabled, 147 // remember this state to re-enable debugger on the next window 148 // opening. 149 disable(); 150 m_inspectorState->setBoolean(DebuggerAgentState::enableWhenShown, true); 73 151 } 74 152 … … 92 170 { 93 171 String breakpointId = makeString(url, ":", String::number(lineNumber), ":", String::number(columnNumber)); 94 RefPtr<InspectorObject> breakpointsCookie = m_inspector Agent->state()->getObject(DebuggerAgentState::javaScriptBreakpoints);172 RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::javaScriptBreakpoints); 95 173 if (breakpointsCookie->find(breakpointId) != breakpointsCookie->end()) 96 174 return; … … 102 180 breakpointObject->setBoolean("enabled", enabled); 103 181 breakpointsCookie->setObject(breakpointId, breakpointObject); 104 m_inspector Agent->state()->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie);182 m_inspectorState->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie); 105 183 106 184 ScriptBreakpoint breakpoint(lineNumber, columnNumber, condition, enabled); … … 133 211 void InspectorDebuggerAgent::removeJavaScriptBreakpoint(ErrorString*, const String& breakpointId) 134 212 { 135 RefPtr<InspectorObject> breakpointsCookie = m_inspector Agent->state()->getObject(DebuggerAgentState::javaScriptBreakpoints);213 RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::javaScriptBreakpoints); 136 214 breakpointsCookie->remove(breakpointId); 137 m_inspector Agent->state()->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie);215 m_inspectorState->setObject(DebuggerAgentState::javaScriptBreakpoints, breakpointsCookie); 138 216 139 217 BreakpointIdToDebugServerBreakpointIdsMap::iterator debugServerBreakpointIdsIterator = m_breakpointIdToDebugServerBreakpointIds.find(breakpointId); … … 249 327 void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString*, PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result) 250 328 { 251 InjectedScript injectedScript = m_in spectorAgent->injectedScriptHost()->injectedScriptForObjectId(callFrameId.get());329 InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(callFrameId.get()); 252 330 if (!injectedScript.hasNoValue()) 253 331 injectedScript.evaluateOnCallFrame(callFrameId, expression, objectGroup, includeCommandLineAPI, result); … … 256 334 void InspectorDebuggerAgent::getCompletionsOnCallFrame(ErrorString*, PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result) 257 335 { 258 InjectedScript injectedScript = m_in spectorAgent->injectedScriptHost()->injectedScriptForObjectId(callFrameId.get());336 InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(callFrameId.get()); 259 337 if (!injectedScript.hasNoValue()) 260 338 injectedScript.getCompletionsOnCallFrame(callFrameId, expression, includeCommandLineAPI, result); … … 265 343 if (!m_pausedScriptState) 266 344 return InspectorValue::null(); 267 InjectedScript injectedScript = m_in spectorAgent->injectedScriptHost()->injectedScriptFor(m_pausedScriptState);345 InjectedScript injectedScript = m_injectedScriptHost->injectedScriptFor(m_pausedScriptState); 268 346 if (injectedScript.hasNoValue()) { 269 347 ASSERT_NOT_REACHED(); … … 285 363 return; 286 364 287 RefPtr<InspectorObject> breakpointsCookie = m_inspector Agent->state()->getObject(DebuggerAgentState::javaScriptBreakpoints);365 RefPtr<InspectorObject> breakpointsCookie = m_inspectorState->getObject(DebuggerAgentState::javaScriptBreakpoints); 288 366 for (InspectorObject::iterator it = breakpointsCookie->begin(); it != breakpointsCookie->end(); ++it) { 289 367 RefPtr<InspectorObject> breakpointObject = it->second->asObject(); … … 341 419 } 342 420 421 void InspectorDebuggerAgent::clear() 422 { 423 m_pausedScriptState = 0; 424 m_scripts.clear(); 425 m_breakpointIdToDebugServerBreakpointIds.clear(); 426 m_continueToLocationBreakpointId = String(); 427 m_breakProgramDetails.clear(); 428 m_javaScriptPauseScheduled = false; 429 } 430 343 431 } // namespace WebCore 344 432 -
trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h
r79539 r79858 45 45 46 46 class InjectedScriptHost; 47 class InspectorAgent;48 47 class InspectorFrontend; 49 48 class InspectorObject; 49 class InspectorState; 50 50 class InspectorValue; 51 class InstrumentingAgents; 52 class Page; 51 53 52 54 typedef String ErrorString; … … 61 63 WTF_MAKE_NONCOPYABLE(InspectorDebuggerAgent); WTF_MAKE_FAST_ALLOCATED; 62 64 public: 63 static PassOwnPtr<InspectorDebuggerAgent> create(Ins pectorAgent*, InspectorFrontend*, bool eraseStickyBreakpoints);65 static PassOwnPtr<InspectorDebuggerAgent> create(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptHost*); 64 66 virtual ~InspectorDebuggerAgent(); 67 68 void startUserInitiatedDebugging(); 69 void enable(ErrorString*) { enable(false); } 70 void disable(ErrorString*) { disable(); } 71 void disable(); 72 bool enabled(); 73 void restore(); 74 void setFrontend(InspectorFrontend*); 75 void clearFrontend(); 65 76 66 77 void inspectedURLChanged(const String& url); … … 89 100 void getCompletionsOnCallFrame(ErrorString* error, PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result); 90 101 102 class Listener { 103 public: 104 virtual ~Listener() { } 105 virtual void debuggerWasEnabled() = 0; 106 virtual void debuggerWasDisabled() = 0; 107 }; 108 void setListener(Listener* listener) { m_listener = listener; } 109 91 110 private: 92 InspectorDebuggerAgent(InspectorAgent*, InspectorFrontend*, bool eraseStickyBreakpoints); 111 InspectorDebuggerAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptHost*); 112 113 void enable(bool restoringFromState); 93 114 94 115 PassRefPtr<InspectorValue> currentCallFrames(); … … 100 121 101 122 bool resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint&, int* actualLineNumber, int* actualColumnNumber); 123 void clear(); 102 124 103 125 class Script { … … 129 151 typedef HashMap<String, Vector<String> > BreakpointIdToDebugServerBreakpointIdsMap; 130 152 131 InspectorAgent* m_inspectorAgent; 153 InstrumentingAgents* m_instrumentingAgents; 154 InspectorState* m_inspectorState; 155 Page* m_inspectedPage; 156 InjectedScriptHost* m_injectedScriptHost; 132 157 InspectorFrontend* m_frontend; 133 158 ScriptState* m_pausedScriptState; … … 137 162 RefPtr<InspectorObject> m_breakProgramDetails; 138 163 bool m_javaScriptPauseScheduled; 164 Listener* m_listener; 139 165 }; 140 166 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r79323 r79858 103 103 { 104 104 #if ENABLE(JAVASCRIPT_DEBUGGER) 105 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())105 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 106 106 browserDebuggerAgent->willInsertDOMNode(node, parent); 107 107 #endif … … 113 113 domAgent->didInsertDOMNode(node); 114 114 #if ENABLE(JAVASCRIPT_DEBUGGER) 115 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())115 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 116 116 browserDebuggerAgent->didInsertDOMNode(node); 117 117 #endif … … 121 121 { 122 122 #if ENABLE(JAVASCRIPT_DEBUGGER) 123 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())123 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 124 124 browserDebuggerAgent->willRemoveDOMNode(node); 125 125 #endif … … 129 129 { 130 130 #if ENABLE(JAVASCRIPT_DEBUGGER) 131 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())131 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 132 132 browserDebuggerAgent->didRemoveDOMNode(node); 133 133 #endif … … 139 139 { 140 140 #if ENABLE(JAVASCRIPT_DEBUGGER) 141 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())141 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 142 142 browserDebuggerAgent->willModifyDOMAttr(element); 143 143 #endif … … 175 175 { 176 176 #if ENABLE(JAVASCRIPT_DEBUGGER) 177 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())177 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 178 178 browserDebuggerAgent->willSendXMLHttpRequest(url); 179 179 #endif … … 668 668 { 669 669 #if ENABLE(JAVASCRIPT_DEBUGGER) 670 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent-> browserDebuggerAgent())670 if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorAgent->instrumentingAgents()->inspectorBrowserDebuggerAgent()) 671 671 browserDebuggerAgent->pauseOnNativeEventIfNeeded(categoryType, eventName, synchronous); 672 672 #endif -
trunk/Source/WebCore/inspector/front-end/DebuggerModel.js
r78717 r79858 53 53 enableDebugger: function() 54 54 { 55 InspectorAgent.enableDebugger();55 DebuggerAgent.enable(); 56 56 if (this._breakpointsPushedToBackend) 57 57 return; … … 69 69 disableDebugger: function() 70 70 { 71 InspectorAgent.disableDebugger();71 DebuggerAgent.disable(); 72 72 }, 73 73
Note: See TracChangeset
for help on using the changeset viewer.