Web Inspector: use single method for retrieving evaluation context in the runtime...
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2012 14:36:43 +0000 (14:36 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 May 2012 14:36:43 +0000 (14:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=85621

Reviewed by Pavel Feldman.

Merged two script state retrieval methods into one. Moved Page specific logic
into PageRuntimeAgent.

* inspector/InspectorRuntimeAgent.cpp:
(WebCore::InspectorRuntimeAgent::evaluate):
* inspector/InspectorRuntimeAgent.h:
(InspectorRuntimeAgent):
* inspector/PageRuntimeAgent.cpp:
(WebCore::PageRuntimeAgent::scriptStateForEval):
* inspector/PageRuntimeAgent.h:
(PageRuntimeAgent):
* inspector/WorkerRuntimeAgent.cpp:
(WebCore::WorkerRuntimeAgent::scriptStateForEval):
* inspector/WorkerRuntimeAgent.h:
(WorkerRuntimeAgent):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@116099 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorRuntimeAgent.cpp
Source/WebCore/inspector/InspectorRuntimeAgent.h
Source/WebCore/inspector/PageRuntimeAgent.cpp
Source/WebCore/inspector/PageRuntimeAgent.h
Source/WebCore/inspector/WorkerRuntimeAgent.cpp
Source/WebCore/inspector/WorkerRuntimeAgent.h

index 6a67b93..b178039 100644 (file)
@@ -1,3 +1,26 @@
+2012-05-04  Yury Semikhatsky  <yurys@chromium.org>
+
+        Web Inspector: use single method for retrieving evaluation context in the runtime agent
+        https://bugs.webkit.org/show_bug.cgi?id=85621
+
+        Reviewed by Pavel Feldman.
+
+        Merged two script state retrieval methods into one. Moved Page specific logic
+        into PageRuntimeAgent.
+
+        * inspector/InspectorRuntimeAgent.cpp:
+        (WebCore::InspectorRuntimeAgent::evaluate):
+        * inspector/InspectorRuntimeAgent.h:
+        (InspectorRuntimeAgent):
+        * inspector/PageRuntimeAgent.cpp:
+        (WebCore::PageRuntimeAgent::scriptStateForEval):
+        * inspector/PageRuntimeAgent.h:
+        (PageRuntimeAgent):
+        * inspector/WorkerRuntimeAgent.cpp:
+        (WebCore::WorkerRuntimeAgent::scriptStateForEval):
+        * inspector/WorkerRuntimeAgent.h:
+        (WorkerRuntimeAgent):
+
 2012-05-04  Jochen Eisinger  <jochen@chromium.org>
 
         Unreviewed, rolling out r115549.
 2012-05-04  Jochen Eisinger  <jochen@chromium.org>
 
         Unreviewed, rolling out r115549.
index ad6c8c6..bbd7ce8 100644 (file)
@@ -85,15 +85,9 @@ static ScriptDebugServer::PauseOnExceptionsState setPauseOnExceptionsState(Scrip
 
 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const String* const frameId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
 {
 
 void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptionsAndMuteConsole, const String* const frameId, const bool* const returnByValue, RefPtr<TypeBuilder::Runtime::RemoteObject>& result, TypeBuilder::OptOutput<bool>* wasThrown)
 {
-    ScriptState* scriptState = 0;
-    if (frameId) {
-        scriptState = scriptStateForFrameId(*frameId);
-        if (!scriptState) {
-            *errorString = "Frame with given id not found.";
-            return;
-        }
-    } else
-        scriptState = getDefaultInspectedState();
+    ScriptState* scriptState = scriptStateForEval(errorString, frameId);
+    if (!scriptState)
+        return;
     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
     if (injectedScript.hasNoValue()) {
         *errorString = "Inspected frame has gone";
     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
     if (injectedScript.hasNoValue()) {
         *errorString = "Inspected frame has gone";
index 8280ae2..e8e3bab 100644 (file)
@@ -88,8 +88,8 @@ public:
 
 protected:
     InspectorRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
 
 protected:
     InspectorRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*);
-    virtual ScriptState* scriptStateForFrameId(const String& frameId) = 0;
-    virtual ScriptState* getDefaultInspectedState() = 0;
+    virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId) = 0;
+
     virtual void muteConsole() = 0;
     virtual void unmuteConsole() = 0;
 
     virtual void muteConsole() = 0;
     virtual void unmuteConsole() = 0;
 
index 9284f39..caa1ed9 100644 (file)
@@ -52,19 +52,19 @@ PageRuntimeAgent::~PageRuntimeAgent()
 {
 }
 
 {
 }
 
-ScriptState* PageRuntimeAgent::scriptStateForFrameId(const String& frameId)
+ScriptState* PageRuntimeAgent::scriptStateForEval(ErrorString* errorString, const String* frameId)
 {
 {
-    Frame* frame = m_pageAgent->frameForId(frameId);
-    if (!frame)
+    if (!frameId)
+        return mainWorldScriptState(m_inspectedPage->mainFrame());
+
+    Frame* frame = m_pageAgent->frameForId(*frameId);
+    if (!frame) {
+        *errorString = "Frame with given id not found.";
         return 0;
         return 0;
+    }
     return mainWorldScriptState(frame);
 }
 
     return mainWorldScriptState(frame);
 }
 
-ScriptState* PageRuntimeAgent::getDefaultInspectedState()
-{
-    return mainWorldScriptState(m_inspectedPage->mainFrame());
-}
-
 void PageRuntimeAgent::muteConsole()
 {
     Console::mute();
 void PageRuntimeAgent::muteConsole()
 {
     Console::mute();
index 32614a8..e806ed3 100644 (file)
@@ -52,8 +52,7 @@ public:
 private:
     PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*);
 
 private:
     PageRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, Page*, InspectorPageAgent*);
 
-    virtual ScriptState* scriptStateForFrameId(const String& frameId);
-    virtual ScriptState* getDefaultInspectedState();
+    virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId);
     virtual void muteConsole();
     virtual void unmuteConsole();
     Page* m_inspectedPage;
     virtual void muteConsole();
     virtual void unmuteConsole();
     Page* m_inspectedPage;
index 1c4457e..1d82e59 100644 (file)
@@ -48,13 +48,12 @@ WorkerRuntimeAgent::~WorkerRuntimeAgent()
 {
 }
 
 {
 }
 
-ScriptState* WorkerRuntimeAgent::scriptStateForFrameId(const String&)
-{
-    return 0;
-}
-
-ScriptState* WorkerRuntimeAgent::getDefaultInspectedState()
+ScriptState* WorkerRuntimeAgent::scriptStateForEval(ErrorString* error, const String* frameId)
 {
 {
+    if (frameId) {
+        *error = "Frame id is not supported for workers.";
+        return 0;
+    }
     return scriptStateFromWorkerContext(m_workerContext);
 }
 
     return scriptStateFromWorkerContext(m_workerContext);
 }
 
index ccfe1fb..24f56af 100644 (file)
@@ -50,8 +50,7 @@ public:
 
 private:
     WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
 
 private:
     WorkerRuntimeAgent(InstrumentingAgents*, InspectorState*, InjectedScriptManager*, WorkerContext*);
-    virtual ScriptState* scriptStateForFrameId(const String& frameId);
-    virtual ScriptState* getDefaultInspectedState();
+    virtual ScriptState* scriptStateForEval(ErrorString*, const String* frameId);
     virtual void muteConsole();
     virtual void unmuteConsole();
     WorkerContext* m_workerContext;
     virtual void muteConsole();
     virtual void unmuteConsole();
     WorkerContext* m_workerContext;