Changeset 82845 in webkit


Ignore:
Timestamp:
Apr 4, 2011 10:32:51 AM (13 years ago)
Author:
yurys@chromium.org
Message:

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):
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r82843 r82845  
     12011-04-04  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: InspectorRuntimeAgent should not depend on Page
     6        https://bugs.webkit.org/show_bug.cgi?id=57759
     7
     8        Descendants of InspectorRuntimeAgent should implement a method providing access to the default
     9        inspected state used for console evaluations.
     10
     11        * inspector/InspectorAgent.cpp:
     12        (WebCore::InspectorAgent::InspectorAgent): runtime agent is created and deleted along with other agents.
     13        (WebCore::InspectorAgent::setFrontend):
     14        * inspector/InspectorAgent.h:
     15        * inspector/InspectorRuntimeAgent.cpp:
     16        (WebCore::InspectorRuntimeAgent::create):
     17        (WebCore::InspectorRuntimeAgent::InspectorRuntimeAgent):
     18        (WebCore::InspectorRuntimeAgent::evaluate):
     19        * inspector/InspectorRuntimeAgent.h:
     20        (WebCore::InspectorRuntimeAgent::InspectedStateProvider::~InspectedStateProvider):
     21
    1222011-04-04  Yong Li  <yoli@rim.com>
    223
  • trunk/Source/WebCore/inspector/InspectorAgent.cpp

    r82449 r82845  
    9090static const char profilesPanelName[] = "profiles";
    9191
     92namespace {
     93
     94class PageRuntimeAgent : public InspectorRuntimeAgent {
     95public:
     96    PageRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* page)
     97        : InspectorRuntimeAgent(injectedScriptManager)
     98        , m_inspectedPage(page) { }
     99    virtual ~PageRuntimeAgent() { }
     100
     101private:
     102    virtual ScriptState* getDefaultInspectedState() { return mainWorldScriptState(m_inspectedPage->mainFrame()); }
     103    Page* m_inspectedPage;
     104};
     105
     106}
     107
    92108InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScriptManager* injectedScriptManager)
    93109    : m_inspectedPage(page)
     
    111127#endif
    112128    , m_resourceAgent(InspectorResourceAgent::create(m_instrumentingAgents.get(), page, m_state.get()))
     129    , m_runtimeAgent(adoptPtr(new PageRuntimeAgent(m_injectedScriptManager, page)))
    113130    , m_consoleAgent(new InspectorConsoleAgent(m_instrumentingAgents.get(), this, m_state.get(), injectedScriptManager, m_domAgent.get()))
    114131#if ENABLE(JAVASCRIPT_DEBUGGER)
     
    163180    m_inspectedPage = 0;
    164181
    165     releaseFrontendLifetimeAgents();
    166182    m_injectedScriptManager->disconnect();
    167183
     
    202218
    203219    m_frontend = inspectorFrontend;
    204     createFrontendLifetimeAgents();
    205220
    206221#if ENABLE(OFFLINE_WEB_APPLICATIONS)
     
    273288#endif
    274289    m_pageAgent->clearFrontend();
    275 
    276     releaseFrontendLifetimeAgents();
    277 }
    278 
    279 void InspectorAgent::createFrontendLifetimeAgents()
    280 {
    281     m_runtimeAgent = InspectorRuntimeAgent::create(m_injectedScriptManager, m_inspectedPage);
    282 }
    283 
    284 void InspectorAgent::releaseFrontendLifetimeAgents()
    285 {
    286     m_runtimeAgent.clear();
    287290}
    288291
  • trunk/Source/WebCore/inspector/InspectorAgent.h

    r82403 r82845  
    178178    void unbindAllResources();
    179179
    180     void releaseFrontendLifetimeAgents();
    181     void createFrontendLifetimeAgents();
    182 
    183180#if ENABLE(JAVASCRIPT_DEBUGGER)
    184181    void toggleRecordButton(bool);
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp

    r82804 r82845  
    3737#include "InjectedScriptManager.h"
    3838#include "InspectorValues.h"
    39 #include "Page.h"
    40 #include <wtf/PassOwnPtr.h>
    4139#include <wtf/PassRefPtr.h>
    4240
    4341namespace WebCore {
    4442
    45 PassOwnPtr<InspectorRuntimeAgent> InspectorRuntimeAgent::create(InjectedScriptManager* injectedScriptManager, Page* inspectedPage)
    46 {
    47     return adoptPtr(new InspectorRuntimeAgent(injectedScriptManager, inspectedPage));
    48 }
    49 
    50 InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager, Page* inspectedPage)
     43InspectorRuntimeAgent::InspectorRuntimeAgent(InjectedScriptManager* injectedScriptManager)
    5144    : m_injectedScriptManager(injectedScriptManager)
    52     , m_inspectedPage(inspectedPage)
    5345{
    5446}
     
    6052void InspectorRuntimeAgent::evaluate(ErrorString* errorString, const String& expression, const String& objectGroup, const bool* const optionalIncludeCommandLineAPI, RefPtr<InspectorObject>* result)
    6153{
    62     ScriptState* scriptState = mainWorldScriptState(m_inspectedPage->mainFrame());
    63     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(scriptState);
     54    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(getDefaultInspectedState());
    6455    if (!injectedScript.hasNoValue())
    6556        injectedScript.evaluate(errorString, expression, objectGroup, optionalIncludeCommandLineAPI ? *optionalIncludeCommandLineAPI : false, result);
  • trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h

    r82804 r82845  
    3434#if ENABLE(INSPECTOR)
    3535
     36#include "ScriptState.h"
    3637#include <wtf/Forward.h>
    3738#include <wtf/Noncopyable.h>
     
    4344class InspectorObject;
    4445class InspectorValue;
    45 class Page;
    4646
    4747typedef String ErrorString;
     
    5050    WTF_MAKE_NONCOPYABLE(InspectorRuntimeAgent);
    5151public:
    52     static PassOwnPtr<InspectorRuntimeAgent> create(InjectedScriptManager*, Page*);
    53     ~InspectorRuntimeAgent();
     52    virtual ~InspectorRuntimeAgent();
    5453
    5554    // Part of the protocol.
     
    6160    void releaseObjectGroup(ErrorString*, const String& objectGroup);
    6261
     62protected:
     63    explicit InspectorRuntimeAgent(InjectedScriptManager*);
     64    virtual ScriptState* getDefaultInspectedState() = 0;
     65
    6366private:
    64     InspectorRuntimeAgent(InjectedScriptManager*, Page*);
    65 
    6667    InjectedScriptManager* m_injectedScriptManager;
    67     Page* m_inspectedPage;
    6868};
    6969
Note: See TracChangeset for help on using the changeset viewer.