WebKit2: Need to set the location of the Databases directory when the WebProcess...
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Dec 2010 17:27:10 +0000 (17:27 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Dec 2010 17:27:10 +0000 (17:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=50604

Reviewed by Darin Adler.

* WebProcess/WebCoreSupport/WebDatabaseManager.cpp: Added.
(WebKit::WebDatabaseManager::shared):
(WebKit::WebDatabaseManager::WebDatabaseManager):
Initialize the DatabaseTracker with the Database directory.
* WebProcess/WebCoreSupport/WebDatabaseManager.h: Added.
* WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm: Added.
(WebKit::WebDatabaseManager::databaseDirectory):
Copied from WebKitInitializeDatabasesIfNecessary in WebKit/mac/Storage/WebDatabaseManager.mm.
* WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp: Added.
(WebKit::WebDatabaseManager::databaseDirectory):
Copied from WebKitInitializeWebDatabasesIfNecessary in WebKit/win/WebDatabaseManager.cpp.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
Make sure that the Databases directory has been set by calling WebDatabaseManager::shared().

* WebKit2.xcodeproj/project.pbxproj:
Add WebDatabaseManager.cpp/.h/Mac.cpp
* win/WebKit2.vcproj:
Add WebDatabaseManager.cpp/.h/Win.cpp

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

WebKit2/ChangeLog
WebKit2/WebKit2.xcodeproj/project.pbxproj
WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm [new file with mode: 0644]
WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp [new file with mode: 0644]
WebKit2/WebProcess/WebProcess.cpp
WebKit2/win/WebKit2.vcproj

index 43101ca..b6de3a2 100644 (file)
@@ -1,3 +1,31 @@
+2010-12-07  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        WebKit2: Need to set the location of the Databases directory when the WebProcess is initialized
+        https://bugs.webkit.org/show_bug.cgi?id=50604
+
+        * WebProcess/WebCoreSupport/WebDatabaseManager.cpp: Added.
+        (WebKit::WebDatabaseManager::shared):
+        (WebKit::WebDatabaseManager::WebDatabaseManager):
+        Initialize the DatabaseTracker with the Database directory.
+        * WebProcess/WebCoreSupport/WebDatabaseManager.h: Added.
+        * WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm: Added.
+        (WebKit::WebDatabaseManager::databaseDirectory):
+        Copied from WebKitInitializeDatabasesIfNecessary in WebKit/mac/Storage/WebDatabaseManager.mm.
+        * WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp: Added.
+        (WebKit::WebDatabaseManager::databaseDirectory):
+        Copied from WebKitInitializeWebDatabasesIfNecessary in WebKit/win/WebDatabaseManager.cpp.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        Make sure that the Databases directory has been set by calling WebDatabaseManager::shared().
+
+        * WebKit2.xcodeproj/project.pbxproj:
+        Add WebDatabaseManager.cpp/.h/Mac.cpp
+        * win/WebKit2.vcproj:
+        Add WebDatabaseManager.cpp/.h/Win.cpp
+
 2010-12-06  Darin Adler  <darin@apple.com>
 
         Reviewed by Sam Weinig.
index 9615ff1..7c7ab65 100644 (file)
                F634445C12A885E9000612D8 /* WKSecurityOrigin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F634445A12A885E9000612D8 /* WKSecurityOrigin.cpp */; };
                F634445D12A885E9000612D8 /* WKSecurityOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = F634445B12A885E9000612D8 /* WKSecurityOrigin.h */; settings = {ATTRIBUTES = (Public, ); }; };
                F67DD7BA125E40D9007BDCB8 /* WKSerializedScriptValuePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F67DD7B9125E40D9007BDCB8 /* WKSerializedScriptValuePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               F6A25FD912ADC6BD00DC40CC /* WebDatabaseManagerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6A25FD812ADC6BD00DC40CC /* WebDatabaseManagerMac.mm */; };
