+2011-02-24 Ilya Tikhonovsky <loislo@chromium.org>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: There is a validator of the protocol message format.
+
+ It has two parts. InspectorBackendStub.js is the frontend part.
+ InspectorBackendDispatcher.cpp is the backend part.
+ Both parts are checking protocol message format and report the error if
+ the message has not enough fields or the types of fields do not match with
+ Inspector.idl specification. These validators are generated automatically.
+
+ In addition, we have a number of places at the backend where we check the
+ function arguments and do nothing if the arguments are invalid
+ from the business logic point of view.
+
+ This patch bring us an ability to report a custom error from such function to the frontend.
+
+ https://bugs.webkit.org/show_bug.cgi?id=54971
+
+ * inspector/CodeGeneratorInspector.pm:
+ * inspector/InjectedScriptHost.cpp:
+ * inspector/InspectorAgent.cpp:
+ * inspector/InspectorAgent.h:
+ * inspector/InspectorApplicationCacheAgent.cpp:
+ * inspector/InspectorApplicationCacheAgent.h:
+ * inspector/InspectorBrowserDebuggerAgent.cpp:
+ * inspector/InspectorBrowserDebuggerAgent.h:
+ * inspector/InspectorCSSAgent.cpp:
+ * inspector/InspectorCSSAgent.h:
+ * inspector/InspectorConsoleAgent.cpp:
+ * inspector/InspectorConsoleAgent.h:
+ * inspector/InspectorController.cpp:
+ * inspector/InspectorDOMAgent.cpp:
+ * inspector/InspectorDOMAgent.h:
+ * inspector/InspectorDOMStorageAgent.cpp:
+ * inspector/InspectorDOMStorageAgent.h:
+ * inspector/InspectorDatabaseAgent.cpp:
+ * inspector/InspectorDatabaseAgent.h:
+ * inspector/InspectorDebuggerAgent.cpp:
+ * inspector/InspectorDebuggerAgent.h:
+ * inspector/InspectorProfilerAgent.cpp:
+ * inspector/InspectorProfilerAgent.h:
+ * inspector/InspectorResourceAgent.cpp:
+ * inspector/InspectorResourceAgent.h:
+ * inspector/InspectorRuntimeAgent.cpp:
+ * inspector/InspectorRuntimeAgent.h:
+ * inspector/InspectorTimelineAgent.cpp:
+ * inspector/InspectorTimelineAgent.h:
+
2011-02-24 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Ojan Vafai.
$indent = " ";
}
- my $args = join(", ", (map($_->name, @inArgs), map("&" . $_->name, @outArgs)));
+ push(@function, "$indent ErrorString error;");
+ my $args = join(", ", ("&error", map($_->name, @inArgs), map("&" . $_->name, @outArgs)));
push(@function, "$indent if (!protocolErrors->length())");
push(@function, "$indent $domainAccessor->$functionName($args);");
+ push(@function, "$indent if (error.length())");
+ push(@function, "$indent protocolErrors->pushString(error);");
if (scalar(@inArgs)) {
push(@function, " } else {");
push(@function, " protocolErrors->pushString(\"Protocol Error: 'arguments' property with type 'object' was not found.\");");
$forwardDeclarations
+typedef String ErrorString;
+
class $className {
public:
$constructor
void InjectedScriptHost::clearConsoleMessages()
{
- if (m_inspectorAgent)
- m_inspectorAgent->consoleAgent()->clearConsoleMessages();
+ if (m_inspectorAgent) {
+ ErrorString error;
+ m_inspectorAgent->consoleAgent()->clearConsoleMessages(&error);
+ }
}
void InjectedScriptHost::copyText(const String& text)
if (m_frontend)
m_frontend->disconnectFromBackend();
- hideHighlight();
+ ErrorString error;
+ hideHighlight(&error);
#if ENABLE(JAVASCRIPT_DEBUGGER)
m_debuggerAgent.clear();
m_nodeToFocus = 0;
}
-void InspectorAgent::highlight(Node* node)
+void InspectorAgent::highlight(ErrorString*, Node* node)
{
if (!enabled())
return;
m_client->highlight(node);
}
-void InspectorAgent::highlightDOMNode(long nodeId)
+void InspectorAgent::highlightDOMNode(ErrorString* error, long nodeId)
{
Node* node = 0;
if (m_domAgent && (node = m_domAgent->nodeForId(nodeId)))
- highlight(node);
+ highlight(error, node);
}
-void InspectorAgent::highlightFrame(unsigned long frameId)
+void InspectorAgent::highlightFrame(ErrorString* error, unsigned long frameId)
{
Frame* mainFrame = m_inspectedPage->mainFrame();
for (Frame* frame = mainFrame; frame; frame = frame->tree()->traverseNext(mainFrame)) {
if (reinterpret_cast<uintptr_t>(frame) == frameId && frame->ownerElement()) {
- highlight(frame->ownerElement());
+ highlight(error, frame->ownerElement());
return;
}
}
}
-void InspectorAgent::hideHighlight()
+void InspectorAgent::hideHighlight(ErrorString*)
{
if (!enabled())
return;
Node* node = result.innerNode();
while (node && node->nodeType() == Node::TEXT_NODE)
node = node->parentNode();
- if (node)
- highlight(node);
+ if (node) {
+ ErrorString error;
+ highlight(&error, node);
+ }
}
bool InspectorAgent::handleMousePress()
if (searchingForNodeInPage() == enabled)
return;
m_state->setBoolean(InspectorAgentState::searchingForNode, enabled);
- if (!enabled)
- hideHighlight();
+ if (!enabled) {
+ ErrorString error;
+ hideHighlight(&error);
+ }
}
-void InspectorAgent::setSearchingForNode(bool enabled, bool* newState)
+void InspectorAgent::setSearchingForNode(ErrorString*, bool enabled, bool* newState)
{
*newState = enabled;
setSearchingForNode(enabled);
m_frontend = 0;
+ ErrorString error;
#if ENABLE(JAVASCRIPT_DEBUGGER)
// If the window is being closed with the debugger enabled,
// remember this state to re-enable debugger on the next window
// opening.
- disableDebugger();
+ disableDebugger(&error);
#endif
setSearchingForNode(false);
- hideHighlight();
+ hideHighlight(&error);
#if ENABLE(JAVASCRIPT_DEBUGGER)
m_profilerAgent->setFrontend(0);
#endif
}
-void InspectorAgent::populateScriptObjects()
+void InspectorAgent::populateScriptObjects(ErrorString*)
{
ASSERT(m_frontend);
if (!m_frontend)
ASSERT(m_frontend);
#if ENABLE(JAVASCRIPT_DEBUGGER)
m_profilerAgent->setFrontend(m_frontend);
- if (m_state->getBoolean(InspectorAgentState::profilerEnabled))
- enableProfiler();
+ if (m_state->getBoolean(InspectorAgentState::profilerEnabled)) {
+ ErrorString error;
+ enableProfiler(&error);
+ }
if (action == ProfilerRestoreResetAgent)
m_profilerAgent->resetFrontendProfiles();
#endif
return loader->frame() == m_inspectedPage->mainFrame() && requestUrl == loader->requestURL();
}
-void InspectorAgent::setUserAgentOverride(const String& userAgent)
+void InspectorAgent::setUserAgentOverride(ErrorString*, const String& userAgent)
{
m_userAgentOverride = userAgent;
}
}
#endif // ENABLE(WORKERS)
-void InspectorAgent::getCookies(RefPtr<InspectorArray>* cookies, WTF::String* cookiesString)
+void InspectorAgent::getCookies(ErrorString*, RefPtr<InspectorArray>* cookies, WTF::String* cookiesString)
{
// If we can get raw cookies.
ListHashSet<Cookie> rawCookiesList;
return value;
}
-void InspectorAgent::deleteCookie(const String& cookieName, const String& domain)
+void InspectorAgent::deleteCookie(ErrorString*, const String& cookieName, const String& domain)
{
for (Frame* frame = m_inspectedPage->mainFrame(); frame; frame = frame->tree()->traverseNext(m_inspectedPage->mainFrame())) {
Document* document = frame->document();
return enabled() && m_profilerAgent->enabled();
}
-void InspectorAgent::enableProfiler()
+void InspectorAgent::enableProfiler(ErrorString*)
{
if (profilerEnabled())
return;
m_profilerAgent->enable(false);
}
-void InspectorAgent::disableProfiler()
+void InspectorAgent::disableProfiler(ErrorString*)
{
m_state->setBoolean(InspectorAgentState::profilerEnabled, false);
m_profilerAgent->disable();
m_frontend->debuggerWasEnabled();
}
-void InspectorAgent::disableDebugger()
+void InspectorAgent::disableDebugger(ErrorString*)
{
if (!enabled())
return;
m_state->setBoolean(InspectorAgentState::debuggerEnabled, false);
}
}
-
-void InspectorAgent::resume()
-{
- if (m_debuggerAgent)
- m_debuggerAgent->resume();
-}
#endif
void InspectorAgent::evaluateForTestInFrontend(long callId, const String& script)
m_pendingEvaluateTestCommands.append(pair<long, String>(callId, script));
}
-void InspectorAgent::didEvaluateForTestInFrontend(long callId, const String& jsonResult)
+void InspectorAgent::didEvaluateForTestInFrontend(ErrorString*, long callId, const String& jsonResult)
{
ScriptState* scriptState = scriptStateFromPage(debuggerWorld(), m_inspectedPage);
ScriptObject window;
context.drawText(font, nodeTitleRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + font.fontMetrics().height()));
}
-void InspectorAgent::openInInspectedWindow(const String& url)
+void InspectorAgent::openInInspectedWindow(ErrorString*, const String& url)
{
Frame* mainFrame = m_inspectedPage->mainFrame();
newFrame->loader()->changeLocation(mainFrame->document()->securityOrigin(), newFrame->loader()->completeURL(url), "", false, false);
}
-void InspectorAgent::addScriptToEvaluateOnLoad(const String& source)
+void InspectorAgent::addScriptToEvaluateOnLoad(ErrorString*, const String& source)
{
m_scriptsToEvaluateOnLoad.append(source);
}
-void InspectorAgent::removeAllScriptsToEvaluateOnLoad()
+void InspectorAgent::removeAllScriptsToEvaluateOnLoad(ErrorString*)
{
m_scriptsToEvaluateOnLoad.clear();
}
return url;
}
-void InspectorAgent::reloadPage(bool ignoreCache)
+void InspectorAgent::reloadPage(ErrorString*, bool ignoreCache)
{
m_inspectedPage->mainFrame()->loader()->reload(ignoreCache);
}
class WebSocketHandshakeResponse;
#endif
+typedef String ErrorString;
+
class InspectorAgent {
WTF_MAKE_NONCOPYABLE(InspectorAgent);
WTF_MAKE_FAST_ALLOCATED;
Page* inspectedPage() const { return m_inspectedPage; }
KURL inspectedURL() const;
KURL inspectedURLWithoutFragment() const;
- void reloadPage(bool ignoreCache);
+ void reloadPage(ErrorString* error, bool ignoreCache);
void showConsole();
void restoreInspectorStateFromCookie(const String& inspectorCookie);
- void highlight(Node*);
- void hideHighlight();
+ void highlight(ErrorString* error, Node*);
+ void hideHighlight(ErrorString* error);
void inspect(Node*);
- void highlightDOMNode(long nodeId);
- void hideDOMNodeHighlight() { hideHighlight(); }
+ void highlightDOMNode(ErrorString* error, long nodeId);
+ void hideDOMNodeHighlight(ErrorString* error) { hideHighlight(error); }
- void highlightFrame(unsigned long frameId);
- void hideFrameHighlight() { hideHighlight(); }
+ void highlightFrame(ErrorString* error, unsigned long frameId);
+ void hideFrameHighlight(ErrorString* error) { hideHighlight(error); }
void setFrontend(InspectorFrontend*);
InspectorFrontend* frontend() const { return m_frontend; }
void didCommitLoad(DocumentLoader*);
- void getCookies(RefPtr<InspectorArray>* cookies, WTF::String* cookiesString);
- void deleteCookie(const String& cookieName, const String& domain);
+ void getCookies(ErrorString* error, RefPtr<InspectorArray>* cookies, WTF::String* cookiesString);
+ void deleteCookie(ErrorString* error, const String& cookieName, const String& domain);
void domContentLoadedEventFired(DocumentLoader*, const KURL&);
void loadEventFired(DocumentLoader*, const KURL&);
bool hasFrontend() const { return m_frontend; }
void drawNodeHighlight(GraphicsContext&) const;
- void openInInspectedWindow(const String& url);
+ void openInInspectedWindow(ErrorString* error, const String& url);
void drawElementTitle(GraphicsContext&, const IntRect& boundingBox, const FloatRect& overlayRect, WebCore::Settings*) const;
#if ENABLE(JAVASCRIPT_DEBUGGER)
bool isRecordingUserInitiatedProfile() const;
- void startProfiling() { startUserInitiatedProfiling(); }
+ void startProfiling(ErrorString*) { startUserInitiatedProfiling(); }
void startUserInitiatedProfiling();
- void stopProfiling() { stopUserInitiatedProfiling(); }
+ void stopProfiling(ErrorString*) { stopUserInitiatedProfiling(); }
void stopUserInitiatedProfiling();
- void enableProfiler();
- void disableProfiler();
+ void enableProfiler(ErrorString* error);
+ void disableProfiler(ErrorString* error);
bool profilerEnabled() const;
void startUserInitiatedDebugging();
- void enableDebugger() { enableDebugger(false); }
+ void enableDebugger(ErrorString*) { enableDebugger(false); }
void enableDebugger(bool eraseStickyBreakpoints);
- void disableDebugger();
+ void disableDebugger(ErrorString* error);
bool debuggerEnabled() const { return m_debuggerAgent; }
- void resume();
#endif
// Generic code called from custom implementations.
void evaluateForTestInFrontend(long testCallId, const String& script);
- void addScriptToEvaluateOnLoad(const String& source);
- void removeAllScriptsToEvaluateOnLoad();
+ void addScriptToEvaluateOnLoad(ErrorString* error, const String& source);
+ void removeAllScriptsToEvaluateOnLoad(ErrorString* error);
void setInspectorExtensionAPI(const String& source);
InspectorState* state() { return m_state.get(); }
// InspectorAgent API
void getInspectorState(RefPtr<InspectorObject>* state);
void setMonitoringXHREnabled(bool enabled, bool* newState);
- void populateScriptObjects();
+ void populateScriptObjects(ErrorString* error);
// Following are used from InspectorBackend and internally.
- void setSearchingForNode(bool enabled, bool* newState);
- void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
+ void setSearchingForNode(ErrorString* error, bool enabled, bool* newState);
+ void didEvaluateForTestInFrontend(ErrorString* error, long callId, const String& jsonResult);
- void setUserAgentOverride(const String& userAgent);
+ void setUserAgentOverride(ErrorString* error, const String& userAgent);
void applyUserAgentOverride(String* userAgent) const;
private:
m_frontend->updateNetworkState(isNowOnline);
}
-void InspectorApplicationCacheAgent::getApplicationCaches(RefPtr<InspectorValue>* applicationCaches)
+void InspectorApplicationCacheAgent::getApplicationCaches(ErrorString*, RefPtr<InspectorValue>* applicationCaches)
{
if (m_documentLoader) {
ApplicationCacheHost* host = m_documentLoader->applicationCacheHost();
class InspectorValue;
class ResourceResponse;
+typedef String ErrorString;
+
class InspectorApplicationCacheAgent {
WTF_MAKE_NONCOPYABLE(InspectorApplicationCacheAgent); WTF_MAKE_FAST_ALLOCATED;
public:
void networkStateChanged();
// From Frontend
- void getApplicationCaches(RefPtr<InspectorValue>* applicationCaches);
+ void getApplicationCaches(ErrorString* error, RefPtr<InspectorValue>* applicationCaches);
private:
PassRefPtr<InspectorObject> buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList&, const ApplicationCacheHost::CacheInfo&);
#include "InspectorDOMAgent.h"
#include "InspectorDebuggerAgent.h"
#include "InspectorState.h"
+#include "InspectorValues.h"
#include <wtf/text/CString.h>
namespace {
{
}
-void InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints(PassRefPtr<InspectorObject> breakpoints)
+void InspectorBrowserDebuggerAgent::setAllBrowserBreakpoints(ErrorString*, PassRefPtr<InspectorObject> breakpoints)
{
m_inspectorAgent->state()->setObject(BrowserDebuggerAgentState::browserBreakpoints, breakpoints);
inspectedURLChanged(m_inspectorAgent->inspectedURLWithoutFragment());
if (!condition)
return;
+ ErrorString error;
if (type == eventListenerNativeBreakpointType) {
if (!enabled)
return;
String eventName;
if (!condition->getString("eventName", &eventName))
return;
- setEventListenerBreakpoint(eventName);
+ setEventListenerBreakpoint(&error, eventName);
} else if (type == xhrNativeBreakpointType) {
if (!enabled)
return;
String url;
if (!condition->getString("url", &url))
return;
- setXHRBreakpoint(url);
+ setXHRBreakpoint(&error, url);
}
}
m_domBreakpoints.clear();
}
-void InspectorBrowserDebuggerAgent::setEventListenerBreakpoint(const String& eventName)
+void InspectorBrowserDebuggerAgent::setEventListenerBreakpoint(ErrorString*, const String& eventName)
{
m_eventListenerBreakpoints.add(eventName);
}
-void InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint(const String& eventName)
+void InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint(ErrorString*, const String& eventName)
{
m_eventListenerBreakpoints.remove(eventName);
}
}
}
-void InspectorBrowserDebuggerAgent::setDOMBreakpoint(long nodeId, long type)
+void InspectorBrowserDebuggerAgent::setDOMBreakpoint(ErrorString*, long nodeId, long type)
{
Node* node = m_inspectorAgent->domAgent()->nodeForId(nodeId);
if (!node)
}
}
-void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(long nodeId, long type)
+void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(ErrorString*, long nodeId, long type)
{
Node* node = m_inspectorAgent->domAgent()->nodeForId(nodeId);
if (!node)
debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData.release());
}
-void InspectorBrowserDebuggerAgent::setXHRBreakpoint(const String& url)
+void InspectorBrowserDebuggerAgent::setXHRBreakpoint(ErrorString*, const String& url)
{
if (url.isEmpty())
m_hasXHRBreakpointWithEmptyURL = true;
m_XHRBreakpoints.add(url);
}
-void InspectorBrowserDebuggerAgent::removeXHRBreakpoint(const String& url)
+void InspectorBrowserDebuggerAgent::removeXHRBreakpoint(ErrorString*, const String& url)
{
if (url.isEmpty())
m_hasXHRBreakpointWithEmptyURL = false;
class InspectorObject;
class Node;
+typedef String ErrorString;
+
class InspectorBrowserDebuggerAgent {
WTF_MAKE_NONCOPYABLE(InspectorBrowserDebuggerAgent);
public:
virtual ~InspectorBrowserDebuggerAgent();
- void setAllBrowserBreakpoints(PassRefPtr<InspectorObject>);
+ void setAllBrowserBreakpoints(ErrorString* error, PassRefPtr<InspectorObject>);
void inspectedURLChanged(const String& url);
// BrowserDebugger API for InspectorFrontend
- void setXHRBreakpoint(const String& url);
- void removeXHRBreakpoint(const String& url);
- void setEventListenerBreakpoint(const String& eventName);
- void removeEventListenerBreakpoint(const String& eventName);
- void setDOMBreakpoint(long nodeId, long type);
- void removeDOMBreakpoint(long nodeId, long type);
+ void setXHRBreakpoint(ErrorString* error, const String& url);
+ void removeXHRBreakpoint(ErrorString* error, const String& url);
+ void setEventListenerBreakpoint(ErrorString* error, const String& eventName);
+ void removeEventListenerBreakpoint(ErrorString* error, const String& eventName);
+ void setDOMBreakpoint(ErrorString* error, long nodeId, long type);
+ void removeDOMBreakpoint(ErrorString* error, long nodeId, long type);
// InspectorInstrumentation API
void willInsertDOMNode(Node*, Node* parent);
m_documentToInspectorStyleSheet.clear();
}
-void InspectorCSSAgent::getStylesForNode(long nodeId, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::getStylesForNode(ErrorString*, long nodeId, RefPtr<InspectorValue>* result)
{
Element* element = elementForId(nodeId);
if (!element)
*result = resultObject.release();
}
-void InspectorCSSAgent::getInlineStyleForNode(long nodeId, RefPtr<InspectorValue>* style)
+void InspectorCSSAgent::getInlineStyleForNode(ErrorString*, long nodeId, RefPtr<InspectorValue>* style)
{
Element* element = elementForId(nodeId);
if (!element)
*style = styleSheet->buildObjectForStyle(element->style());
}
-void InspectorCSSAgent::getComputedStyleForNode(long nodeId, RefPtr<InspectorValue>* style)
+void InspectorCSSAgent::getComputedStyleForNode(ErrorString*, long nodeId, RefPtr<InspectorValue>* style)
{
Element* element = elementForId(nodeId);
if (!element)
*style = inspectorStyle->buildObjectForStyle();
}
-void InspectorCSSAgent::getAllStyles(RefPtr<InspectorArray>* styles)
+void InspectorCSSAgent::getAllStyles(ErrorString*, RefPtr<InspectorArray>* styles)
{
Vector<Document*> documents = m_domAgent->documents();
for (Vector<Document*>::iterator it = documents.begin(); it != documents.end(); ++it) {
}
}
-void InspectorCSSAgent::getStyleSheet(const String& styleSheetId, RefPtr<InspectorValue>* styleSheetObject)
+void InspectorCSSAgent::getStyleSheet(ErrorString*, const String& styleSheetId, RefPtr<InspectorValue>* styleSheetObject)
{
InspectorStyleSheet* inspectorStyleSheet = styleSheetForId(styleSheetId);
if (!inspectorStyleSheet)
*styleSheetObject = inspectorStyleSheet->buildObjectForStyleSheet();
}
-void InspectorCSSAgent::getStyleSheetText(const String& styleSheetId, String* url, String* result)
+void InspectorCSSAgent::getStyleSheetText(ErrorString*, const String& styleSheetId, String* url, String* result)
{
InspectorStyleSheet* inspectorStyleSheet = styleSheetForId(styleSheetId);
if (!inspectorStyleSheet)
inspectorStyleSheet->text(result);
}
-void InspectorCSSAgent::setStyleSheetText(const String& styleSheetId, const String& text, bool* success)
+void InspectorCSSAgent::setStyleSheetText(ErrorString*, const String& styleSheetId, const String& text, bool* success)
{
InspectorStyleSheet* inspectorStyleSheet = styleSheetForId(styleSheetId);
if (!inspectorStyleSheet) {
inspectorStyleSheet->reparseStyleSheet(text);
}
-void InspectorCSSAgent::setPropertyText(const RefPtr<InspectorObject>& fullStyleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::setPropertyText(ErrorString*, const RefPtr<InspectorObject>& fullStyleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result)
{
InspectorCSSId compoundId(fullStyleId);
ASSERT(!compoundId.isEmpty());
*result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
}
-void InspectorCSSAgent::toggleProperty(const RefPtr<InspectorObject>& fullStyleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::toggleProperty(ErrorString*, const RefPtr<InspectorObject>& fullStyleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result)
{
InspectorCSSId compoundId(fullStyleId);
ASSERT(!compoundId.isEmpty());
*result = inspectorStyleSheet->buildObjectForStyle(inspectorStyleSheet->styleForId(compoundId));
}
-void InspectorCSSAgent::setRuleSelector(const RefPtr<InspectorObject>& fullRuleId, const String& selector, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::setRuleSelector(ErrorString*, const RefPtr<InspectorObject>& fullRuleId, const String& selector, RefPtr<InspectorValue>* result)
{
InspectorCSSId compoundId(fullRuleId);
ASSERT(!compoundId.isEmpty());
*result = inspectorStyleSheet->buildObjectForRule(inspectorStyleSheet->ruleForId(compoundId));
}
-void InspectorCSSAgent::addRule(const long contextNodeId, const String& selector, RefPtr<InspectorValue>* result)
+void InspectorCSSAgent::addRule(ErrorString*, const long contextNodeId, const String& selector, RefPtr<InspectorValue>* result)
{
Node* node = m_domAgent->nodeForId(contextNodeId);
if (!node)
*result = inspectorStyleSheet->buildObjectForRule(newRule);
}
-void InspectorCSSAgent::getSupportedCSSProperties(RefPtr<InspectorArray>* cssProperties)
+void InspectorCSSAgent::getSupportedCSSProperties(ErrorString*, RefPtr<InspectorArray>* cssProperties)
{
RefPtr<InspectorArray> properties = InspectorArray::create();
for (int i = 0; i < numCSSProperties; ++i)
*cssProperties = properties.release();
}
-void InspectorCSSAgent::querySelectorAll(const long nodeId, const String& selector, RefPtr<InspectorArray>* result)
+void InspectorCSSAgent::querySelectorAll(ErrorString*, const long nodeId, const String& selector, RefPtr<InspectorArray>* result)
{
Node* node = m_domAgent->nodeForId(nodeId);
if (!node)
~InspectorCSSAgent();
void reset();
- void getStylesForNode(long nodeId, RefPtr<InspectorValue>* result);
- void getInlineStyleForNode(long nodeId, RefPtr<InspectorValue>* style);
- void getComputedStyleForNode(long nodeId, RefPtr<InspectorValue>* style);
- void getAllStyles(RefPtr<InspectorArray>* styles);
- void getStyleSheet(const String& styleSheetId, RefPtr<InspectorValue>* result);
- void getStyleSheetText(const String& styleSheetId, String* url, String* result);
- void setStyleSheetText(const String& styleSheetId, const String& text, bool* success);
- void setPropertyText(const RefPtr<InspectorObject>& styleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result);
- void toggleProperty(const RefPtr<InspectorObject>& styleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result);
- void setRuleSelector(const RefPtr<InspectorObject>& ruleId, const String& selector, RefPtr<InspectorValue>* result);
- void addRule(const long contextNodeId, const String& selector, RefPtr<InspectorValue>* result);
- void getSupportedCSSProperties(RefPtr<InspectorArray>* result);
- void querySelectorAll(const long nodeId, const String& selector, RefPtr<InspectorArray>* result);
+ void getStylesForNode(ErrorString* error, long nodeId, RefPtr<InspectorValue>* result);
+ void getInlineStyleForNode(ErrorString* error, long nodeId, RefPtr<InspectorValue>* style);
+ void getComputedStyleForNode(ErrorString* error, long nodeId, RefPtr<InspectorValue>* style);
+ void getAllStyles(ErrorString* error, RefPtr<InspectorArray>* styles);
+ void getStyleSheet(ErrorString* error, const String& styleSheetId, RefPtr<InspectorValue>* result);
+ void getStyleSheetText(ErrorString* error, const String& styleSheetId, String* url, String* result);
+ void setStyleSheetText(ErrorString* error, const String& styleSheetId, const String& text, bool* success);
+ void setPropertyText(ErrorString* error, const RefPtr<InspectorObject>& styleId, long propertyIndex, const String& text, bool overwrite, RefPtr<InspectorValue>* result);
+ void toggleProperty(ErrorString* error, const RefPtr<InspectorObject>& styleId, long propertyIndex, bool disable, RefPtr<InspectorValue>* result);
+ void setRuleSelector(ErrorString* error, const RefPtr<InspectorObject>& ruleId, const String& selector, RefPtr<InspectorValue>* result);
+ void addRule(ErrorString* error, const long contextNodeId, const String& selector, RefPtr<InspectorValue>* result);
+ void getSupportedCSSProperties(ErrorString* error, RefPtr<InspectorArray>* result);
+ void querySelectorAll(ErrorString* error, const long nodeId, const String& selector, RefPtr<InspectorArray>* result);
private:
typedef HashMap<String, RefPtr<InspectorStyleSheet> > IdToInspectorStyleSheet;
m_inspectorDOMAgent = 0;
}
-void InspectorConsoleAgent::setConsoleMessagesEnabled(bool enabled, bool* newState)
+void InspectorConsoleAgent::setConsoleMessagesEnabled(ErrorString*, bool enabled, bool* newState)
{
*newState = enabled;
setConsoleMessagesEnabled(enabled);
}
-void InspectorConsoleAgent::clearConsoleMessages()
+void InspectorConsoleAgent::clearConsoleMessages(ErrorString*)
{
m_consoleMessages.clear();
m_expiredConsoleMessageCount = 0;
void InspectorConsoleAgent::reset()
{
- clearConsoleMessages();
+ ErrorString error;
+ clearConsoleMessages(&error);
m_times.clear();
m_counts.clear();
}
addConsoleMessage(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier));
}
-void InspectorConsoleAgent::setMonitoringXHREnabled(bool enabled)
+void InspectorConsoleAgent::setMonitoringXHREnabled(ErrorString*, bool enabled)
{
m_inspectorState->setBoolean(ConsoleAgentState::monitoringXHR, enabled);
}
class ScriptCallStack;
class ScriptProfile;
+typedef String ErrorString;
+
class InspectorConsoleAgent {
WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
public:
InspectorConsoleAgent(InstrumentingAgents*, InspectorAgent*, InspectorState*, InjectedScriptHost*, InspectorDOMAgent*);
~InspectorConsoleAgent();
- void setConsoleMessagesEnabled(bool enabled, bool* newState);
- void clearConsoleMessages();
+ void setConsoleMessagesEnabled(ErrorString* error, bool enabled, bool* newState);
+ void clearConsoleMessages(ErrorString* error);
void reset();
void setFrontend(InspectorFrontend*);
void clearFrontend();
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
#endif
- void setMonitoringXHREnabled(bool enabled);
+ void setMonitoringXHREnabled(ErrorString* error, bool enabled);
private:
void setConsoleMessagesEnabled(bool);
void InspectorController::startTimelineProfiler()
{
- m_inspectorAgent->timelineAgent()->start();
+ ErrorString error;
+ m_inspectorAgent->timelineAgent()->start(&error);
}
void InspectorController::stopTimelineProfiler()
{
- m_inspectorAgent->timelineAgent()->stop();
+ ErrorString error;
+ m_inspectorAgent->timelineAgent()->stop(&error);
}
void InspectorController::connectFrontend()
void InspectorController::hideHighlight()
{
- m_inspectorAgent->hideHighlight();
+ ErrorString error;
+ m_inspectorAgent->hideHighlight(&error);
}
#if ENABLE(JAVASCRIPT_DEBUGGER)
void InspectorController::enableProfiler()
{
- m_inspectorAgent->enableProfiler();
+ ErrorString error;
+ m_inspectorAgent->enableProfiler(&error);
}
void InspectorController::disableProfiler()
{
- m_inspectorAgent->disableProfiler();
+ ErrorString error;
+ m_inspectorAgent->disableProfiler(&error);
}
bool InspectorController::profilerEnabled()
void InspectorController::disableDebugger()
{
- m_inspectorAgent->disableDebugger();
+ ErrorString error;
+ m_inspectorAgent->disableDebugger(&error);
}
void InspectorController::startUserInitiatedProfiling()
void InspectorController::resume()
{
- if (InspectorDebuggerAgent* debuggerAgent = m_inspectorAgent->debuggerAgent())
- debuggerAgent->resume();
+ if (InspectorDebuggerAgent* debuggerAgent = m_inspectorAgent->debuggerAgent()) {
+ ErrorString error;
+ debuggerAgent->resume(&error);
+ }
}
#endif
void InspectorDOMAgent::reset()
{
- searchCanceled();
+ ErrorString error;
+ searchCanceled(&error);
discardBindings();
if (m_revalidateStyleAttrTask)
m_revalidateStyleAttrTask->reset();
return 0;
}
-void InspectorDOMAgent::getChildNodes(long nodeId)
+void InspectorDOMAgent::getChildNodes(ErrorString*, long nodeId)
{
pushChildNodesToFrontend(nodeId);
}
return map->get(nodeToPush);
}
-void InspectorDOMAgent::setAttribute(long elementId, const String& name, const String& value, bool* success)
+void InspectorDOMAgent::setAttribute(ErrorString*, long elementId, const String& name, const String& value, bool* success)
{
Node* node = nodeForId(elementId);
if (node && (node->nodeType() == Node::ELEMENT_NODE)) {
}
}
-void InspectorDOMAgent::removeAttribute(long elementId, const String& name, bool* success)
+void InspectorDOMAgent::removeAttribute(ErrorString* error, long elementId, const String& name, bool* success)
{
Node* node = nodeForId(elementId);
if (node && (node->nodeType() == Node::ELEMENT_NODE)) {
}
}
-void InspectorDOMAgent::removeNode(long nodeId, long* outNodeId)
+void InspectorDOMAgent::removeNode(ErrorString*, long nodeId, long* outNodeId)
{
Node* node = nodeForId(nodeId);
if (!node)
*outNodeId = nodeId;
}
-void InspectorDOMAgent::changeTagName(long nodeId, const String& tagName, long* newId)
+void InspectorDOMAgent::changeTagName(ErrorString*, long nodeId, const String& tagName, long* newId)
{
Node* oldNode = nodeForId(nodeId);
if (!oldNode || !oldNode->isElementNode())
pushChildNodesToFrontend(*newId);
}
-void InspectorDOMAgent::getOuterHTML(long nodeId, WTF::String* outerHTML)
+void InspectorDOMAgent::getOuterHTML(ErrorString*, long nodeId, WTF::String* outerHTML)
{
Node* node = nodeForId(nodeId);
if (!node || !node->isHTMLElement())
*outerHTML = toHTMLElement(node)->outerHTML();
}
-void InspectorDOMAgent::setOuterHTML(long nodeId, const String& outerHTML, long* newId)
+void InspectorDOMAgent::setOuterHTML(ErrorString*, long nodeId, const String& outerHTML, long* newId)
{
Node* node = nodeForId(nodeId);
if (!node || !node->isHTMLElement())
pushChildNodesToFrontend(*newId);
}
-void InspectorDOMAgent::setTextNodeValue(long nodeId, const String& value, bool* success)
+void InspectorDOMAgent::setTextNodeValue(ErrorString*, long nodeId, const String& value, bool* success)
{
Node* node = nodeForId(nodeId);
if (node && (node->nodeType() == Node::TEXT_NODE)) {
}
}
-void InspectorDOMAgent::getEventListenersForNode(long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray)
+void InspectorDOMAgent::getEventListenersForNode(ErrorString*, long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray)
{
Node* node = nodeForId(nodeId);
*outNodeId = nodeId;
}
}
-void InspectorDOMAgent::addInspectedNode(long nodeId)
+void InspectorDOMAgent::addInspectedNode(ErrorString*, long nodeId)
{
m_inspectedNodes.prepend(nodeId);
while (m_inspectedNodes.size() > 5)
m_inspectedNodes.removeLast();
}
-void InspectorDOMAgent::performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously)
+void InspectorDOMAgent::performSearch(ErrorString* error, const String& whitespaceTrimmedQuery, bool runSynchronously)
{
// FIXME: Few things are missing here:
// 1) Search works with node granularity - number of matches within node is not calculated.
escapedTagNameQuery.replace("'", "\\'");
// Clear pending jobs.
- searchCanceled();
+ searchCanceled(error);
// Find all frames, iframes and object elements to search their documents.
Vector<Document*> docs = documents();
for (Deque<MatchJob*>::iterator it = m_pendingMatchJobs.begin(); it != m_pendingMatchJobs.end(); ++it)
(*it)->match(resultCollector);
reportNodesAsSearchResults(resultCollector);
- searchCanceled();
+ searchCanceled(error);
return;
}
m_matchJobsTimer.startOneShot(0);
}
-void InspectorDOMAgent::searchCanceled()
+void InspectorDOMAgent::searchCanceled(ErrorString*)
{
if (m_matchJobsTimer.isActive())
m_matchJobsTimer.stop();
m_searchResults.clear();
}
-void InspectorDOMAgent::resolveNode(long nodeId, RefPtr<InspectorValue>* result)
+void InspectorDOMAgent::resolveNode(ErrorString*, long nodeId, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = injectedScriptForNodeId(nodeId);
if (!injectedScript.hasNoValue())
injectedScript.resolveNode(nodeId, result);
}
-void InspectorDOMAgent::getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result)
+void InspectorDOMAgent::getNodeProperties(ErrorString*, long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = injectedScriptForNodeId(nodeId);
if (!injectedScript.hasNoValue())
injectedScript.getNodeProperties(nodeId, propertiesArray, result);
}
-void InspectorDOMAgent::getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result)
+void InspectorDOMAgent::getNodePrototypes(ErrorString*, long nodeId, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = injectedScriptForNodeId(nodeId);
if (!injectedScript.hasNoValue())
injectedScript.getNodePrototypes(nodeId, result);
}
-void InspectorDOMAgent::pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, long* nodeId)
+void InspectorDOMAgent::pushNodeToFrontend(ErrorString*, PassRefPtr<InspectorObject> objectId, long* nodeId)
{
InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(objectId.get());
Node* node = injectedScript.nodeForObjectId(objectId);
void InspectorDOMAgent::onMatchJobsTimer(Timer<InspectorDOMAgent>*)
{
if (!m_pendingMatchJobs.size()) {
- searchCanceled();
+ ErrorString error;
+ searchCanceled(&error);
return;
}
m_frontend->addNodesToSearchResult(nodeIds.release());
}
-void InspectorDOMAgent::copyNode(long nodeId)
+void InspectorDOMAgent::copyNode(ErrorString*, long nodeId)
{
Node* node = nodeForId(nodeId);
if (!node)
Pasteboard::generalPasteboard()->writePlainText(markup);
}
-void InspectorDOMAgent::pushNodeByPathToFrontend(const String& path, long* nodeId)
+void InspectorDOMAgent::pushNodeByPathToFrontend(ErrorString*, const String& path, long* nodeId)
{
if (Node* node = nodeForPath(path))
*nodeId = pushNodePathToFrontend(node);
class Page;
class RevalidateStyleAttributeTask;
+typedef String ErrorString;
+
#if ENABLE(INSPECTOR)
struct EventListenerInfo {
void reset();
// Methods called from the frontend for DOM nodes inspection.
- void getChildNodes(long nodeId);
- void setAttribute(long elementId, const String& name, const String& value, bool* success);
- void removeAttribute(long elementId, const String& name, bool* success);
- void removeNode(long nodeId, long* outNodeId);
- void changeTagName(long nodeId, const String& tagName, long* newId);
- void getOuterHTML(long nodeId, WTF::String* outerHTML);
- void setOuterHTML(long nodeId, const String& outerHTML, long* newId);
- void setTextNodeValue(long nodeId, const String& value, bool* success);
- void getEventListenersForNode(long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray);
- void addInspectedNode(long nodeId);
- void performSearch(const String& whitespaceTrimmedQuery, bool runSynchronously);
- void searchCanceled();
- void resolveNode(long nodeId, RefPtr<InspectorValue>* result);
- void getNodeProperties(long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result);
- void getNodePrototypes(long nodeId, RefPtr<InspectorValue>* result);
- void pushNodeToFrontend(PassRefPtr<InspectorObject> objectId, long* nodeId);
+ void getChildNodes(ErrorString* error, long nodeId);
+ void setAttribute(ErrorString* error, long elementId, const String& name, const String& value, bool* success);
+ void removeAttribute(ErrorString* error, long elementId, const String& name, bool* success);
+ void removeNode(ErrorString* error, long nodeId, long* outNodeId);
+ void changeTagName(ErrorString* error, long nodeId, const String& tagName, long* newId);
+ void getOuterHTML(ErrorString* error, long nodeId, WTF::String* outerHTML);
+ void setOuterHTML(ErrorString* error, long nodeId, const String& outerHTML, long* newId);
+ void setTextNodeValue(ErrorString* error, long nodeId, const String& value, bool* success);
+ void getEventListenersForNode(ErrorString* error, long nodeId, long* outNodeId, RefPtr<InspectorArray>* listenersArray);
+ void addInspectedNode(ErrorString* error, long nodeId);
+ void performSearch(ErrorString* error, const String& whitespaceTrimmedQuery, bool runSynchronously);
+ void searchCanceled(ErrorString* error);
+ void resolveNode(ErrorString* error, long nodeId, RefPtr<InspectorValue>* result);
+ void getNodeProperties(ErrorString* error, long nodeId, PassRefPtr<InspectorArray> propertiesArray, RefPtr<InspectorValue>* result);
+ void getNodePrototypes(ErrorString* error, long nodeId, RefPtr<InspectorValue>* result);
+ void pushNodeToFrontend(ErrorString* error, PassRefPtr<InspectorObject> objectId, long* nodeId);
// Methods called from the InspectorInstrumentation.
void setDocument(Document*);
Node* nodeForId(long nodeId);
long pushNodePathToFrontend(Node*);
void pushChildNodesToFrontend(long nodeId);
- void pushNodeByPathToFrontend(const String& path, long* nodeId);
+ void pushNodeByPathToFrontend(ErrorString* error, const String& path, long* nodeId);
void inspect(Node*);
long inspectedNode(unsigned long num);
- void copyNode(long nodeId);
+ void copyNode(ErrorString* error, long nodeId);
void setDOMListener(DOMListener*);
String documentURLString(Document*) const;
m_frontend = 0;
}
-void InspectorDOMStorageAgent::getDOMStorageEntries(long storageId, RefPtr<InspectorArray>* entries)
+void InspectorDOMStorageAgent::getDOMStorageEntries(ErrorString*, long storageId, RefPtr<InspectorArray>* entries)
{
InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
if (storageResource) {
}
}
-void InspectorDOMStorageAgent::setDOMStorageItem(long storageId, const String& key, const String& value, bool* success)
+void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString*, long storageId, const String& key, const String& value, bool* success)
{
InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
if (storageResource) {
}
}
-void InspectorDOMStorageAgent::removeDOMStorageItem(long storageId, const String& key, bool* success)
+void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString*, long storageId, const String& key, bool* success)
{
InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
if (storageResource) {
class Storage;
class StorageArea;
+typedef String ErrorString;
+
class InspectorDOMStorageAgent {
public:
static PassOwnPtr<InspectorDOMStorageAgent> create(InstrumentingAgents* instrumentingAgents)
void clearResources();
// Called from the front-end.
- void getDOMStorageEntries(long storageId, RefPtr<InspectorArray>* entries);
- void setDOMStorageItem(long storageId, const String& key, const String& value, bool* success);
- void removeDOMStorageItem(long storageId, const String& key, bool* success);
+ void getDOMStorageEntries(ErrorString* error, long storageId, RefPtr<InspectorArray>* entries);
+ void setDOMStorageItem(ErrorString* error, long storageId, const String& key, const String& value, bool* success);
+ void removeDOMStorageItem(ErrorString* error, long storageId, const String& key, bool* success);
// Called from the injected script.
void selectDOMStorage(Storage* storage);
m_frontendProvider.clear();
}
-void InspectorDatabaseAgent::getDatabaseTableNames(long databaseId, RefPtr<InspectorArray>* names)
+void InspectorDatabaseAgent::getDatabaseTableNames(ErrorString*, long databaseId, RefPtr<InspectorArray>* names)
{
Database* database = databaseForId(databaseId);
if (database) {
}
}
-void InspectorDatabaseAgent::executeSQL(long databaseId, const String& query, bool* success, long* transactionId)
+void InspectorDatabaseAgent::executeSQL(ErrorString*, long databaseId, const String& query, bool* success, long* transactionId)
{
Database* database = databaseForId(databaseId);
if (!database) {
class InspectorFrontend;
class InstrumentingAgents;
+typedef String ErrorString;
+
class InspectorDatabaseAgent {
public:
class FrontendProvider;
void clearResources();
// Called from the front-end.
- void getDatabaseTableNames(long databaseId, RefPtr<InspectorArray>* names);
- void executeSQL(long databaseId, const String& query, bool* success, long* transactionId);
+ void getDatabaseTableNames(ErrorString* error, long databaseId, RefPtr<InspectorArray>* names);
+ void executeSQL(ErrorString* error, long databaseId, const String& query, bool* success, long* transactionId);
// Called from the injected script.
Database* databaseForId(long databaseId);
m_pausedScriptState = 0;
}
-void InspectorDebuggerAgent::activateBreakpoints()
+void InspectorDebuggerAgent::activateBreakpoints(ErrorString*)
{
ScriptDebugServer::shared().activateBreakpoints();
}
-void InspectorDebuggerAgent::deactivateBreakpoints()
+void InspectorDebuggerAgent::deactivateBreakpoints(ErrorString*)
{
ScriptDebugServer::shared().deactivateBreakpoints();
}
m_breakpointIdToDebugServerBreakpointIds.clear();
}
-void InspectorDebuggerAgent::setJavaScriptBreakpoint(const String& url, int lineNumber, int columnNumber, const String& condition, bool enabled, String* outBreakpointId, RefPtr<InspectorArray>* locations)
+void InspectorDebuggerAgent::setJavaScriptBreakpoint(ErrorString*, const String& url, int lineNumber, int columnNumber, const String& condition, bool enabled, String* outBreakpointId, RefPtr<InspectorArray>* locations)
{
String breakpointId = makeString(url, ":", String::number(lineNumber), ":", String::number(columnNumber));
RefPtr<InspectorObject> breakpointsCookie = m_inspectorAgent->state()->getObject(DebuggerAgentState::javaScriptBreakpoints);
*outBreakpointId = breakpointId;
}
-void InspectorDebuggerAgent::setJavaScriptBreakpointBySourceId(const String& sourceId, int lineNumber, int columnNumber, const String& condition, bool enabled, String* outBreakpointId, int* actualLineNumber, int* actualColumnNumber)
+void InspectorDebuggerAgent::setJavaScriptBreakpointBySourceId(ErrorString*, const String& sourceId, int lineNumber, int columnNumber, const String& condition, bool enabled, String* outBreakpointId, int* actualLineNumber, int* actualColumnNumber)
{
String breakpointId = makeString(sourceId, ":", String::number(lineNumber), ":", String::number(columnNumber));
if (m_breakpointIdToDebugServerBreakpointIds.find(breakpointId) != m_breakpointIdToDebugServerBreakpointIds.end())
*outBreakpointId = breakpointId;
}
-void InspectorDebuggerAgent::removeJavaScriptBreakpoint(const String& breakpointId)
+void InspectorDebuggerAgent::removeJavaScriptBreakpoint(ErrorString*, const String& breakpointId)
{
RefPtr<InspectorObject> breakpointsCookie = m_inspectorAgent->state()->getObject(DebuggerAgentState::javaScriptBreakpoints);
breakpointsCookie->remove(breakpointId);
m_breakpointIdToDebugServerBreakpointIds.remove(debugServerBreakpointIdsIterator);
}
-void InspectorDebuggerAgent::continueToLocation(const String& sourceId, int lineNumber, int columnNumber)
+void InspectorDebuggerAgent::continueToLocation(ErrorString* error, const String& sourceId, int lineNumber, int columnNumber)
{
if (!m_continueToLocationBreakpointId.isEmpty()) {
ScriptDebugServer::shared().removeBreakpoint(m_continueToLocationBreakpointId);
}
ScriptBreakpoint breakpoint(lineNumber, columnNumber, "", true);
m_continueToLocationBreakpointId = ScriptDebugServer::shared().setBreakpoint(sourceId, breakpoint, &lineNumber, &columnNumber);
- resume();
+ resume(error);
}
bool InspectorDebuggerAgent::resolveBreakpoint(const String& breakpointId, const String& sourceId, const ScriptBreakpoint& breakpoint, int* actualLineNumber, int* actualColumnNumber)
return true;
}
-void InspectorDebuggerAgent::editScriptSource(const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames)
+void InspectorDebuggerAgent::editScriptSource(ErrorString*, const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames)
{
if ((*success = ScriptDebugServer::shared().editScriptSource(sourceID, newContent, *result)))
*newCallFrames = currentCallFrames();
}
-void InspectorDebuggerAgent::getScriptSource(const String& sourceID, String* scriptSource)
+void InspectorDebuggerAgent::getScriptSource(ErrorString*, const String& sourceID, String* scriptSource)
{
*scriptSource = m_scripts.get(sourceID).data;
}
ScriptDebugServer::shared().setPauseOnNextStatement(false);
}
-void InspectorDebuggerAgent::pause()
+void InspectorDebuggerAgent::pause(ErrorString*)
{
schedulePauseOnNextStatement(JavaScriptPauseEventType, InspectorObject::create());
m_javaScriptPauseScheduled = true;
}
-void InspectorDebuggerAgent::resume()
+void InspectorDebuggerAgent::resume(ErrorString*)
{
ScriptDebugServer::shared().continueProgram();
}
-void InspectorDebuggerAgent::stepOver()
+void InspectorDebuggerAgent::stepOver(ErrorString*)
{
ScriptDebugServer::shared().stepOverStatement();
}
-void InspectorDebuggerAgent::stepInto()
+void InspectorDebuggerAgent::stepInto(ErrorString*)
{
ScriptDebugServer::shared().stepIntoStatement();
}
-void InspectorDebuggerAgent::stepOut()
+void InspectorDebuggerAgent::stepOut(ErrorString*)
{
ScriptDebugServer::shared().stepOutOfFunction();
}
-void InspectorDebuggerAgent::setPauseOnExceptionsState(long pauseState, long* newState)
+void InspectorDebuggerAgent::setPauseOnExceptionsState(ErrorString*, long pauseState, long* newState)
{
ScriptDebugServer::shared().setPauseOnExceptionsState(static_cast<ScriptDebugServer::PauseOnExceptionsState>(pauseState));
*newState = ScriptDebugServer::shared().pauseOnExceptionsState();
}
-void InspectorDebuggerAgent::evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
+void InspectorDebuggerAgent::evaluateOnCallFrame(ErrorString*, PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = m_inspectorAgent->injectedScriptHost()->injectedScriptForObjectId(callFrameId.get());
if (!injectedScript.hasNoValue())
injectedScript.evaluateOnCallFrame(callFrameId, expression, objectGroup, includeCommandLineAPI, result);
}
-void InspectorDebuggerAgent::getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
+void InspectorDebuggerAgent::getCompletionsOnCallFrame(ErrorString*, PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = m_inspectorAgent->injectedScriptHost()->injectedScriptForObjectId(callFrameId.get());
if (!injectedScript.hasNoValue())
#include <wtf/text/StringHash.h>
namespace WebCore {
+
class InjectedScriptHost;
class InspectorAgent;
class InspectorFrontend;
class InspectorObject;
class InspectorValue;
+typedef String ErrorString;
+
enum DebuggerEventType {
JavaScriptPauseEventType,
JavaScriptBreakpointEventType,
void inspectedURLChanged(const String& url);
// Part of the protocol.
- void activateBreakpoints();
- void deactivateBreakpoints();
+ void activateBreakpoints(ErrorString* error);
+ void deactivateBreakpoints(ErrorString* error);
- void setJavaScriptBreakpoint(const String& url, int lineNumber, int columnNumber, const String& condition, bool enabled, String* breakpointId, RefPtr<InspectorArray>* locations);
- void setJavaScriptBreakpointBySourceId(const String& sourceId, int lineNumber, int columnNumber, const String& condition, bool enabled, String* breakpointId, int* actualLineNumber, int* actualColumnNumber);
- void removeJavaScriptBreakpoint(const String& breakpointId);
- void continueToLocation(const String& sourceId, int lineNumber, int columnNumber);
+ void setJavaScriptBreakpoint(ErrorString* error, const String& url, int lineNumber, int columnNumber, const String& condition, bool enabled, String* breakpointId, RefPtr<InspectorArray>* locations);
+ void setJavaScriptBreakpointBySourceId(ErrorString* error, const String& sourceId, int lineNumber, int columnNumber, const String& condition, bool enabled, String* breakpointId, int* actualLineNumber, int* actualColumnNumber);
+ void removeJavaScriptBreakpoint(ErrorString* error, const String& breakpointId);
+ void continueToLocation(ErrorString* error, const String& sourceId, int lineNumber, int columnNumber);
- void editScriptSource(const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames);
- void getScriptSource(const String& sourceID, String* scriptSource);
+ void editScriptSource(ErrorString* error, const String& sourceID, const String& newContent, bool* success, String* result, RefPtr<InspectorValue>* newCallFrames);
+ void getScriptSource(ErrorString* error, const String& sourceID, String* scriptSource);
void schedulePauseOnNextStatement(DebuggerEventType type, PassRefPtr<InspectorValue> data);
void cancelPauseOnNextStatement();
void breakProgram(DebuggerEventType type, PassRefPtr<InspectorValue> data);
- void pause();
- void resume();
- void stepOver();
- void stepInto();
- void stepOut();
- void setPauseOnExceptionsState(long pauseState, long* newState);
- void evaluateOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
- void getCompletionsOnCallFrame(PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
+ void pause(ErrorString* error);
+ void resume(ErrorString* error);
+ void stepOver(ErrorString* error);
+ void stepInto(ErrorString* error);
+ void stepOut(ErrorString* error);
+ void setPauseOnExceptionsState(ErrorString* error, long pauseState, long* newState);
+ void evaluateOnCallFrame(ErrorString* error, PassRefPtr<InspectorObject> callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
+ void getCompletionsOnCallFrame(ErrorString* error, PassRefPtr<InspectorObject> callFrameId, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
private:
InspectorDebuggerAgent(InspectorAgent*, InspectorFrontend*, bool eraseStickyBreakpoints);
return makeString(UserInitiatedProfileName, '.', String::number(m_currentUserInitiatedProfileNumber));
}
-void InspectorProfilerAgent::getProfileHeaders(RefPtr<InspectorArray>* headers)
+void InspectorProfilerAgent::getProfileHeaders(ErrorString*, RefPtr<InspectorArray>* headers)
{
ProfilesMap::iterator profilesEnd = m_profiles.end();
for (ProfilesMap::iterator it = m_profiles.begin(); it != profilesEnd; ++it)
} // namespace
-void InspectorProfilerAgent::getProfile(const String& type, unsigned uid, RefPtr<InspectorObject>* profileObject)
+void InspectorProfilerAgent::getProfile(ErrorString*, const String& type, unsigned uid, RefPtr<InspectorObject>* profileObject)
{
if (type == CPUProfileType) {
ProfilesMap::iterator it = m_profiles.find(uid);
}
}
-void InspectorProfilerAgent::removeProfile(const String& type, unsigned uid)
+void InspectorProfilerAgent::removeProfile(ErrorString*, const String& type, unsigned uid)
{
if (type == CPUProfileType) {
if (m_profiles.contains(uid))
};
-void InspectorProfilerAgent::takeHeapSnapshot(bool detailed)
+void InspectorProfilerAgent::takeHeapSnapshot(ErrorString*, bool detailed)
{
String title = makeString(UserInitiatedProfileName, '.', String::number(m_nextUserInitiatedHeapSnapshotNumber));
++m_nextUserInitiatedHeapSnapshotNumber;
class ScriptHeapSnapshot;
class ScriptProfile;
+typedef String ErrorString;
+
class InspectorProfilerAgent {
WTF_MAKE_NONCOPYABLE(InspectorProfilerAgent); WTF_MAKE_FAST_ALLOCATED;
public:
void addProfile(PassRefPtr<ScriptProfile> prpProfile, unsigned lineNumber, const String& sourceURL);
void addProfileFinishedMessageToConsole(PassRefPtr<ScriptProfile>, unsigned lineNumber, const String& sourceURL);
void addStartProfilingMessageToConsole(const String& title, unsigned lineNumber, const String& sourceURL);
- void clearProfiles() { resetState(); }
+ void clearProfiles(ErrorString*) { resetState(); }
void disable();
void enable(bool skipRecompile);
bool enabled() { return m_enabled; }
String getCurrentUserInitiatedProfileName(bool incrementProfileNumber = false);
- void getProfileHeaders(RefPtr<InspectorArray>* headers);
- void getProfile(const String& type, unsigned uid, RefPtr<InspectorObject>* profileObject);
+ void getProfileHeaders(ErrorString* error, RefPtr<InspectorArray>* headers);
+ void getProfile(ErrorString* error, const String& type, unsigned uid, RefPtr<InspectorObject>* profileObject);
bool isRecordingUserInitiatedProfile() { return m_recordingUserInitiatedProfile; }
- void removeProfile(const String& type, unsigned uid);
+ void removeProfile(ErrorString* error, const String& type, unsigned uid);
void resetState();
void resetFrontendProfiles();
void setFrontend(InspectorFrontend* frontend) { m_frontend = frontend; }
void startUserInitiatedProfiling();
void stopUserInitiatedProfiling(bool ignoreProfile = false);
- void takeHeapSnapshot(bool detailed);
+ void takeHeapSnapshot(ErrorString* error, bool detailed);
void toggleRecordButton(bool isProfiling);
private:
m_frontend->identifierForInitialRequest(identifier, url.string(), loaderObject, callStackValue);
}
-void InspectorResourceAgent::setExtraHeaders(PassRefPtr<InspectorObject> headers)
+void InspectorResourceAgent::setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject> headers)
{
m_state->setObject(ResourceAgentState::extraRequestHeaders, headers);
}
return 0;
}
-void InspectorResourceAgent::cachedResources(RefPtr<InspectorObject>* object)
+void InspectorResourceAgent::cachedResources(ErrorString* error, RefPtr<InspectorObject>* object)
{
*object = buildObjectForFrameTree(m_page->mainFrame(), true);
}
-void InspectorResourceAgent::resourceContent(unsigned long frameId, const String& url, bool base64Encode, bool* success, String* content)
+void InspectorResourceAgent::resourceContent(ErrorString*, unsigned long frameId, const String& url, bool base64Encode, bool* success, String* content)
{
Frame* frame = frameForId(frameId);
if (!frame) {
class WebSocketHandshakeResponse;
#endif
+typedef String ErrorString;
+
class InspectorResourceAgent : public RefCounted<InspectorResourceAgent> {
public:
static PassRefPtr<InspectorResourceAgent> create(Page* page, InspectorState* state, InspectorFrontend* frontend)
Frame* frameForId(unsigned long);
// Called from frontend
- void cachedResources(RefPtr<InspectorObject>*);
- void resourceContent(unsigned long frameId, const String& url, bool base64Encode, bool* resourceFound, String* content);
- void setExtraHeaders(PassRefPtr<InspectorObject>);
+ void cachedResources(ErrorString* error, RefPtr<InspectorObject>*);
+ void resourceContent(ErrorString* error, unsigned long frameId, const String& url, bool base64Encode, bool* resourceFound, String* content);
+ void setExtraHeaders(ErrorString* error, PassRefPtr<InspectorObject>);
private:
InspectorResourceAgent(Page* page, InspectorState*, InspectorFrontend* frontend);
InspectorRuntimeAgent::~InspectorRuntimeAgent() { }
-void InspectorRuntimeAgent::evaluate(const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
+void InspectorRuntimeAgent::evaluate(ErrorString* error, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForMainFrame();
if (!injectedScript.hasNoValue())
injectedScript.evaluate(expression, objectGroup, includeCommandLineAPI, result);
}
-void InspectorRuntimeAgent::getCompletions(const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
+void InspectorRuntimeAgent::getCompletions(ErrorString*, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForMainFrame();
if (!injectedScript.hasNoValue())
injectedScript.getCompletions(expression, includeCommandLineAPI, result);
}
-void InspectorRuntimeAgent::getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result)
+void InspectorRuntimeAgent::getProperties(ErrorString*, PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(objectId.get());
if (!injectedScript.hasNoValue())
injectedScript.getProperties(objectId, ignoreHasOwnProperty, abbreviate, result);
}
-void InspectorRuntimeAgent::setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result)
+void InspectorRuntimeAgent::setPropertyValue(ErrorString*, PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result)
{
InjectedScript injectedScript = m_injectedScriptHost->injectedScriptForObjectId(objectId.get());
if (!injectedScript.hasNoValue())
injectedScript.setPropertyValue(objectId, propertyName, expression, result);
}
-void InspectorRuntimeAgent::releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup)
+void InspectorRuntimeAgent::releaseWrapperObjectGroup(ErrorString*, long injectedScriptId, const String& objectGroup)
{
m_injectedScriptHost->releaseWrapperObjectGroup(injectedScriptId, objectGroup);
}
class InspectorObject;
class InspectorValue;
+typedef String ErrorString;
+
class InspectorRuntimeAgent {
WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
public:
~InspectorRuntimeAgent();
// Part of the protocol.
- void evaluate(const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
- void getCompletions(const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
- void getProperties(PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result);
- void setPropertyValue(PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result);
- void releaseWrapperObjectGroup(long injectedScriptId, const String& objectGroup);
+ void evaluate(ErrorString* error, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
+ void getCompletions(ErrorString* error, const String& expression, bool includeCommandLineAPI, RefPtr<InspectorValue>* result);
+ void getProperties(ErrorString* error, PassRefPtr<InspectorObject> objectId, bool ignoreHasOwnProperty, bool abbreviate, RefPtr<InspectorValue>* result);
+ void setPropertyValue(ErrorString* error, PassRefPtr<InspectorObject> objectId, const String& propertyName, const String& expression, RefPtr<InspectorValue>* result);
+ void releaseWrapperObjectGroup(ErrorString* error, long injectedScriptId, const String& objectGroup);
private:
InspectorRuntimeAgent(InjectedScriptHost*);
void InspectorTimelineAgent::clearFrontend()
{
- stop();
+ ErrorString error;
+ stop(&error);
m_frontend = 0;
}
void InspectorTimelineAgent::restore(InspectorState* state, InspectorFrontend* frontend)
{
setFrontend(frontend);
- if (state->getBoolean(TimelineAgentState::timelineAgentEnabled))
- start();
+ if (state->getBoolean(TimelineAgentState::timelineAgentEnabled)) {
+ ErrorString error;
+ start(&error);
+ }
}
-void InspectorTimelineAgent::start()
+void InspectorTimelineAgent::start(ErrorString*)
{
if (!m_frontend)
return;
m_state->setBoolean(TimelineAgentState::timelineAgentEnabled, true);
}
-void InspectorTimelineAgent::stop()
+void InspectorTimelineAgent::stop(ErrorString*)
{
if (!started())
return;
class ResourceRequest;
class ResourceResponse;
+typedef String ErrorString;
+
// Must be kept in sync with TimelineAgent.js
enum TimelineRecordType {
EventDispatchTimelineRecordType = 0,
void restore(InspectorState*, InspectorFrontend*);
- void start();
- void stop();
+ void start(ErrorString* error);
+ void stop(ErrorString* error);
bool started() const;
int id() const { return m_id; }