2009-07-11 Jeremy Orlow <jorlow@chromium.org>
authorbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jul 2009 19:36:50 +0000 (19:36 +0000)
committerbfulgham@webkit.org <bfulgham@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jul 2009 19:36:50 +0000 (19:36 +0000)
        Reviewed by Darin Adler.

        Cleanup DOM Storage dependencies.
        https://bugs.webkit.org/show_bug.cgi?id=27180

        DOM Storage had several unnecessary (and probably unintended)
        dependencies.  This patch replaces many includes of header files with
        forward declaration of classes, making some destructors explicit, and
        taking some factories out of the header files.

        This will allow things like StorageAreaSync to take a StorageAreaImpl*
        (as it should) rather than a StorageArea* which previously weren't
        possible because the dependencies were such a tangled mess.

        * storage/LocalStorageTask.cpp:
        (WebCore::LocalStorageTask::~LocalStorageTask):
        * storage/LocalStorageTask.h:
        * storage/Storage.cpp:
        (WebCore::Storage::~Storage):
        * storage/Storage.h:
        * storage/StorageArea.cpp:
        * storage/StorageArea.h:
        * storage/StorageAreaImpl.cpp:
        * storage/StorageAreaImpl.h:
        * storage/StorageAreaSync.cpp:
        (WebCore::StorageAreaSync::~StorageAreaSync):
        * storage/StorageAreaSync.h:
        * storage/StorageEvent.cpp:
        (WebCore::StorageEvent::create):
        (WebCore::StorageEvent::StorageEvent):
        * storage/StorageEvent.h:
        * storage/StorageNamespace.h:
        * storage/StorageNamespaceImpl.cpp:
        * storage/StorageNamespaceImpl.h:
        * storage/StorageSyncManager.cpp:
        (WebCore::StorageSyncManager::~StorageSyncManager):
        * storage/StorageSyncManager.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45864 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
WebCore/ChangeLog
WebCore/storage/LocalStorageTask.cpp
WebCore/storage/LocalStorageTask.h
WebCore/storage/Storage.cpp
WebCore/storage/Storage.h
WebCore/storage/StorageArea.cpp
WebCore/storage/StorageArea.h
WebCore/storage/StorageAreaImpl.cpp
WebCore/storage/StorageAreaImpl.h
WebCore/storage/StorageAreaSync.cpp
WebCore/storage/StorageAreaSync.h
WebCore/storage/StorageEvent.cpp
WebCore/storage/StorageEvent.h
WebCore/storage/StorageNamespace.h
WebCore/storage/StorageNamespaceImpl.cpp
WebCore/storage/StorageNamespaceImpl.h
WebCore/storage/StorageSyncManager.cpp
WebCore/storage/StorageSyncManager.h

index 86eebcd..7d10b40 100644 (file)
@@ -1,3 +1,44 @@
+2009-07-11  Jeremy Orlow  <jorlow@chromium.org>
+
+        Reviewed by Darin Adler.
+
+        Cleanup DOM Storage dependencies.
+        https://bugs.webkit.org/show_bug.cgi?id=27180
+
+        DOM Storage had several unnecessary (and probably unintended)
+        dependencies.  This patch replaces many includes of header files with
+        forward declaration of classes, making some destructors explicit, and
+        taking some factories out of the header files.
+
+        This will allow things like StorageAreaSync to take a StorageAreaImpl*
+        (as it should) rather than a StorageArea* which previously weren't
+        possible because the dependencies were such a tangled mess.
+
+        * storage/LocalStorageTask.cpp:
+        (WebCore::LocalStorageTask::~LocalStorageTask):
+        * storage/LocalStorageTask.h:
+        * storage/Storage.cpp:
+        (WebCore::Storage::~Storage):
+        * storage/Storage.h:
+        * storage/StorageArea.cpp:
+        * storage/StorageArea.h:
+        * storage/StorageAreaImpl.cpp:
+        * storage/StorageAreaImpl.h:
+        * storage/StorageAreaSync.cpp:
+        (WebCore::StorageAreaSync::~StorageAreaSync):
+        * storage/StorageAreaSync.h:
+        * storage/StorageEvent.cpp:
+        (WebCore::StorageEvent::create):
+        (WebCore::StorageEvent::StorageEvent):
+        * storage/StorageEvent.h:
+        * storage/StorageNamespace.h:
+        * storage/StorageNamespaceImpl.cpp:
+        * storage/StorageNamespaceImpl.h:
+        * storage/StorageSyncManager.cpp:
+        (WebCore::StorageSyncManager::~StorageSyncManager):
+        * storage/StorageSyncManager.h:
+
+
 2009-07-14  Adam Treat  <adam.treat@torchmobile.com>
 
         Reviewed by David Hyatt.
index f9b8dc2..f5d4890 100644 (file)
@@ -49,6 +49,10 @@ LocalStorageTask::LocalStorageTask(Type type, PassRefPtr<LocalStorageThread> thr
     ASSERT(m_type == TerminateThread);
 }
 
