Commit 631b2ce6 authored by pfeldman@chromium.org's avatar pfeldman@chromium.org

2011-01-20 Pavel Feldman <pfeldman@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: further simplify InspectorState.
        https://bugs.webkit.org/show_bug.cgi?id=52731

        This change moves XHR logging flag into console agent,
        removes InspectorState pushing to the front-end.

        * inspector/Inspector.idl:
        * inspector/InspectorConsoleAgent.cpp:
        (WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
        (WebCore::InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest):
        (WebCore::InspectorConsoleAgent::setMonitoringXHREnabled):
        (WebCore::InspectorConsoleAgent::setConsoleMessagesEnabled):
        (WebCore::InspectorConsoleAgent::addConsoleMessage):
        * inspector/InspectorConsoleAgent.h:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::InspectorController):
        * inspector/InspectorController.h:
        (WebCore::InspectorController::state):
        (WebCore::InspectorController::settings):
        * inspector/InspectorState.cpp:
        (WebCore::InspectorState::InspectorState):
        (WebCore::InspectorState::registerBoolean):
        (WebCore::InspectorState::registerString):
        (WebCore::InspectorState::registerLong):
        (WebCore::InspectorState::registerObject):
        (WebCore::InspectorState::Property::create):
        * inspector/InspectorState.h:
        * inspector/front-end/ConsoleView.js:
        (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.consoleMessagesCleared):
        (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.monitoringXHRStateChanged):
        (WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher):
        (WebInspector.ConsoleView.prototype._handleContextMenuEvent):
        * inspector/front-end/inspector.js:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76230 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 343ce767
