Commit b169accc authored by yurys@chromium.org's avatar yurys@chromium.org

2011-03-15 Yury Semikhatsky <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: split InspectorAgent.populateScriptObjects into more granular agent-specific requests
        https://bugs.webkit.org/show_bug.cgi?id=56389

        Instead of sending one big request populateScriptObjects each agent requests
        for initial data in its constructor.

        * inspector/Inspector.idl:
        * inspector/InspectorAgent.cpp:
        (WebCore::InspectorAgent::InspectorAgent):
        (WebCore::InspectorAgent::restoreInspectorStateFromCookie):
        (WebCore::InspectorAgent::setFrontend):
        (WebCore::InspectorAgent::pushDataCollectedOffline):
        (WebCore::InspectorAgent::getPreferredPanel):
        * inspector/InspectorAgent.h:
        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
        (WebCore::InspectorDOMAgent::setFrontend):
        (WebCore::InspectorDOMAgent::restore):
        * inspector/InspectorDOMAgent.h:
        (WebCore::InspectorDOMAgent::create):
        * inspector/InspectorDebuggerAgent.cpp:
        (WebCore::InspectorDebuggerAgent::setFrontend):
        * inspector/InspectorDebuggerAgent.h:
        * inspector/InspectorProfilerAgent.h:
        (WebCore::InspectorProfilerAgent::isEnabled):
        * inspector/front-end/ProfilesPanel.js:
        (WebInspector.ProfilesPanel):
        * inspector/front-end/ScriptsPanel.js:
        (WebInspector.ScriptsPanel):
        * inspector/front-end/inspector.js:

