Title: [149449] trunk/Source
Revision
149449
Author
[email protected]
Date
2013-05-01 13:28:27 -0700 (Wed, 01 May 2013)

Log Message

Add LocalStorageDatabase class
https://bugs.webkit.org/show_bug.cgi?id=115486

Reviewed by Sam Weinig.

Source/WebCore:

Export symbols needed by WebKit2.

* WebCore.exp.in:

Source/WebKit2:

The LocalStorageDatabase class will persist local storage data to disk.

* UIProcess/Storage/LocalStorageDatabase.cpp:
* UIProcess/Storage/LocalStorageDatabase.h: Added.

* UIProcess/Storage/StorageManager.cpp:
(StorageManager::StorageArea):
(WebKit::StorageManager::LocalStorageNamespace::storageManager):
Add getter.

(StorageManager::LocalStorageNamespace):
(WebKit::StorageManager::StorageArea::StorageArea):
If this is a local storage area, create a LocalStorageDatabase.

(WebKit::StorageManager::LocalStorageNamespace::databaseFilename):
Helper function for getting the name of the database for the given origin.

* WebKit2.xcodeproj/project.pbxproj:
Add new files.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (149448 => 149449)


--- trunk/Source/WebCore/ChangeLog	2013-05-01 19:57:31 UTC (rev 149448)
+++ trunk/Source/WebCore/ChangeLog	2013-05-01 20:28:27 UTC (rev 149449)
@@ -1,3 +1,14 @@
+2013-05-01  Anders Carlsson  <[email protected]>
+
+        Add LocalStorageDatabase class
+        https://bugs.webkit.org/show_bug.cgi?id=115486
+
+        Reviewed by Sam Weinig.
+
+        Export symbols needed by WebKit2.
+
+        * WebCore.exp.in:
+
 2013-05-01  Eric Carlson  <[email protected]>
 
         [Mac Lion] Assertion failure in MediaControlTextTrackContainerElement::updateDisplay()

Modified: trunk/Source/WebCore/WebCore.exp.in (149448 => 149449)


--- trunk/Source/WebCore/WebCore.exp.in	2013-05-01 19:57:31 UTC (rev 149448)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-05-01 20:28:27 UTC (rev 149449)
@@ -570,6 +570,7 @@
 __ZN7WebCore17cacheDOMStructureEPNS_17JSDOMGlobalObjectEPN3JSC9StructureEPKNS2_9ClassInfoE
 __ZN7WebCore17openTemporaryFileERKN3WTF6StringERi
 __ZN7WebCore17userVisibleStringEP5NSURL
+__ZN7WebCore18makeAllDirectoriesERKN3WTF6StringE
 __ZN7WebCore18DOMWindowExtensionC1EPNS_5FrameEPNS_15DOMWrapperWorldE
 __ZN7WebCore10Pasteboard17generalPasteboardEv
 __ZN7WebCore10Pasteboard14writePlainTextERKN3WTF6StringENS0_18SmartReplaceOptionE
@@ -752,6 +753,7 @@
 __ZN7WebCore24deleteCookiesForHostnameERKNS_21NetworkStorageSessionERKN3WTF6StringE
 __ZN7WebCore24fileSystemRepresentationERKN3WTF6StringE
 __ZN7WebCore24notifyHistoryItemChangedE
+__ZN7WebCore24pathByAppendingComponentERKN3WTF6StringES3_
 __ZN7WebCore25HistoryPropertyListWriter11releaseDataEv
 __ZN7WebCore25HistoryPropertyListWriter12writeObjectsERNS_30BinaryPropertyListObjectStreamE
 __ZN7WebCore25HistoryPropertyListWriter16writeHistoryItemERNS_30BinaryPropertyListObjectStreamEPNS_11HistoryItemE

Modified: trunk/Source/WebKit2/ChangeLog (149448 => 149449)


--- trunk/Source/WebKit2/ChangeLog	2013-05-01 19:57:31 UTC (rev 149448)
+++ trunk/Source/WebKit2/ChangeLog	2013-05-01 20:28:27 UTC (rev 149449)
@@ -1,3 +1,30 @@
+2013-05-01  Anders Carlsson  <[email protected]>
+
+        Add LocalStorageDatabase class
+        https://bugs.webkit.org/show_bug.cgi?id=115486
+
+        Reviewed by Sam Weinig.
+
+        The LocalStorageDatabase class will persist local storage data to disk.
+
+        * UIProcess/Storage/LocalStorageDatabase.cpp:
+        * UIProcess/Storage/LocalStorageDatabase.h: Added.
+
+        * UIProcess/Storage/StorageManager.cpp:
+        (StorageManager::StorageArea):
+        (WebKit::StorageManager::LocalStorageNamespace::storageManager):
+        Add getter.
+
+        (StorageManager::LocalStorageNamespace):
+        (WebKit::StorageManager::StorageArea::StorageArea):
+        If this is a local storage area, create a LocalStorageDatabase.
+
+        (WebKit::StorageManager::LocalStorageNamespace::databaseFilename):
+        Helper function for getting the name of the database for the given origin.
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add new files.
+
 2013-05-01  Alexey Proskuryakov  <[email protected]>
 
         <rdar://problem/13781156> Launching NetworkProcess broken on some OS versions.