2011-01-20 Pavel Feldman <pfeldman@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: further simplify InspectorState.
https://bugs.webkit.org/show_bug.cgi?id=52731
This change moves XHR logging flag into console agent,
removes InspectorState pushing to the front-end.
* inspector/Inspector.idl:
* inspector/InspectorConsoleAgent.cpp:
(WebCore::InspectorConsoleAgent::InspectorConsoleAgent):
(WebCore::InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest):
(WebCore::InspectorConsoleAgent::setMonitoringXHREnabled):
(WebCore::InspectorConsoleAgent::setConsoleMessagesEnabled):
(WebCore::InspectorConsoleAgent::addConsoleMessage):
* inspector/InspectorConsoleAgent.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorController.h:
(WebCore::InspectorController::state):
(WebCore::InspectorController::settings):
* inspector/InspectorState.cpp:
(WebCore::InspectorState::InspectorState):
(WebCore::InspectorState::registerBoolean):
(WebCore::InspectorState::registerString):
(WebCore::InspectorState::registerLong):
(WebCore::InspectorState::registerObject):
(WebCore::InspectorState::Property::create):
* inspector/InspectorState.h:
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.consoleMessagesCleared):
(WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher.dispatcher.monitoringXHRStateChanged):
(WebInspector.ConsoleView.prototype._registerConsoleDomainDispatcher):
(WebInspector.ConsoleView.prototype._handleContextMenuEvent):
* inspector/front-end/inspector.js:
2011-01-20 Csaba Osztrogonác <ossy@webkit.org>
Unreviewed buildfix.
......@@ -39,8 +39,6 @@ module core {
[domain=Inspector] void addScriptToEvaluateOnLoad(in String scriptSource);
[domain=Inspector] void removeAllScriptsToEvaluateOnLoad();
[domain=Inspector] void releaseWrapperObjectGroup(in long injectedScriptId, in String objectGroup);
[domain=Inspector] void getInspectorState(out Object state);
[domain=Inspector] void setMonitoringXHREnabled(in boolean enable, out boolean newState);
[domain=Inspector] void reloadPage();
[domain=Inspector] void populateScriptObjects();
......@@ -95,6 +93,8 @@ module core {
[notify, domain=Console] void updateConsoleMessageRepeatCount(out unsigned long count);
[domain=Console] void clearConsoleMessages();
[notify, domain=Console] void consoleMessagesCleared();
[domain=Console] void setMonitoringXHREnabled(in boolean enabled);
[notify, domain=Console] void monitoringXHRStateChanged(out boolean enabled);
///////////////////////////////////////////////////////////////////////
// Network API
......
......@@ -33,6 +33,7 @@
#include "InspectorController.h"
#include "InspectorDOMAgent.h"
#include "InspectorFrontend.h"
#include "InspectorSettings.h"
#include "InspectorState.h"
#include "ResourceError.h"
#include "ResourceResponse.h"
......@@ -49,9 +50,8 @@ namespace WebCore {
static const unsigned maximumConsoleMessages = 1000;
static const unsigned expireConsoleMessagesStep = 100;
InspectorConsoleAgent::InspectorConsoleAgent(InspectorController* inspectorController, InspectorState* state)
InspectorConsoleAgent::InspectorConsoleAgent(InspectorController* inspectorController)
: m_inspectorController(inspectorController)
, m_state(state)
, m_frontend(0)
, m_previousMessage(0)
, m_expiredConsoleMessageCount(0)
......@@ -165,7 +165,7 @@ void InspectorConsoleAgent::resourceRetrievedByXMLHttpRequest(const String& url,
{
if (!m_inspectorController->enabled())
return;
if (m_state->getBoolean(InspectorState::monitoringXHR))
if (m_inspectorController->state()->getBoolean(InspectorState::monitoringXHR))
addMessageToConsole(JSMessageSource, LogMessageType, LogMessageLevel, "XHR finished loading: \"" + url + "\".", sendLineNumber, sendURL);
}
......@@ -191,11 +191,21 @@ void InspectorConsoleAgent::didFailLoading(unsigned long identifier, const Resou
addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier));
}
void InspectorConsoleAgent::setMonitoringXHREnabled(bool enabled)
{
m_inspectorController->state()->setBoolean(InspectorState::monitoringXHR, enabled);
m_inspectorController->settings()->setBoolean(InspectorSettings::MonitoringXHREnabled, enabled);
if (m_frontend)
m_frontend->monitoringXHRStateChanged(enabled);
}
void InspectorConsoleAgent::setConsoleMessagesEnabled(bool enabled)
{
m_state->setBoolean(InspectorState::consoleMessagesEnabled, enabled);
if (!m_inspectorController->enabled())
m_inspectorController->state()->setBoolean(InspectorState::consoleMessagesEnabled, enabled);
if (!enabled || !m_frontend)
return;
m_frontend->monitoringXHRStateChanged(m_inspectorController->state()->getBoolean(InspectorState::monitoringXHR));
if (m_expiredConsoleMessageCount)
m_frontend->updateConsoleMessageExpiredCount(m_expiredConsoleMessageCount);
unsigned messageCount = m_consoleMessages.size();
......@@ -210,12 +220,12 @@ void InspectorConsoleAgent::addConsoleMessage(PassOwnPtr<ConsoleMessage> console
if (m_previousMessage && m_previousMessage->isEqual(consoleMessage.get())) {
m_previousMessage->incrementCount();
if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend)
if (m_inspectorController->state()->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend)
m_previousMessage->updateRepeatCountInConsole(m_frontend);
} else {
m_previousMessage = consoleMessage.get();
m_consoleMessages.append(consoleMessage);
if (m_state->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend)
if (m_inspectorController->state()->getBoolean(InspectorState::consoleMessagesEnabled) && m_frontend)
m_previousMessage->addToFrontend(m_frontend, m_inspectorController->injectedScriptHost());
}
......
......@@ -48,7 +48,7 @@ class ScriptProfile;
class InspectorConsoleAgent : public Noncopyable {
public:
InspectorConsoleAgent(InspectorController*, InspectorState*);
InspectorConsoleAgent(InspectorController*);
~InspectorConsoleAgent();
void setConsoleMessagesEnabled(bool enabled, bool* newState);
......@@ -70,13 +70,13 @@ public:
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
#endif
void setMonitoringXHREnabled(bool enabled);
private:
void setConsoleMessagesEnabled(bool);
void addConsoleMessage(PassOwnPtr<ConsoleMessage>);
InspectorController* m_inspectorController;
InspectorState* m_state;
InspectorFrontend* m_frontend;
ConsoleMessage* m_previousMessage;
Vector<OwnPtr<ConsoleMessage> > m_consoleMessages;
......
......@@ -142,7 +142,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
, m_state(new InspectorState(client))
, m_inspectorBackendDispatcher(new InspectorBackendDispatcher(this))
, m_injectedScriptHost(InjectedScriptHost::create(this))
, m_consoleAgent(new InspectorConsoleAgent(this, m_state.get()))
, m_consoleAgent(new InspectorConsoleAgent(this))
#if ENABLE(JAVASCRIPT_DEBUGGER)
, m_attachDebuggerWhenShown(false)
, m_profilerAgent(InspectorProfilerAgent::create(this))
......@@ -215,11 +215,6 @@ bool InspectorController::searchingForNodeInPage() const
return m_state->getBoolean(InspectorState::searchingForNode);
}
void InspectorController::getInspectorState(RefPtr<InspectorObject>* state)
{
*state = m_state->generateStateObjectForFrontend();
}
void InspectorController::restoreInspectorStateFromCookie(const String& inspectorStateCookie)
{
m_state->restoreFromInspectorCookie(inspectorStateCookie);
......@@ -379,13 +374,6 @@ void InspectorController::setSearchingForNode(bool enabled, bool* newState)
setSearchingForNode(enabled);
}
void InspectorController::setMonitoringXHREnabled(bool enabled, bool* newState)
{
*newState = enabled;
m_state->setBoolean(InspectorState::monitoringXHR, enabled);
m_settings->setBoolean(InspectorSettings::MonitoringXHREnabled, enabled);
}
void InspectorController::connectFrontend()
{
m_openingFrontend = false;
......
......@@ -258,6 +258,9 @@ public:
void setInspectorAttachedHeight(long height);
long inspectorAttachedHeight() const;
InspectorState* state() { return m_state.get(); }
InspectorSettings* settings() { return m_settings.get(); }
private:
friend class InspectorBackend;
friend class InspectorBackendDispatcher;
......@@ -269,8 +272,6 @@ private:
void ensureSettingsLoaded();
void getInspectorState(RefPtr<InspectorObject>* state);
void populateScriptObjects();
void pushDataCollectedOffline();
void restoreDebugger();
......@@ -285,7 +286,6 @@ private:
// Following are used from InspectorBackend and internally.
void setSearchingForNode(bool enabled, bool* newState);
void setMonitoringXHREnabled(bool enabled, bool* newState);
void releaseFrontendLifetimeAgents();
#if ENABLE(JAVASCRIPT_DEBUGGER)
......
......@@ -39,15 +39,12 @@ InspectorState::InspectorState(InspectorClient* client)
: m_client(client)
{
// Pure reload state
registerBoolean(userInitiatedProfiling, false, String());
registerBoolean(timelineProfilerEnabled, false, String());
registerBoolean(searchingForNode, false, String());
registerObject(stickyBreakpoints, String());
// Should go away
registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled");
registerBoolean(monitoringXHR, false, "monitoringXHREnabled");
registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState");
registerBoolean(userInitiatedProfiling, false);
registerBoolean(timelineProfilerEnabled, false);
registerBoolean(searchingForNode, false);
registerObject(stickyBreakpoints);
registerBoolean(consoleMessagesEnabled, false);
registerBoolean(monitoringXHR, false);
}
void InspectorState::restoreFromInspectorCookie(const String& json)
......@@ -70,16 +67,6 @@ void InspectorState::restoreFromInspectorCookie(const String& json)
}
}
PassRefPtr<InspectorObject> InspectorState::generateStateObjectForFrontend()
{
RefPtr<InspectorObject> stateObject = InspectorObject::create();
for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i) {
if (i->second.m_frontendAlias.length())
stateObject->setValue(i->second.m_frontendAlias, i->second.m_value);
}
return stateObject.release();
}
void InspectorState::updateCookie()
{
RefPtr<InspectorObject> cookieObject = InspectorObject::create();
......@@ -139,31 +126,30 @@ void InspectorState::setObject(InspectorPropertyId id, PassRefPtr<InspectorObjec
updateCookie();
}
void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias)
void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value)
{
m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value), frontendAlias));
m_properties.set(propertyId, Property::create(InspectorBasicValue::create(value)));
}
void InspectorState::registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias)
void InspectorState::registerString(InspectorPropertyId propertyId, const String& value)
{
m_properties.set(propertyId, Property::create(InspectorString::create(value), frontendAlias));
m_properties.set(propertyId, Property::create(InspectorString::create(value)));
}
void InspectorState::registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias)
void InspectorState::registerLong(InspectorPropertyId propertyId, long value)
{
m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias));
m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value)));
}
void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias)
void InspectorState::registerObject(InspectorPropertyId propertyId)
{
m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias));
m_properties.set(propertyId, Property::create(InspectorObject::create()));
}
InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value, const String& frontendAlias)
InspectorState::Property InspectorState::Property::create(PassRefPtr<InspectorValue> value)
{
Property property;
property.m_value = value;
property.m_frontendAlias = frontendAlias;
return property;
}
......
......@@ -47,7 +47,6 @@ public:
monitoringXHR = 1,
timelineProfilerEnabled,
searchingForNode,
pauseOnExceptionsState,
consoleMessagesEnabled,
userInitiatedProfiling,
stickyBreakpoints,
......@@ -56,36 +55,33 @@ public:
InspectorState(InspectorClient* client);
PassRefPtr<InspectorObject> generateStateObjectForFrontend();
void restoreFromInspectorCookie(const String& jsonString);
String getFrontendAlias(InspectorPropertyId propertyId);
bool getBoolean(InspectorPropertyId propertyId);
String getString(InspectorPropertyId propertyId);
long getLong(InspectorPropertyId propertyId);
PassRefPtr<InspectorObject> getObject(InspectorPropertyId id);
bool getBoolean(InspectorPropertyId);
String getString(InspectorPropertyId);
long getLong(InspectorPropertyId);
PassRefPtr<InspectorObject> getObject(InspectorPropertyId);
void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value)); }
void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value)); }
void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value)); }
void setObject(InspectorPropertyId propertyId, PassRefPtr<InspectorObject> value);
void setBoolean(InspectorPropertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value)); }
void setString(InspectorPropertyId, const String& value) { setValue(propertyId, InspectorString::create(value)); }
void setLong(InspectorPropertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value)); }
void setObject(InspectorPropertyId, PassRefPtr<InspectorObject> value);
private:
void updateCookie();
void setValue(InspectorPropertyId propertyId, PassRefPtr<InspectorValue> value);
void setValue(InspectorPropertyId, PassRefPtr<InspectorValue>);
struct Property {
static Property create(PassRefPtr<InspectorValue> value, const String& frontendAlias);
String m_frontendAlias;
static Property create(PassRefPtr<InspectorValue> value);
RefPtr<InspectorValue> m_value;
};
typedef HashMap<long, Property> PropertyMap;
PropertyMap m_properties;
void registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias);
void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias);
void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias);
void registerObject(InspectorPropertyId propertyId, const String& frontendAlias);
void registerBoolean(InspectorPropertyId, bool value);
void registerString(InspectorPropertyId, const String& value);
void registerLong(InspectorPropertyId, long value);
void registerObject(InspectorPropertyId);
InspectorClient* m_client;
};
......
......@@ -149,6 +149,11 @@ WebInspector.ConsoleView.prototype = {
consoleMessagesCleared: function()
{
console.clearMessages();
},
monitoringXHRStateChanged: function(enabled)
{
console._monitoringXHREnabled = enabled;
}
}
InspectorBackend.registerDomainDispatcher("Console", dispatcher);
......@@ -413,14 +418,9 @@ WebInspector.ConsoleView.prototype = {
return;
}
var itemAction = InspectorBackend.setMonitoringXHREnabled.bind(InspectorBackend, !this._monitoringXHREnabled);
var contextMenu = new WebInspector.ContextMenu();
function monitoringXHRWasChanged(newState)
{
WebInspector.monitoringXHREnabled = newState;
}
var itemAction = InspectorBackend.setMonitoringXHREnabled.bind(InspectorBackend, !WebInspector.monitoringXHREnabled, monitoringXHRWasChanged);
contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), itemAction, WebInspector.monitoringXHREnabled);
contextMenu.appendCheckboxItem(WebInspector.UIString("XMLHttpRequest logging"), itemAction, this._monitoringXHREnabled);
contextMenu.appendItem(WebInspector.UIString("Clear Console"), this.requestClearMessages.bind(this));
contextMenu.show(event);
},
......
......@@ -601,12 +601,6 @@ WebInspector.doLoadedDone = function()
this.extensionServer.initExtensions();
function populateInspectorState(inspectorState)
{
WebInspector.monitoringXHREnabled = inspectorState.monitoringXHREnabled;
}
InspectorBackend.getInspectorState(populateInspectorState);
function onPopulateScriptObjects()
{
if (!WebInspector.currentPanel)
......
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