Commit 90c7c336 authored by yurys@chromium.org's avatar yurys@chromium.org

2011-04-04 Yury Semikhatsky <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: InspectorRuntimeAgent should not depend on Page
        https://bugs.webkit.org/show_bug.cgi?id=57759

        Descendants of InspectorRuntimeAgent should implement a method providing access to the default
        inspected state used for console evaluations.

        * inspector/InspectorAgent.cpp:
        (WebCore::InspectorAgent::InspectorAgent): runtime agent is created and deleted along with other agents.
        (WebCore::InspectorAgent::setFrontend):
        * inspector/InspectorAgent.h:
        * inspector/InspectorRuntimeAgent.cpp:
        (WebCore::InspectorRuntimeAgent::create):
        (WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
        (WebCore::InspectorRuntimeAgent::evaluate):
        * inspector/InspectorRuntimeAgent.h:
        (WebCore::InspectorRuntimeAgent::InspectedStateProvider::~InspectedStateProvider):

git-svn-id: svn://svn.chromium.org/blink/trunk@82845 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent c7c047aa
2011-04-04 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Pavel Feldman.
Web Inspector: InspectorRuntimeAgent should not depend on Page
https://bugs.webkit.org/show_bug.cgi?id=57759
Descendants of InspectorRuntimeAgent should implement a method providing access to the default
inspected state used for console evaluations.
* inspector/InspectorAgent.cpp:
(WebCore::InspectorAgent::InspectorAgent): runtime agent is created and deleted along with other agents.
(WebCore::InspectorAgent::setFrontend):
* inspector/InspectorAgent.h:
* inspector/InspectorRuntimeAgent.cpp:
(WebCore::InspectorRuntimeAgent::create):
(WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
(WebCore::InspectorRuntimeAgent::evaluate):
* inspector/InspectorRuntimeAgent.h:
(WebCore::InspectorRuntimeAgent::InspectedStateProvider::~InspectedStateProvider):
2011-04-04 Yong Li <yoli@rim.com> 2011-04-04 Yong Li <yoli@rim.com>
Reviewed by Antonio Gomes. Reviewed by Antonio Gomes.
...@@ -89,6 +89,22 @@ static const char scriptsPanelName[] = "scripts"; ...@@ -89,6 +89,22 @@ static const char scriptsPanelName[] = "scripts";
static const char consolePanelName[] = "console"; static const char consolePanelName[] = "console";
static const char profilesPanelName[] = "profiles"; static const char profilesPanelName[] = "profiles";
namespace {
class PageRuntimeAgent : public InspectorRuntimeAgent {
public:
PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* page)
: InspectorRuntimeAgent(injectedScriptManager)
, m_inspectedPage(page) { }
virtual ~PageRuntimeAgent() { }
private:
virtual ScriptState* getDefaultInspectedState() { return mainWorldScriptState(m_inspectedPage->mainFrame()); }
Page* m_inspectedPage;
};
}
InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScriptManager* injectedScriptManager) InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScriptManager* injectedScriptManager)
: m_inspectedPage(page) : m_inspectedPage(page)
, m_client(client) , m_client(client)
...@@ -110,6 +126,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri ...@@ -110,6 +126,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri
, m_applicationCacheAgent(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), page)) , m_applicationCacheAgent(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), page))
#endif #endif
, m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), page, m_state.get())) , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), page, m_state.get()))
, m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_injectedScriptManager, page)))
, m_consoleAgent(new InspectorConsoleAgent(m_instrumentingAgents.get(), this, m_state.get(), injectedScriptManager, m_domAgent.get())) , m_consoleAgent(new InspectorConsoleAgent(m_instrumentingAgents.get(), this, m_state.get(), injectedScriptManager, m_domAgent.get()))
#if ENABLE(JAVASCRIPT_DEBUGGER) #if ENABLE(JAVASCRIPT_DEBUGGER)
, m_debuggerAgent(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, injectedScriptManager)) , m_debuggerAgent(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, injectedScriptManager))
...@@ -162,7 +179,6 @@ void InspectorAgent::inspectedPageDestroyed() ...@@ -162,7 +179,6 @@ void InspectorAgent::inspectedPageDestroyed()
InspectorInstrumentation::unbindInspectorAgent(m_inspectedPage); InspectorInstrumentation::unbindInspectorAgent(m_inspectedPage);
m_inspectedPage = 0; m_inspectedPage = 0;
releaseFrontendLifetimeAgents();
m_injectedScriptManager->disconnect(); m_injectedScriptManager->disconnect();
m_client->inspectorDestroyed(); m_client->inspectorDestroyed();
...@@ -201,7 +217,6 @@ void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend) ...@@ -201,7 +217,6 @@ void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
m_state->unmute(); m_state->unmute();
m_frontend = inspectorFrontend; m_frontend = inspectorFrontend;
createFrontendLifetimeAgents();
#if ENABLE(OFFLINE_WEB_APPLICATIONS) #if ENABLE(OFFLINE_WEB_APPLICATIONS)
m_applicationCacheAgent->setFrontend(m_frontend); m_applicationCacheAgent->setFrontend(m_frontend);
...@@ -272,18 +287,6 @@ void InspectorAgent::disconnectFrontend() ...@@ -272,18 +287,6 @@ void InspectorAgent::disconnectFrontend()
m_domStorageAgent->clearFrontend(); m_domStorageAgent->clearFrontend();
#endif #endif
m_pageAgent->clearFrontend(); m_pageAgent->clearFrontend();
releaseFrontendLifetimeAgents();
}
void InspectorAgent::createFrontendLifetimeAgents()
{
m_runtimeAgent = InspectorRuntimeAgent::create(m_injectedScriptManager, m_inspectedPage);
}
void InspectorAgent::releaseFrontendLifetimeAgents()
{
m_runtimeAgent.clear();
} }
void InspectorAgent::didCommitLoad() void InspectorAgent::didCommitLoad()
......
...@@ -177,9 +177,6 @@ private: ...@@ -177,9 +177,6 @@ private:
void showPanel(const String& panel); void showPanel(const String& panel);
void unbindAllResources(); void unbindAllResources();
void releaseFrontendLifetimeAgents();
void createFrontendLifetimeAgents();
#if ENABLE(JAVASCRIPT_DEBUGGER) #if ENABLE(JAVASCRIPT_DEBUGGER)
void toggleRecordButton(bool); void toggleRecordButton(bool);
#endif #endif
......
...@@ -36,20 +36,12 @@ ...@@ -36,20 +36,12 @@
#include "InjectedScript.h" #include "InjectedScript.h"
#include "InjectedScriptManager.h" #include "InjectedScriptManager.h"
#include "InspectorValues.h" #include "InspectorValues.h"
#include "Page.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h> #include <wtf/PassRefPtr.h>
namespace WebCore { namespace WebCore {
PassOwnPtr<InspectorRuntimeAgent> InspectorRuntimeAgent::create(InjectedScriptManager* injectedScriptManager, Page* inspectedPage) InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager)
{
return adoptPtr(new InspectorRuntimeAgent(injectedScriptManager, inspectedPage));
}
InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* inspectedPage)
: m_injectedScriptManager(injectedScriptManager) : m_injectedScriptManager(injectedScriptManager)
, m_inspectedPage(inspectedPage)
{ {
} }
...@@ -59,8 +51,7 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent() ...@@ -59,8 +51,7 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent()
void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, const bool* const optionalIncludeCommandLineAPI, RefPtr<InspectorObject>* result) void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, const bool* const optionalIncludeCommandLineAPI, RefPtr<InspectorObject>* result)
{ {
ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame()); InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(getDefaultInspectedState());
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
if (!injectedScript.hasNoValue()) if (!injectedScript.hasNoValue())
injectedScript.evaluate(errorString, expression, objectGroup, optionalIncludeCommandLineAPI ? *optionalIncludeCommandLineAPI : false, result); injectedScript.evaluate(errorString, expression, objectGroup, optionalIncludeCommandLineAPI ? *optionalIncludeCommandLineAPI : false, result);
} }
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#if ENABLE(INSPECTOR) #if ENABLE(INSPECTOR)
#include "ScriptState.h"
#include <wtf/Forward.h> #include <wtf/Forward.h>
#include <wtf/Noncopyable.h> #include <wtf/Noncopyable.h>
...@@ -42,15 +43,13 @@ class InjectedScriptManager; ...@@ -42,15 +43,13 @@ class InjectedScriptManager;
class InspectorArray; class InspectorArray;
class InspectorObject; class InspectorObject;
class InspectorValue; class InspectorValue;
class Page;
typedef String ErrorString; typedef String ErrorString;
class InspectorRuntimeAgent { class InspectorRuntimeAgent {
WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent); WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
public: public:
static PassOwnPtr<InspectorRuntimeAgent> create(InjectedScriptManager*, Page*); virtual ~InspectorRuntimeAgent();
~InspectorRuntimeAgent();
// Part of the protocol. // Part of the protocol.
void evaluate(ErrorString*, const String& expression, const String& objectGroup, const bool* const optionalIncludeCommandLineAPI, RefPtr<InspectorObject>* result); void evaluate(ErrorString*, const String& expression, const String& objectGroup, const bool* const optionalIncludeCommandLineAPI, RefPtr<InspectorObject>* result);
...@@ -60,11 +59,12 @@ public: ...@@ -60,11 +59,12 @@ public:
void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& expression); void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& expression);
void releaseObjectGroup(ErrorString*, const String& objectGroup); void releaseObjectGroup(ErrorString*, const String& objectGroup);
private: protected:
InspectorRuntimeAgent(InjectedScriptManager*, Page*); explicit InspectorRuntimeAgent(InjectedScriptManager*);
virtual ScriptState* getDefaultInspectedState() = 0;
private:
InjectedScriptManager* m_injectedScriptManager; InjectedScriptManager* m_injectedScriptManager;
Page* m_inspectedPage;
}; };
} // namespace WebCore } // namespace WebCore
......
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