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>
Reviewed by Antonio Gomes.
......@@ -89,6 +89,22 @@ static const char scriptsPanelName[] = "scripts";
static const char consolePanelName[] = "console";
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)
: m_inspectedPage(page)
, m_client(client)
......@@ -110,6 +126,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri
, m_applicationCacheAgent(new InspectorApplicationCacheAgent(m_instrumentingAgents.get(), page))
#endif
, 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()))
#if ENABLE(JAVASCRIPT_DEBUGGER)
, m_debuggerAgent(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, injectedScriptManager))
......@@ -162,7 +179,6 @@ void InspectorAgent::inspectedPageDestroyed()
InspectorInstrumentation::unbindInspectorAgent(m_inspectedPage);
m_inspectedPage = 0;
releaseFrontendLifetimeAgents();
m_injectedScriptManager->disconnect();
m_client->inspectorDestroyed();
......@@ -201,7 +217,6 @@ void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
m_state->unmute();
m_frontend = inspectorFrontend;
createFrontendLifetimeAgents();
#if ENABLE(OFFLINE_WEB_APPLICATIONS)
m_applicationCacheAgent->setFrontend(m_frontend);
......@@ -272,18 +287,6 @@ void InspectorAgent::disconnectFrontend()
m_domStorageAgent->clearFrontend();
#endif
m_pageAgent->clearFrontend();
releaseFrontendLifetimeAgents();
}
void InspectorAgent::createFrontendLifetimeAgents()
{
m_runtimeAgent = InspectorRuntimeAgent::create(m_injectedScriptManager, m_inspectedPage);
}
void InspectorAgent::releaseFrontendLifetimeAgents()
{
m_runtimeAgent.clear();
}
void InspectorAgent::didCommitLoad()
......
......@@ -177,9 +177,6 @@ private:
void showPanel(const String& panel);
void unbindAllResources();
void releaseFrontendLifetimeAgents();
void createFrontendLifetimeAgents();
#if ENABLE(JAVASCRIPT_DEBUGGER)
void toggleRecordButton(bool);
#endif
......
......@@ -36,20 +36,12 @@
#include "InjectedScript.h"
#include "InjectedScriptManager.h"
#include "InspectorValues.h"
#include "Page.h"
#include <wtf/PassOwnPtr.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
PassOwnPtr<InspectorRuntimeAgent> InspectorRuntimeAgent::create(InjectedScriptManager* injectedScriptManager, Page* inspectedPage)
{
return adoptPtr(new InspectorRuntimeAgent(injectedScriptManager, inspectedPage));
}
InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* inspectedPage)
InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager)
: m_injectedScriptManager(injectedScriptManager)
, m_inspectedPage(inspectedPage)
{
}
......@@ -59,8 +51,7 @@ InspectorRuntimeAgent::~InspectorRuntimeAgent()
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(scriptState);
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(getDefaultInspectedState());
if (!injectedScript.hasNoValue())
injectedScript.evaluate(errorString, expression, objectGroup, optionalIncludeCommandLineAPI ? *optionalIncludeCommandLineAPI : false, result);
}
......
......@@ -33,6 +33,7 @@
#if ENABLE(INSPECTOR)
#include "ScriptState.h"
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
......@@ -42,15 +43,13 @@ class InjectedScriptManager;
class InspectorArray;
class InspectorObject;
class InspectorValue;
class Page;
typedef String ErrorString;
class InspectorRuntimeAgent {
WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
public:
static PassOwnPtr<InspectorRuntimeAgent> create(InjectedScriptManager*, Page*);
~InspectorRuntimeAgent();
virtual ~InspectorRuntimeAgent();
// Part of the protocol.
void evaluate(ErrorString*, const String& expression, const String& objectGroup, const bool* const optionalIncludeCommandLineAPI, RefPtr<InspectorObject>* result);
......@@ -60,11 +59,12 @@ public:
void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& expression);
void releaseObjectGroup(ErrorString*, const String& objectGroup);
private:
InspectorRuntimeAgent(InjectedScriptManager*, Page*);
protected:
explicit InspectorRuntimeAgent(InjectedScriptManager*);
virtual ScriptState* getDefaultInspectedState() = 0;
private:
InjectedScriptManager* m_injectedScriptManager;
Page* m_inspectedPage;
};
} // 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