+LocalStorageTask::~LocalStorageTask()
+{
+}
+
 void LocalStorageTask::performTask()
 {
     switch (m_type) {
index 2c397da..cd90734 100644 (file)
@@ -49,6 +49,9 @@ namespace WebCore {
         void performTask();
 
     private:
+        friend class ThreadSafeShared<LocalStorageTask>;
+        ~LocalStorageTask();
+
         LocalStorageTask(Type, PassRefPtr<StorageAreaSync>);
         LocalStorageTask(Type, PassRefPtr<LocalStorageThread>);
 
index e228971..0166098 100644 (file)
@@ -47,6 +47,10 @@ Storage::Storage(Frame* frame, PassRefPtr<StorageArea> storageArea)
     ASSERT(m_storageArea);
 }
 
+Storage::~Storage()
+{
+}
+
 unsigned Storage::length() const
 {
     if (!m_frame)
index ca7a32e..acafb22 100644 (file)
@@ -28,8 +28,6 @@
 
 #if ENABLE(DOM_STORAGE)
 
-#include "StorageArea.h"
-
 #include <wtf/Forward.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -37,6 +35,7 @@
 namespace WebCore {
 
     class Frame;
+    class StorageArea;
     class String;
     typedef int ExceptionCode;
 
@@ -56,6 +55,9 @@ namespace WebCore {
         void disconnectFrame() { m_frame = 0; }
 
     private:
+        friend class RefCounted<Storage>;
+        ~Storage();
+
         Storage(Frame*, PassRefPtr<StorageArea>);
             
         Frame* m_frame;
index 11b3517..828926a 100644 (file)
@@ -33,6 +33,7 @@
 #if ENABLE(DOM_STORAGE)
 
 #include "StorageAreaImpl.h"
+#include "StorageSyncManager.h"
 
 namespace WebCore {
 
index 31f716a..a2a50f0 100644 (file)
 #if ENABLE(DOM_STORAGE)
 
 #include "PlatformString.h"
-#include "SecurityOrigin.h"
-#include "StorageAreaSync.h"
-#include "StorageMap.h"
-#include "StorageSyncManager.h"
 
-#include <wtf/Forward.h>
 #include <wtf/PassRefPtr.h>
-#include <wtf/RefCounted.h>
-#include <wtf/RefPtr.h>
+#include <wtf/Threading.h>
 
 namespace WebCore {
 
     class Frame;
-    class Page;
     class SecurityOrigin;
-    class StorageAreaSync;
-    class StorageMap;
     class StorageSyncManager;
     typedef int ExceptionCode;
     enum StorageType { LocalStorage, SessionStorage };
index ba31658..e399464 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(DOM_STORAGE)
 
-#include "DOMWindow.h"
 #include "EventNames.h"
 #include "ExceptionCode.h"
 #include "Frame.h"
index e2d14f1..0288633 100644 (file)
 
 #include "StorageArea.h"
 
+#include <wtf/RefPtr.h>
+
 namespace WebCore {
 
+    class SecurityOrigin;
+    class StorageMap;
+    class StorageAreaSync;
+
     class StorageAreaImpl : public StorageArea {
     public:
         static PassRefPtr<StorageArea> create(StorageType, SecurityOrigin*, PassRefPtr<StorageSyncManager>);
index 2cef56d..b5f18bf 100644 (file)
@@ -33,6 +33,7 @@
 #include "HTMLElement.h"
 #include "SQLiteStatement.h"
 #include "StorageArea.h"
+#include "StorageSyncManager.h"
 #include "SuddenTermination.h"
 
 namespace WebCore {
@@ -65,12 +66,10 @@ StorageAreaSync::StorageAreaSync(PassRefPtr<StorageSyncManager> storageSyncManag
         m_importComplete = true;
 }
 
-#ifndef NDEBUG
 StorageAreaSync::~StorageAreaSync()
 {
     ASSERT(!m_syncTimer.isActive());
 }
-#endif
 
 void StorageAreaSync::scheduleFinalSync()
 {
index a7f1082..e8ed59a 100644 (file)
@@ -28,9 +28,9 @@
 
 #if ENABLE(DOM_STORAGE)
 
+#include "PlatformString.h"
 #include "SQLiteDatabase.h"
 #include "StringHash.h"
-#include "StorageSyncManager.h"
 #include "Timer.h"
 #include <wtf/HashMap.h>
 
@@ -42,10 +42,6 @@ namespace WebCore {
     
     class StorageAreaSync : public RefCounted<StorageAreaSync> {
     public:
-#ifndef NDEBUG
-        ~StorageAreaSync();
-#endif
-
         static PassRefPtr<StorageAreaSync> create(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageArea> storageArea);
         
         void scheduleFinalSync();
@@ -55,6 +51,9 @@ namespace WebCore {
         void scheduleClear();
         
     private:
+        friend class RefCounted<StorageAreaSync>;
+        ~StorageAreaSync();
+
         StorageAreaSync(PassRefPtr<StorageSyncManager> storageSyncManager, PassRefPtr<StorageArea> storageArea);
 
         void dispatchStorageEvent(const String& key, const String& oldValue, const String& newValue, Frame* sourceFrame);
index f2945a9..2e620d5 100644 (file)
 
 namespace WebCore {
 
+PassRefPtr<StorageEvent> StorageEvent::create()
+{
+    return adoptRef(new StorageEvent);
+}
+
+StorageEvent::StorageEvent()
+{
+}
+
+PassRefPtr<StorageEvent> StorageEvent::create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& uri, PassRefPtr<DOMWindow> source, Storage* storageArea)
+{
+    return adoptRef(new StorageEvent(type, key, oldValue, newValue, uri, source, storageArea));
+}
+
 StorageEvent::StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& uri, PassRefPtr<DOMWindow> source, Storage* storageArea)
     : Event(type, false, true)
     , m_key(key)
index ee3d5ad..703fb5a 100644 (file)
 #if ENABLE(DOM_STORAGE)
 
 #include "Event.h"
-#include "Storage.h"
+#include "PlatformString.h"
 
 namespace WebCore {
 
     class DOMWindow;
+    class Storage;
 
     class StorageEvent : public Event {
     public:
-        static PassRefPtr<StorageEvent> create()
-        {
-            return adoptRef(new StorageEvent);
-        }
-        static PassRefPtr<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& uri, PassRefPtr<DOMWindow> source, Storage* storageArea)
-        {
-            return adoptRef(new StorageEvent(type, key, oldValue, newValue, uri, source, storageArea));
-        }
+        static PassRefPtr<StorageEvent> create();
+        static PassRefPtr<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& uri, PassRefPtr<DOMWindow> source, Storage* storageArea);
 
         const String& key() const { return m_key; }
         const String& oldValue() const { return m_oldValue; }
@@ -61,7 +56,7 @@ namespace WebCore {
         virtual bool isStorageEvent() const { return true; }
 
     private:    
-        StorageEvent() { }
+        StorageEvent();
         StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& uri, PassRefPtr<DOMWindow> source, Storage* storageArea);
         
         String m_key;
index 687cea2..edbe339 100644 (file)
 
 #if ENABLE(DOM_STORAGE)
 
-#include "SecurityOriginHash.h"
-#include "StorageArea.h"
+#include "PlatformString.h"
 
-#include <wtf/HashMap.h>
+#include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 
 namespace WebCore {
 
+    class SecurityOrigin;
     class StorageArea;
-    class StorageSyncManager;
 
     // This interface is required for Chromium since these actions need to be proxied between processes.
     class StorageNamespace : public RefCounted<StorageNamespace> {
index 39ec27b..c596d18 100644 (file)
 
 #if ENABLE(DOM_STORAGE)
 
+#include "SecurityOriginHash.h"
+#include "StringHash.h"
+#include "StorageArea.h"
+#include "StorageSyncManager.h"
 #include <wtf/StdLibExtras.h>
 
 namespace WebCore {
index 6c5a9dc..7e4b8f9 100644 (file)
 
 #if ENABLE(DOM_STORAGE)
 
+#include "PlatformString.h"
+#include "SecurityOriginHash.h"
+#include "StorageArea.h"
 #include "StorageNamespace.h"
 
+#include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
+
 namespace WebCore {
 
     class StorageNamespaceImpl : public StorageNamespace {
index 5dab7a6..a935242 100644 (file)
@@ -33,6 +33,8 @@
 #include "FileSystem.h"
 #include "Frame.h"
 #include "FrameTree.h"
+#include "LocalStorageTask.h"
+#include "LocalStorageThread.h"
 #include "Page.h"
 #include "PageGroup.h"
 #include "StorageAreaSync.h"
@@ -53,6 +55,10 @@ StorageSyncManager::StorageSyncManager(const String& path)
     m_thread->start();
 }
 
+StorageSyncManager::~StorageSyncManager()
+{
+}
+
 String StorageSyncManager::fullDatabaseFilename(SecurityOrigin* origin)
 {
     ASSERT(origin);
index 83353ed..7d06ba7 100644 (file)
 
 #if ENABLE(DOM_STORAGE)
 
-#include "LocalStorageTask.h"
-#include "LocalStorageThread.h"
-#include "StorageArea.h"
-#include "StorageAreaSync.h"
+#include "PlatformString.h"
 
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
 #include <wtf/Threading.h>
 
 namespace WebCore {
 
+    class LocalStorageThread;
+    class SecurityOrigin;
+    class StorageAreaSync;
+
     class StorageSyncManager : public ThreadSafeShared<StorageSyncManager> {
     public:
         static PassRefPtr<StorageSyncManager> create(const String& path);
@@ -47,6 +50,9 @@ namespace WebCore {
         void close();
 
     private:
+        friend class ThreadSafeShared<StorageSyncManager>;
+        ~StorageSyncManager();
+
         StorageSyncManager(const String& path);
 
         RefPtr<LocalStorageThread> m_thread;