Added: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp (0 => 149449)


--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp	2013-05-01 20:28:27 UTC (rev 149449)
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "LocalStorageDatabase.h"
+
+#include "WorkQueue.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+PassRefPtr<LocalStorageDatabase> LocalStorageDatabase::create(const String& databaseFilename, PassRefPtr<WorkQueue> queue)
+{
+    return adoptRef(new LocalStorageDatabase(databaseFilename, queue));
+}
+
+LocalStorageDatabase::LocalStorageDatabase(const String& databaseFilename, PassRefPtr<WorkQueue> queue)
+    : m_queue(queue)
+{
+    // FIXME: If it can't import, then the default WebKit behavior should be that of private browsing,
+    // not silently ignoring it. https://bugs.webkit.org/show_bug.cgi?id=25894
+    m_queue->dispatch(bind(&LocalStorageDatabase::performImport, this));
+}
+
+LocalStorageDatabase::~LocalStorageDatabase()
+{
+}
+
+void LocalStorageDatabase::performImport()
+{
+    // FIXME: Actually import.
+}
+
+} // namespace WebKit

Added: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h (0 => 149449)


--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.h	2013-05-01 20:28:27 UTC (rev 149449)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2013 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LocalStorageDatabase_h
+#define LocalStorageDatabase_h
+
+#include <wtf/Forward.h>
+#include <wtf/RefPtr.h>
+#include <wtf/ThreadSafeRefCounted.h>
+
+class WorkQueue;
+
+namespace WebKit {
+
+class LocalStorageDatabase : public ThreadSafeRefCounted<LocalStorageDatabase> {
+public:
+    static PassRefPtr<LocalStorageDatabase> create(const String& databaseFilename, PassRefPtr<WorkQueue>);
+    ~LocalStorageDatabase();
+
+private:
+    LocalStorageDatabase(const String& databaseFilename, PassRefPtr<WorkQueue>);
+
+    void performImport();
+
+    RefPtr<WorkQueue> m_queue;
+};
+
+
+} // namespace WebKit
+
+#endif // LocalStorageDatabase_h

Modified: trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp (149448 => 149449)


--- trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-05-01 19:57:31 UTC (rev 149448)
+++ trunk/Source/WebKit2/UIProcess/Storage/StorageManager.cpp	2013-05-01 20:28:27 UTC (rev 149449)
@@ -26,11 +26,13 @@
 #include "config.h"
 #include "StorageManager.h"
 
+#include "LocalStorageDatabase.h"
 #include "SecurityOriginData.h"
 #include "StorageAreaMapMessages.h"
 #include "StorageManagerMessages.h"
 #include "WebProcessProxy.h"
 #include "WorkQueue.h"
+#include <WebCore/FileSystem.h>
 #include <WebCore/SecurityOriginHash.h>
 #include <WebCore/StorageMap.h>
 
@@ -63,6 +65,8 @@
 
     // Will be null if the storage area belongs to a session storage namespace.
     LocalStorageNamespace* m_localStorageNamespace;
+    RefPtr<LocalStorageDatabase> m_localStorageDatabase;
+
     RefPtr<SecurityOrigin> m_securityOrigin;
     unsigned m_quotaInBytes;
 
@@ -75,6 +79,9 @@
     static PassRefPtr<LocalStorageNamespace> create(StorageManager*, uint64_t storageManagerID);
     ~LocalStorageNamespace();
 
+    StorageManager* storageManager() const { return m_storageManager; }
+    String databaseFilename(SecurityOrigin*) const;
+
     PassRefPtr<StorageArea> getOrCreateStorageArea(PassRefPtr<SecurityOrigin>);
     void didDestroyStorageArea(StorageArea*);
 
@@ -100,6 +107,8 @@
     , m_quotaInBytes(quotaInBytes)
     , m_storageMap(StorageMap::create(m_quotaInBytes))
 {
+    if (m_localStorageNamespace)
+        m_localStorageDatabase = LocalStorageDatabase::create(m_localStorageNamespace->databaseFilename(m_securityOrigin.get()), m_localStorageNamespace->storageManager()->m_queue);
 }
 
 StorageManager::StorageArea::~StorageArea()
@@ -195,6 +204,16 @@
     ASSERT(m_storageAreaMap.isEmpty());
 }
 