+               F6A25FDC12ADC6CC00DC40CC /* WebDatabaseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F6A25FDA12ADC6CC00DC40CC /* WebDatabaseManager.cpp */; };
+               F6A25FDD12ADC6CC00DC40CC /* WebDatabaseManager.h in Headers */ = {isa = PBXBuildFile; fileRef = F6A25FDB12ADC6CC00DC40CC /* WebDatabaseManager.h */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXContainerItemProxy section */
                F634445A12A885E9000612D8 /* WKSecurityOrigin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKSecurityOrigin.cpp; sourceTree = "<group>"; };
                F634445B12A885E9000612D8 /* WKSecurityOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSecurityOrigin.h; sourceTree = "<group>"; };
                F67DD7B9125E40D9007BDCB8 /* WKSerializedScriptValuePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKSerializedScriptValuePrivate.h; sourceTree = "<group>"; };
+               F6A25FD812ADC6BD00DC40CC /* WebDatabaseManagerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebDatabaseManagerMac.mm; sourceTree = "<group>"; };
+               F6A25FDA12ADC6CC00DC40CC /* WebDatabaseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebDatabaseManager.cpp; sourceTree = "<group>"; };
+               F6A25FDB12ADC6CC00DC40CC /* WebDatabaseManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseManager.h; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
                                BC032D6010F4378D0058C15A /* WebChromeClient.h */,
                                BC111A54112F4FBB00337BAB /* WebContextMenuClient.cpp */,
                                BC032D6210F4378D0058C15A /* WebContextMenuClient.h */,
+                               F6A25FDA12ADC6CC00DC40CC /* WebDatabaseManager.cpp */,
+                               F6A25FDB12ADC6CC00DC40CC /* WebDatabaseManager.h */,
                                BC111A56112F4FBB00337BAB /* WebDragClient.cpp */,
                                BC032D6610F4378D0058C15A /* WebDragClient.h */,
                                BC111A57112F4FBB00337BAB /* WebEditorClient.cpp */,
                BC111ADE112F5B9A00337BAB /* mac */ = {
                        isa = PBXGroup;
                        children = (
+                               F6A25FD812ADC6BD00DC40CC /* WebDatabaseManagerMac.mm */,
                                C5237F5F12441CA300780472 /* WebEditorClientMac.mm */,
                                BC111ADF112F5BC200337BAB /* WebErrorsMac.mm */,
                                9391F283121B38F500EBF7E8 /* WebFrameNetworkingContext.h */,
                                F634445D12A885E9000612D8 /* WKSecurityOrigin.h in Headers */,
                                BC2D021712AC41CB00E732A3 /* SameDocumentNavigationType.h in Headers */,
                                BC2D021912AC426C00E732A3 /* WKPageLoadTypes.h in Headers */,
+                               F6A25FDD12ADC6CC00DC40CC /* WebDatabaseManager.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                512F58F912A88A5400629530 /* WKCredential.cpp in Sources */,
                                512F58FB12A88A5400629530 /* WKProtectionSpace.cpp in Sources */,
                                F634445C12A885E9000612D8 /* WKSecurityOrigin.cpp in Sources */,
+                               F6A25FD912ADC6BD00DC40CC /* WebDatabaseManagerMac.mm in Sources */,
+                               F6A25FDC12ADC6CC00DC40CC /* WebDatabaseManager.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp b/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp
new file mode 100644 (file)
index 0000000..fc849b9
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 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 "WebDatabaseManager.h"
+
+#include <WebCore/DatabaseTracker.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebDatabaseManager& WebDatabaseManager::shared()
+{
+    static WebDatabaseManager& shared = *new WebDatabaseManager;
+    return shared;
+}
+
+WebDatabaseManager::WebDatabaseManager()
+{
+    DatabaseTracker::initializeTracker(databaseDirectory());
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h b/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h
new file mode 100644 (file)
index 0000000..86176f3
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 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 WebDatabaseManager_h
+#define WebDatabaseManager_h
+
+#include <wtf/Noncopyable.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+class WebDatabaseManager : public Noncopyable {
+public:
+    static WebDatabaseManager& shared();
+
+    // FIXME: Add methods to get the origins for which there are databases, delete the databases
+    // for an origin, and delete all the databases.
+    // https://bugs.webkit.org/show_bug.cgi?id=50606
+
+private:
+    WebDatabaseManager();
+
+    String databaseDirectory() const;
+};
+
+} // namespace WebKit
+
+#endif // WebDatabaseManager_h
diff --git a/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm b/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm
new file mode 100644 (file)
index 0000000..d4eb3ac
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2010 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 "WebDatabaseManager.h"
+
+namespace WebKit {
+
+NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory";
+
+String WebDatabaseManager::databaseDirectory() const
+{
+    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+    NSString *databasesDirectory = [defaults objectForKey:WebDatabaseDirectoryDefaultsKey];
+    if (!databasesDirectory || ![databasesDirectory isKindOfClass:[NSString class]])
+        databasesDirectory = @"~/Library/WebKit/Databases";
+
+    return [databasesDirectory stringByStandardizingPath];
+}
+
+} // namespace WebKit
diff --git a/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp b/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp
new file mode 100644 (file)
index 0000000..b6d15fd
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2010 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 "WebDatabaseManager.h"
+
+#include <WebCore/FileSystem.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+String WebDatabaseManager::databaseDirectory() const
+{
+    return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "Databases");
+}
+
+} // namespace WebKit
index 511805a..389f995 100644 (file)
@@ -33,6 +33,7 @@
 #include "RunLoop.h"
 #include "WebContextMessages.h"
 #include "WebCoreArgumentCoders.h"
+#include "WebDatabaseManager.h"
 #include "WebFrame.h"
 #include "WebPage.h"
 #include "WebPageCreationParameters.h"
@@ -105,6 +106,11 @@ WebProcess::WebProcess()
     // Initialize our platform strategies.
     WebPlatformStrategies::initialize();
 #endif // USE(PLATFORM_STRATEGIES)
+
+#if ENABLE(DATABASE)
+    // Make sure the WebDatabaseManager is initialized so that the Database directory is set.
+    WebDatabaseManager::shared();
+#endif
 }
 
 void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, RunLoop* runLoop)
index 134e6a5..add5939 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\WebProcess\WebCoreSupport\WebDatabaseManager.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\WebProcess\WebCoreSupport\WebDatabaseManager.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\WebProcess\WebCoreSupport\WebDragClient.cpp"
                                        >
                                </File>
                                        Name="win"
                                        >
                                        <File
+                                               RelativePath="..\WebProcess\WebCoreSupport\win\WebDatabaseManagerWin.cpp"
+                                               >
+                                       </File>
+                                       <File
                                                RelativePath="..\WebProcess\WebCoreSupport\win\WebErrorsWin.cpp"
                                                >
                                        </File>