Title: [118783] trunk/Source/WebCore
Revision
118783
Author
[email protected]
Date
2012-05-29 09:00:35 -0700 (Tue, 29 May 2012)

Log Message

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 <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118782 => 118783)


--- trunk/Source/WebCore/ChangeLog	2012-05-29 15:52:54 UTC (rev 118782)
+++ trunk/Source/WebCore/ChangeLog	2012-05-29 16:00:35 UTC (rev 118783)
@@ -1,3 +1,26 @@
+2012-05-29  Taiju Tsuiki  <[email protected]>
+
+        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  <[email protected]>
 
         REGRESSION(r109729): The optgroup element's "disabled" attribute has no effect to rendering and selection

Modified: trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp (118782 => 118783)


--- trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp	2012-05-29 15:52:54 UTC (rev 118782)
+++ trunk/Source/WebCore/inspector/InspectorFileSystemAgent.cpp	2012-05-29 16:00:35 UTC (rev 118783)
@@ -44,6 +44,35 @@
 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 @@
 
 InspectorFileSystemAgent::~InspectorFileSystemAgent()
 {
+    if (m_frontendProvider)
+        m_frontendProvider->clear();
     m_instrumentingAgents->setInspectorFileSystemAgent(0);
 }
 
@@ -74,12 +105,15 @@
 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 @@
 }
 
 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);

Modified: trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h (118782 => 118783)


--- trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h	2012-05-29 15:52:54 UTC (rev 118782)
+++ trunk/Source/WebCore/inspector/InspectorFileSystemAgent.h	2012-05-29 16:00:35 UTC (rev 118783)
@@ -47,6 +47,8 @@
 
 class InspectorFileSystemAgent : public InspectorBaseAgent<InspectorFileSystemAgent>, public InspectorBackendDispatcher::FileSystemCommandHandler {
 public:
+    class FrontendProvider;
+
     static PassOwnPtr<InspectorFileSystemAgent> create(InstrumentingAgents*, InspectorState*);
     virtual ~InspectorFileSystemAgent();
 
@@ -59,7 +61,7 @@
 private:
     InspectorFileSystemAgent(InstrumentingAgents*, InspectorState*);
 
-    InspectorFrontend::FileSystem* m_frontend;
+    RefPtr<FrontendProvider> m_frontendProvider;
     bool m_enabled;
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to