Add InspectorFileSystemAgent::FrontendProvider

https://bugs.webkit.org/show_bug.cgi?id=87635

InspectorFileSystemAgent needs weak reference to its frontend to perform
asynchronous operation.

Patch by Taiju Tsuiki <tzik@chromium.org> on 2012-05-29
Reviewed by Yury Semikhatsky.

* inspector/InspectorFileSystemAgent.cpp:
(InspectorFileSystemAgent::FrontendProvider):
(WebCore):
(WebCore::InspectorFileSystemAgent::~InspectorFileSystemAgent):
(WebCore::InspectorFileSystemAgent::enable):
(WebCore::InspectorFileSystemAgent::disable):
(WebCore::InspectorFileSystemAgent::setFrontend):
(WebCore::InspectorFileSystemAgent::clearFrontend):
(WebCore::InspectorFileSystemAgent::restore):
(WebCore::InspectorFileSystemAgent::InspectorFileSystemAgent):
* inspector/InspectorFileSystemAgent.h:
(InspectorFileSystemAgent):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@118783 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e313ac6a
2012-05-29 Taiju Tsuiki <tzik@chromium.org>
Add InspectorFileSystemAgent::FrontendProvider
https://bugs.webkit.org/show_bug.cgi?id=87635
InspectorFileSystemAgent needs weak reference to its frontend to perform
asynchronous operation.
Reviewed by Yury Semikhatsky.
* inspector/InspectorFileSystemAgent.cpp:
(InspectorFileSystemAgent::FrontendProvider):
(WebCore):
(WebCore::InspectorFileSystemAgent::~InspectorFileSystemAgent):
(WebCore::InspectorFileSystemAgent::enable):
(WebCore::InspectorFileSystemAgent::disable):
(WebCore::InspectorFileSystemAgent::setFrontend):
(WebCore::InspectorFileSystemAgent::clearFrontend):
(WebCore::InspectorFileSystemAgent::restore):
(WebCore::InspectorFileSystemAgent::InspectorFileSystemAgent):
* inspector/InspectorFileSystemAgent.h:
(InspectorFileSystemAgent):
2012-05-29 Yoshifumi Inoue <yosin@chromium.org>
REGRESSION(r109729): The optgroup element's "disabled" attribute has no effect to rendering and selection
......
......@@ -44,6 +44,35 @@ namespace FileSystemAgentState {
static const char fileSystemAgentEnabled[] = "fileSystemAgentEnabled";
}
class InspectorFileSystemAgent::FrontendProvider : public RefCounted<FrontendProvider> {
public:
static PassRefPtr<FrontendProvider> create(InspectorFileSystemAgent* agent, InspectorFrontend::FileSystem* frontend)
{
return adoptRef(new FrontendProvider(agent, frontend));
}
InspectorFrontend::FileSystem* frontend() const
{
if (m_agent && m_agent->m_enabled)
return m_frontend;
return 0;
}
void clear()
{
m_agent = 0;
m_frontend = 0;
}
private:
FrontendProvider(InspectorFileSystemAgent* agent, InspectorFrontend::FileSystem* frontend)
: m_agent(agent)
, m_frontend(frontend) { }
InspectorFileSystemAgent* m_agent;
InspectorFrontend::FileSystem* m_frontend;
};
// static
PassOwnPtr<InspectorFileSystemAgent> InspectorFileSystemAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* state)
{
......@@ -52,6 +81,8 @@ PassOwnPtr<InspectorFileSystemAgent> InspectorFileSystemAgent::create(Instrument
InspectorFileSystemAgent::~InspectorFileSystemAgent()
{
if (m_frontendProvider)
m_frontendProvider->clear();
m_instrumentingAgents->setInspectorFileSystemAgent(0);
}
......@@ -74,12 +105,15 @@ void InspectorFileSystemAgent::disable(ErrorString*)
void InspectorFileSystemAgent::setFrontend(InspectorFrontend* frontend)
{
ASSERT(frontend);
m_frontend = frontend->filesystem();
m_frontendProvider = FrontendProvider::create(this, frontend->filesystem());
}
void InspectorFileSystemAgent::clearFrontend()
{
m_frontend = 0;
if (m_frontendProvider) {
m_frontendProvider->clear();
m_frontendProvider = 0;
}
m_enabled = false;
m_state->setBoolean(FileSystemAgentState::fileSystemAgentEnabled, m_enabled);
}
......@@ -90,9 +124,8 @@ void InspectorFileSystemAgent::restore()
}
InspectorFileSystemAgent::InspectorFileSystemAgent(InstrumentingAgents* instrumentingAgents, InspectorState* state)
: InspectorBaseAgent<InspectorFileSystemAgent>("FileSystem", instrumentingAgents, state),
m_frontend(0),
m_enabled(false)
: InspectorBaseAgent<InspectorFileSystemAgent>("FileSystem", instrumentingAgents, state)
, m_enabled(false)
{
ASSERT(instrumentingAgents);
ASSERT(state);
......
......@@ -47,6 +47,8 @@ class InstrumentingAgents;
class InspectorFileSystemAgent : public InspectorBaseAgent<InspectorFileSystemAgent>, public InspectorBackendDispatcher::FileSystemCommandHandler {
public:
class FrontendProvider;
static PassOwnPtr<InspectorFileSystemAgent> create(InstrumentingAgents*, InspectorState*);
virtual ~InspectorFileSystemAgent();
......@@ -59,7 +61,7 @@ public:
private:
InspectorFileSystemAgent(InstrumentingAgents*, InspectorState*);
InspectorFrontend::FileSystem* m_frontend;
RefPtr<FrontendProvider> m_frontendProvider;
bool m_enabled;
};
......
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