+String StorageManager::LocalStorageNamespace::databaseFilename(SecurityOrigin* securityOrigin) const
+{
+    if (!makeAllDirectories(m_storageManager->m_localStorageDirectory)) {
+        LOG_ERROR("Unabled to create LocalStorage database path %s", m_storageManager->m_localStorageDirectory.utf8().data());
+        return String();
+    }
+
+    return pathByAppendingComponent(m_storageManager->m_localStorageDirectory, securityOrigin->databaseIdentifier() + ".localstorage");
+}
+
 PassRefPtr<StorageManager::StorageArea> StorageManager::LocalStorageNamespace::getOrCreateStorageArea(PassRefPtr<SecurityOrigin> securityOrigin)
 {
     HashMap<RefPtr<SecurityOrigin>, StorageArea*>::AddResult result = m_storageAreaMap.add(securityOrigin, 0);

Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (149448 => 149449)


--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-05-01 19:57:31 UTC (rev 149448)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj	2013-05-01 20:28:27 UTC (rev 149449)
@@ -83,6 +83,8 @@
 		1A186EEA12EF7618008E5F37 /* LayerTreeHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A186EE812EF7618008E5F37 /* LayerTreeHost.h */; };
 		1A186EEB12EF7618008E5F37 /* LayerTreeHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A186EE912EF7618008E5F37 /* LayerTreeHost.cpp */; };
 		1A1C649B11F4174200553C19 /* WebContextMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A1C648611F415B700553C19 /* WebContextMac.mm */; };
+		1A1D8BA11731A36300141DA4 /* LocalStorageDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1D8B9F1731A36300141DA4 /* LocalStorageDatabase.cpp */; };
+		1A1D8BA21731A36300141DA4 /* LocalStorageDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1D8BA01731A36300141DA4 /* LocalStorageDatabase.h */; };
 		1A1FEC1C1627B45700700F6D /* WebConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A1FEC1A1627B45600700F6D /* WebConnectionMessageReceiver.cpp */; };
 		1A1FEC1D1627B45700700F6D /* WebConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A1FEC1B1627B45700700F6D /* WebConnectionMessages.h */; };
 		1A2161B011F37664008AD0F5 /* NPRuntimeObjectMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A2161AE11F37664008AD0F5 /* NPRuntimeObjectMap.h */; };
@@ -1486,6 +1488,8 @@
 		1A186EE812EF7618008E5F37 /* LayerTreeHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LayerTreeHost.h; sourceTree = "<group>"; };
 		1A186EE912EF7618008E5F37 /* LayerTreeHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LayerTreeHost.cpp; sourceTree = "<group>"; };
 		1A1C648611F415B700553C19 /* WebContextMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMac.mm; sourceTree = "<group>"; };
+		1A1D8B9F1731A36300141DA4 /* LocalStorageDatabase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalStorageDatabase.cpp; sourceTree = "<group>"; };
+		1A1D8BA01731A36300141DA4 /* LocalStorageDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LocalStorageDatabase.h; sourceTree = "<group>"; };
 		1A1FA251127A0E4F0050E709 /* NPRemoteObjectMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPRemoteObjectMap.h; sourceTree = "<group>"; };
 		1A1FA252127A0E4F0050E709 /* NPRemoteObjectMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRemoteObjectMap.cpp; sourceTree = "<group>"; };
 		1A1FA283127A13BC0050E709 /* NPObjectProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NPObjectProxy.h; sourceTree = "<group>"; };
@@ -3016,6 +3020,8 @@
 		1A44B95816B73F8C00B7BBD8 /* Storage */ = {
 			isa = PBXGroup;
 			children = (
+				1A1D8B9F1731A36300141DA4 /* LocalStorageDatabase.cpp */,
+				1A1D8BA01731A36300141DA4 /* LocalStorageDatabase.h */,
 				1A44B95916B73F9F00B7BBD8 /* StorageManager.cpp */,
 				1A44B95A16B73F9F00B7BBD8 /* StorageManager.h */,
 				1AB31A9316BC65AB00F6DBC9 /* StorageManager.messages.in */,
@@ -5723,6 +5729,7 @@
 				318BE17114743DB100A8FBB2 /* WKNotificationManager.h in Headers */,
 				31A2EC74148D59CA00810D71 /* WKNotificationPermissionRequest.h in Headers */,
 				312C0C4A146DDC8A0016C911 /* WKNotificationProvider.h in Headers */,
+				1A1D8BA21731A36300141DA4 /* LocalStorageDatabase.h in Headers */,
 				BC407602124FF0270068F20A /* WKNumber.h in Headers */,
 				BC857FE612B843D800EDEB2E /* WKOpenPanelParameters.h in Headers */,
 				BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */,
@@ -6755,6 +6762,7 @@
 				512935D71288D19400A4B695 /* WebContextMenuItem.cpp in Sources */,
 				510FBB9A1288C95E00AFFDF4 /* WebContextMenuItemData.cpp in Sources */,
 				51A84CE3127F386B00CA6EA4 /* WebContextMenuProxy.cpp in Sources */,
+				1A1D8BA11731A36300141DA4 /* LocalStorageDatabase.cpp in Sources */,
 				51ACBBA1127A8F2C00D203B9 /* WebContextMenuProxyMac.mm in Sources */,
 				BCEE7D0D12846F69009827DA /* WebContextMessageReceiver.cpp in Sources */,
 				3309344F1315B94D0097A7BC /* WebCookieManager.cpp in Sources */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to