git-svn-id: svn://svn.chromium.org/blink/trunk@81222 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0aa2e1f3
2011-03-15 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: split InspectorAgent.populateScriptObjects into more granular agent-specific requests
https://bugs.webkit.org/show_bug.cgi?id=56389
Instead of sending one big request populateScriptObjects each agent requests
for initial data in its constructor.
* inspector/Inspector.idl:
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::InspectorAgent):
(WebCore::InspectorAgent::restoreInspectorStateFromCookie):
(WebCore::InspectorAgent::setFrontend):
(WebCore::InspectorAgent::pushDataCollectedOffline):
(WebCore::InspectorAgent::getPreferredPanel):
* inspector/InspectorAgent.h:
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::InspectorDOMAgent):
(WebCore::InspectorDOMAgent::setFrontend):
(WebCore::InspectorDOMAgent::restore):
* inspector/InspectorDOMAgent.h:
(WebCore::InspectorDOMAgent::create):
* inspector/InspectorDebuggerAgent.cpp:
(WebCore::InspectorDebuggerAgent::setFrontend):
* inspector/InspectorDebuggerAgent.h:
* inspector/InspectorProfilerAgent.h:
(WebCore::InspectorProfilerAgent::isEnabled):
* inspector/front-end/ProfilesPanel.js:
(WebInspector.ProfilesPanel):
* inspector/front-end/ScriptsPanel.js:
(WebInspector.ScriptsPanel):
* inspector/front-end/inspector.js:
2011-03-15 Ryosuke Niwa <rniwa@webkit.org> 2011-03-15 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Darin Adler. Reviewed by Darin Adler.
......
...@@ -34,7 +34,6 @@ module core { ...@@ -34,7 +34,6 @@ module core {
void addScriptToEvaluateOnLoad(in String scriptSource); void addScriptToEvaluateOnLoad(in String scriptSource);
void removeAllScriptsToEvaluateOnLoad(); void removeAllScriptsToEvaluateOnLoad();
void reloadPage(in boolean ignoreCache); void reloadPage(in boolean ignoreCache);
void populateScriptObjects();
void openInInspectedWindow(in String url); void openInInspectedWindow(in String url);
void setSearchingForNode(in boolean enabled, out boolean newState); void setSearchingForNode(in boolean enabled, out boolean newState);
...@@ -254,6 +253,7 @@ module core { ...@@ -254,6 +253,7 @@ module core {
interface [Conditional=INSPECTOR] Profiler { interface [Conditional=INSPECTOR] Profiler {
void enable(); void enable();
void disable(); void disable();
void isEnabled(out boolean state);
void start(); void start();
void stop(); void stop();
[event] void profilerWasEnabled(); [event] void profilerWasEnabled();
......
...@@ -138,7 +138,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri ...@@ -138,7 +138,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri
, m_instrumentingAgents(new InstrumentingAgents()) , m_instrumentingAgents(new InstrumentingAgents())
, m_injectedScriptManager(injectedScriptManager) , m_injectedScriptManager(injectedScriptManager)
, m_state(new InspectorState(client)) , m_state(new InspectorState(client))
, m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), m_state.get(), injectedScriptManager)) , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), page, m_state.get(), injectedScriptManager))
, m_cssAgent(new InspectorCSSAgent(m_instrumentingAgents.get(), m_domAgent.get())) , m_cssAgent(new InspectorCSSAgent(m_instrumentingAgents.get(), m_domAgent.get()))
#if ENABLE(DATABASE) #if ENABLE(DATABASE)
, m_databaseAgent(InspectorDatabaseAgent::create(m_instrumentingAgents.get())) , m_databaseAgent(InspectorDatabaseAgent::create(m_instrumentingAgents.get()))
...@@ -219,8 +219,8 @@ void InspectorAgent::restoreInspectorStateFromCookie(const String& inspectorStat ...@@ -219,8 +219,8 @@ void InspectorAgent::restoreInspectorStateFromCookie(const String& inspectorStat
m_frontend->inspector()->frontendReused(); m_frontend->inspector()->frontendReused();
m_frontend->inspector()->inspectedURLChanged(inspectedURL().string()); m_frontend->inspector()->inspectedURLChanged(inspectedURL().string());
pushDataCollectedOffline();
m_domAgent->restore();
m_resourceAgent->restore(); m_resourceAgent->restore();
m_timelineAgent->restore(); m_timelineAgent->restore();
...@@ -396,6 +396,22 @@ void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend) ...@@ -396,6 +396,22 @@ void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
#endif #endif
// Initialize Web Inspector title. // Initialize Web Inspector title.
m_frontend->inspector()->inspectedURLChanged(inspectedURL().string()); m_frontend->inspector()->inspectedURLChanged(inspectedURL().string());
if (!m_showPanelAfterVisible.isEmpty()) {
m_frontend->inspector()->showPanel(m_showPanelAfterVisible);
m_showPanelAfterVisible = String();
}
if (m_nodeToFocus)
focusNode();
#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS)
WorkersMap::iterator workersEnd = m_workers.end();
for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) {
InspectorWorkerResource* worker = it->second.get();
m_frontend->debugger()->didCreateWorker(worker->id(), worker->url(), worker->isSharedWorker());
}
#endif
// Dispatch pending frontend commands
issueEvaluateForTestCommands();
} }
void InspectorAgent::disconnectFrontend() void InspectorAgent::disconnectFrontend()
...@@ -450,48 +466,6 @@ void InspectorAgent::releaseFrontendLifetimeAgents() ...@@ -450,48 +466,6 @@ void InspectorAgent::releaseFrontendLifetimeAgents()
m_runtimeAgent.clear(); m_runtimeAgent.clear();
} }
void InspectorAgent::populateScriptObjects(ErrorString*)
{
ASSERT(m_frontend);
if (!m_frontend)
return;
#if ENABLE(JAVASCRIPT_DEBUGGER)
if (m_profilerAgent->enabled())
m_frontend->profiler()->profilerWasEnabled();
#endif
pushDataCollectedOffline();
if (m_nodeToFocus)
focusNode();
if (!m_showPanelAfterVisible.isEmpty()) {
m_frontend->inspector()->showPanel(m_showPanelAfterVisible);
m_showPanelAfterVisible = "";
}
#if ENABLE(JAVASCRIPT_DEBUGGER)
m_debuggerAgent->enableDebuggerAfterShown();
#endif
// Dispatch pending frontend commands
issueEvaluateForTestCommands();
}
void InspectorAgent::pushDataCollectedOffline()
{
m_domAgent->setDocument(m_inspectedPage->mainFrame()->document());
#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS)
WorkersMap::iterator workersEnd = m_workers.end();
for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) {
InspectorWorkerResource* worker = it->second.get();
m_frontend->debugger()->didCreateWorker(worker->id(), worker->url(), worker->isSharedWorker());
}
#endif
}
void InspectorAgent::didCommitLoad(DocumentLoader* loader) void InspectorAgent::didCommitLoad(DocumentLoader* loader)
{ {
if (m_frontend) { if (m_frontend) {
......
...@@ -199,7 +199,6 @@ public: ...@@ -199,7 +199,6 @@ public:
// InspectorAgent API // InspectorAgent API
void getInspectorState(RefPtr<InspectorObject>* state); void getInspectorState(RefPtr<InspectorObject>* state);
void setMonitoringXHREnabled(bool enabled, bool* newState); void setMonitoringXHREnabled(bool enabled, bool* newState);
void populateScriptObjects(ErrorString* error);
// Following are used from InspectorBackend and internally. // Following are used from InspectorBackend and internally.
void setSearchingForNode(ErrorString* error, bool enabled, bool* newState); void setSearchingForNode(ErrorString* error, bool enabled, bool* newState);
void didEvaluateForTestInFrontend(ErrorString* error, long callId, const String& jsonResult); void didEvaluateForTestInFrontend(ErrorString* error, long callId, const String& jsonResult);
...@@ -209,7 +208,6 @@ public: ...@@ -209,7 +208,6 @@ public:
private: private:
void showPanel(const String& panel); void showPanel(const String& panel);
void pushDataCollectedOffline();
void unbindAllResources(); void unbindAllResources();
void setSearchingForNode(bool enabled); void setSearchingForNode(bool enabled);
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
#include "MutationEvent.h" #include "MutationEvent.h"
#include "Node.h" #include "Node.h"
#include "NodeList.h" #include "NodeList.h"
#include "Page.h"
#include "Pasteboard.h" #include "Pasteboard.h"
#include "PlatformString.h" #include "PlatformString.h"
#include "RenderStyle.h" #include "RenderStyle.h"
...@@ -252,8 +253,9 @@ void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*) ...@@ -252,8 +253,9 @@ void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*)
m_elements.clear(); m_elements.clear();
} }
InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager) InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, Page* inspectedPage, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
: m_instrumentingAgents(instrumentingAgents) : m_instrumentingAgents(instrumentingAgents)
, m_inspectedPage(inspectedPage)
, m_inspectorState(inspectorState) , m_inspectorState(inspectorState)
, m_injectedScriptManager(injectedScriptManager) , m_injectedScriptManager(injectedScriptManager)
, m_frontend(0) , m_frontend(0)
...@@ -273,6 +275,7 @@ void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend) ...@@ -273,6 +275,7 @@ void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
ASSERT(!m_frontend); ASSERT(!m_frontend);
m_frontend = frontend->dom(); m_frontend = frontend->dom();
m_instrumentingAgents->setInspectorDOMAgent(this); m_instrumentingAgents->setInspectorDOMAgent(this);
m_document = m_inspectedPage->mainFrame()->document();
} }
void InspectorDOMAgent::clearFrontend() void InspectorDOMAgent::clearFrontend()
...@@ -284,6 +287,13 @@ void InspectorDOMAgent::clearFrontend() ...@@ -284,6 +287,13 @@ void InspectorDOMAgent::clearFrontend()
reset(); reset();
} }
void InspectorDOMAgent::restore()
{
// Reset document to avoid early return from setDocument.
m_document = 0;
setDocument(m_inspectedPage->mainFrame()->document());
}
Vector<Document*> InspectorDOMAgent::documents() Vector<Document*> InspectorDOMAgent::documents()
{ {
Vector<Document*> result; Vector<Document*> result;
......
...@@ -93,15 +93,16 @@ public: ...@@ -93,15 +93,16 @@ public:
virtual void didModifyDOMAttr(Element*) = 0; virtual void didModifyDOMAttr(Element*) = 0;
}; };
static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager) static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
{ {
return adoptPtr(new InspectorDOMAgent(instrumentingAgents, inspectorState, injectedScriptManager)); return adoptPtr(new InspectorDOMAgent(instrumentingAgents, page, inspectorState, injectedScriptManager));
} }
~InspectorDOMAgent(); ~InspectorDOMAgent();
void setFrontend(InspectorFrontend*); void setFrontend(InspectorFrontend*);
void clearFrontend(); void clearFrontend();
void restore();
Vector<Document*> documents(); Vector<Document*> documents();
void reset(); void reset();
...@@ -157,7 +158,7 @@ public: ...@@ -157,7 +158,7 @@ public:
static bool isWhitespace(Node*); static bool isWhitespace(Node*);
private: private:
InspectorDOMAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*); InspectorDOMAgent(InstrumentingAgents*, Page*, InspectorState*, InjectedScriptManager*);
// Node-related methods. // Node-related methods.
typedef HashMap<RefPtr<Node>, long> NodeToIdMap; typedef HashMap<RefPtr<Node>, long> NodeToIdMap;
...@@ -189,6 +190,7 @@ private: ...@@ -189,6 +190,7 @@ private:
void discardBindings(); void discardBindings();
InstrumentingAgents* m_instrumentingAgents; InstrumentingAgents* m_instrumentingAgents;
Page* m_inspectedPage;
InspectorState* m_inspectorState; InspectorState* m_inspectorState;
InjectedScriptManager* m_injectedScriptManager; InjectedScriptManager* m_injectedScriptManager;
InspectorFrontend::DOM* m_frontend; InspectorFrontend::DOM* m_frontend;
......
...@@ -128,10 +128,7 @@ void InspectorDebuggerAgent::restore() ...@@ -128,10 +128,7 @@ void InspectorDebuggerAgent::restore()
void InspectorDebuggerAgent::setFrontend(InspectorFrontend* frontend) void InspectorDebuggerAgent::setFrontend(InspectorFrontend* frontend)
{ {
m_frontend = frontend->debugger(); m_frontend = frontend->debugger();
}
void InspectorDebuggerAgent::enableDebuggerAfterShown()
{
if (m_inspectorState->getBoolean(DebuggerAgentState::enableWhenShown)) { if (m_inspectorState->getBoolean(DebuggerAgentState::enableWhenShown)) {
m_inspectorState->setBoolean(DebuggerAgentState::enableWhenShown, false); m_inspectorState->setBoolean(DebuggerAgentState::enableWhenShown, false);
enable(false); enable(false);
......
...@@ -73,7 +73,6 @@ public: ...@@ -73,7 +73,6 @@ public:
bool enabled(); bool enabled();
void restore(); void restore();
void setFrontend(InspectorFrontend*); void setFrontend(InspectorFrontend*);
void enableDebuggerAfterShown();
void clearFrontend(); void clearFrontend();
void inspectedURLChanged(const String& url); void inspectedURLChanged(const String& url);
......
...@@ -68,6 +68,7 @@ public: ...@@ -68,6 +68,7 @@ public:
void enable(ErrorString*); void enable(ErrorString*);
void disable(ErrorString*); void disable(ErrorString*);
void isEnabled(ErrorString*, bool* result) { *result = enabled(); }
void start(ErrorString*) { startUserInitiatedProfiling(); } void start(ErrorString*) { startUserInitiatedProfiling(); }
void stop(ErrorString*) { stopUserInitiatedProfiling(); } void stop(ErrorString*) { stopUserInitiatedProfiling(); }
......
...@@ -134,6 +134,16 @@ WebInspector.ProfilesPanel = function() ...@@ -134,6 +134,16 @@ WebInspector.ProfilesPanel = function()
} }
InspectorBackend.registerDomainDispatcher("Profiler", new WebInspector.ProfilerDispatcher(this)); InspectorBackend.registerDomainDispatcher("Profiler", new WebInspector.ProfilerDispatcher(this));
if (Preferences.profilerAlwaysEnabled || WebInspector.settings.profilerEnabled)
ProfilerAgent.enable();
else {
function onProfilerEnebled(error, value) {
if (value)
this._profilerWasEnabled();
}
ProfilerAgent.isEnabled(onProfilerEnebled.bind(this));
}
} }
WebInspector.ProfilesPanel.prototype = { WebInspector.ProfilesPanel.prototype = {
......
...@@ -195,6 +195,9 @@ WebInspector.ScriptsPanel = function() ...@@ -195,6 +195,9 @@ WebInspector.ScriptsPanel = function()
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, this._breakpointAdded, this); this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointAdded, this._breakpointAdded, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, this._breakpointRemoved, this); this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.BreakpointRemoved, this._breakpointRemoved, this);
this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, this._callFrameSelected, this); this._presentationModel.addEventListener(WebInspector.DebuggerPresentationModel.Events.CallFrameSelected, this._callFrameSelected, this);
if (Preferences.debuggerAlwaysEnabled || WebInspector.settings.debuggerEnabled)
WebInspector.debuggerModel.enableDebugger();
} }
// Keep these in sync with WebCore::ScriptDebugServer // Keep these in sync with WebCore::ScriptDebugServer
......
...@@ -503,22 +503,12 @@ WebInspector.doLoadedDone = function() ...@@ -503,22 +503,12 @@ WebInspector.doLoadedDone = function()
this.extensionServer.initExtensions(); this.extensionServer.initExtensions();
function onPopulateScriptObjects(error)
{
if (!error && !WebInspector.currentPanel)
WebInspector.showPanel(WebInspector.settings.lastActivePanel);
}
InspectorAgent.populateScriptObjects(onPopulateScriptObjects);
if (Preferences.debuggerAlwaysEnabled || WebInspector.settings.debuggerEnabled)
this.debuggerModel.enableDebugger();
if (Preferences.profilerAlwaysEnabled || WebInspector.settings.profilerEnabled)
ProfilerAgent.enable();
if (WebInspector.settings.monitoringXHREnabled) if (WebInspector.settings.monitoringXHREnabled)
ConsoleAgent.setMonitoringXHREnabled(true); ConsoleAgent.setMonitoringXHREnabled(true);
ConsoleAgent.setConsoleMessagesEnabled(true); ConsoleAgent.setConsoleMessagesEnabled(true);
WebInspector.showPanel(WebInspector.settings.lastActivePanel);
function propertyNamesCallback(error, names) function propertyNamesCallback(error, names)
{ {
if (!error) if (!error)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment