2011-01-24 Maciej Stachowiak <mjs@apple.com>
authormjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jan 2011 02:08:52 +0000 (02:08 +0000)
committermjs@apple.com <mjs@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jan 2011 02:08:52 +0000 (02:08 +0000)
        Reviewed by Anders Carlsson.

        Use designated temp directory for the database for WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=53052

        Adopt the new WK2 API for this.

        * WebKitTestRunner/TestController.cpp:
        (WTR::TestController::libraryPathForTesting):
        (WTR::TestController::initialize):
        * WebKitTestRunner/TestController.h:
        * WebKitTestRunner/mac/TestControllerMac.mm:
        (WTR::TestController::platformLibraryPathForTesting):
        * WebKitTestRunner/qt/TestControllerQt.cpp:
        (WTR::TestController::platformLibraryPathForTesting):
        * WebKitTestRunner/win/TestControllerWin.cpp:
        (WTR::TestController::platformLibraryPathForTesting):
2011-01-24  Maciej Stachowiak  <mjs@apple.com>

        Reviewed by Anders Carlsson.

        Use designated temp directory for the database for WebKit2
        https://bugs.webkit.org/show_bug.cgi?id=53052

        Add the API necessary to support this. Database path is now
        determined on the UI process side and passed to the Web process.
        Reviewed by Anders Carlsson.

        * GNUmakefile.am:
        * Shared/WebProcessCreationParameters.cpp:
        (WebKit::WebProcessCreationParameters::encode):
        (WebKit::WebProcessCreationParameters::decode):
        * Shared/WebProcessCreationParameters.h:
        * UIProcess/API/C/WKContext.cpp:
        (WKContextSetDatabaseDirectory):
        * UIProcess/API/C/WKContextPrivate.h:
        * UIProcess/WebContext.cpp:
        (WebKit::WebContext::ensureWebProcess):
        (WebKit::WebContext::databaseDirectory):
        * UIProcess/WebContext.h:
        (WebKit::WebContext::setDatabaseDirectory):
        * UIProcess/mac/WebContextMac.mm:
        (WebKit::WebContext::platformDefaultDatabaseDirectory):
        * UIProcess/qt/WebContextQt.cpp:
        (WebKit::WebContext::platformDefaultDatabaseDirectory):
        * UIProcess/win/WebContextWin.cpp:
        (WebKit::WebContext::platformDefaultDatabaseDirectory):
        * WebKit2.pro:
        * WebKit2.xcodeproj/project.pbxproj:
        * WebProcess/WebCoreSupport/WebDatabaseManager.cpp:
        (WebKit::WebDatabaseManager::initialize):
        (WebKit::WebDatabaseManager::WebDatabaseManager):
        * WebProcess/WebCoreSupport/WebDatabaseManager.h:
        * WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp: Removed.
        * WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm: Removed.
        * WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp: Removed.
        * WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp: Removed.
        * WebProcess/WebProcess.cpp:
        (WebKit::WebProcess::WebProcess):
        (WebKit::WebProcess::initializeWebProcess):
        * WebProcess/com.apple.WebProcess.sb:
        * WebProcess/mac/WebProcessMac.mm:
        (WebKit::initializeSandbox):
        * win/WebKit2.vcproj:

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

29 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/API/C/WKContext.cpp
Source/WebKit2/UIProcess/API/C/WKContextPrivate.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/UIProcess/WebContext.h
Source/WebKit2/UIProcess/mac/WebContextMac.mm
Source/WebKit2/UIProcess/qt/WebContextQt.cpp
Source/WebKit2/UIProcess/win/WebContextWin.cpp
Source/WebKit2/WebKit2.pro
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebDatabaseManager.h
Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp [deleted file]
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm [deleted file]
Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp [deleted file]
Source/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp [deleted file]
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/com.apple.WebProcess.sb
Source/WebKit2/WebProcess/mac/WebProcessMac.mm
Source/WebKit2/win/WebKit2.vcproj
Tools/ChangeLog
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/mac/TestControllerMac.mm
Tools/WebKitTestRunner/qt/TestControllerQt.cpp
Tools/WebKitTestRunner/win/TestControllerWin.cpp

index 7842bdc..cf342a2 100644 (file)
@@ -1,3 +1,51 @@
+2011-01-24  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Use designated temp directory for the database for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=53052
+        
+        Add the API necessary to support this. Database path is now
+        determined on the UI process side and passed to the Web process.
+        Reviewed by Anders Carlsson.
+
+        * GNUmakefile.am:
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetDatabaseDirectory):
+        * UIProcess/API/C/WKContextPrivate.h:
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::ensureWebProcess):
+        (WebKit::WebContext::databaseDirectory):
+        * UIProcess/WebContext.h:
+        (WebKit::WebContext::setDatabaseDirectory):
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::platformDefaultDatabaseDirectory):
+        * UIProcess/qt/WebContextQt.cpp:
+        (WebKit::WebContext::platformDefaultDatabaseDirectory):
+        * UIProcess/win/WebContextWin.cpp:
+        (WebKit::WebContext::platformDefaultDatabaseDirectory):
+        * WebKit2.pro:
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/WebCoreSupport/WebDatabaseManager.cpp:
+        (WebKit::WebDatabaseManager::initialize):
+        (WebKit::WebDatabaseManager::WebDatabaseManager):
+        * WebProcess/WebCoreSupport/WebDatabaseManager.h:
+        * WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp: Removed.
+        * WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm: Removed.
+        * WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp: Removed.
+        * WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp: Removed.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        (WebKit::WebProcess::initializeWebProcess):
+        * WebProcess/com.apple.WebProcess.sb:
+        * WebProcess/mac/WebProcessMac.mm:
+        (WebKit::initializeSandbox):
+        * win/WebKit2.vcproj:
+
 2011-01-24  Brent Fulgham  <bfulgham@webkit.org>
 
         Unreviewed build fix.
index be64c8e..0582f69 100644 (file)
@@ -323,6 +323,7 @@ libWebKit2_la_SOURCES = \
        Source/WebKit2/UIProcess/FindIndicator.h \
        Source/WebKit2/UIProcess/GenericCallback.h \
        Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp \
+       Source/WebKit2/UIProcess/gtk/WebContextGtk.cpp \
        Source/WebKit2/UIProcess/gtk/WebInspectorGtk.cpp \
        Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp \
        Source/WebKit2/UIProcess/gtk/WebPreferencesGtk.cpp \
@@ -504,7 +505,6 @@ libWebKit2_la_SOURCES = \
        Source/WebKit2/WebProcess/Plugins/PluginView.cpp \
        Source/WebKit2/WebProcess/Plugins/PluginView.h \
        Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebContextMenuClientGtk.cpp \
-       Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebFrameNetworkingContext.h \
        Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebPopupMenuGtk.cpp \
        Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp \
index 77e3a82..5e67458 100644 (file)
@@ -46,6 +46,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(injectedBundlePath);
     encoder->encode(injectedBundlePathExtensionHandle);
     encoder->encode(applicationCacheDirectory);
+    encoder->encode(databaseDirectory);
     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
     encoder->encode(urlSchemesRegisteredAsSecure);
     encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
@@ -76,6 +77,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
     if (!decoder->decode(parameters.applicationCacheDirectory))
         return false;
+    if (!decoder->decode(parameters.databaseDirectory))
+        return false;
     if (!decoder->decode(parameters.urlSchemesRegistererdAsEmptyDocument))
         return false;
     if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
index 50d8a90..b157c94 100644 (file)
@@ -53,6 +53,7 @@ struct WebProcessCreationParameters {
     SandboxExtension::Handle injectedBundlePathExtensionHandle;
 
     String applicationCacheDirectory;
+    String databaseDirectory;
     Vector<String> urlSchemesRegistererdAsEmptyDocument;
     Vector<String> urlSchemesRegisteredAsSecure;
     Vector<String> urlSchemesForWhichDomainRelaxationIsForbidden;
index c207225..e60ebc0 100644 (file)
@@ -176,3 +176,8 @@ void WKContextStopMemorySampler(WKContextRef contextRef)
 {
     toImpl(contextRef)->stopMemorySampler();
 }
+
+void WKContextSetDatabaseDirectory(WKContextRef contextRef, WKStringRef databaseDirectory)
+{
+    toImpl(contextRef)->setDatabaseDirectory(toImpl(databaseDirectory)->string());
+}
index 8bcb1b6..bcd24a5 100644 (file)
@@ -54,6 +54,10 @@ WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKString
 
 WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme);
 
+// FIXME: This function is only effective if called before the Web process is launched. But
+// we should really change this setting to be on WebPreferences and changeable at runtime.
+WK_EXPORT void WKContextSetDatabaseDirectory(WKContextRef context, WKStringRef databaseDirectory);
+
 #ifdef __cplusplus
 }
 #endif
index 1bb6bc4..03dcaaf 100644 (file)
@@ -176,6 +176,7 @@ void WebContext::ensureWebProcess()
     parameters.cacheModel = m_cacheModel;
     parameters.languageCode = defaultLanguage();
     parameters.applicationCacheDirectory = applicationCacheDirectory();
+    parameters.databaseDirectory = databaseDirectory();
     parameters.clearResourceCaches = m_clearResourceCachesForNewWebProcess;
     parameters.clearApplicationCache = m_clearApplicationCacheForNewWebProcess;
 #if PLATFORM(MAC)
@@ -602,4 +603,12 @@ void WebContext::stopMemorySampler()
     m_process->send(Messages::WebProcess::StopMemorySampler(), 0);
 }
 
+String WebContext::databaseDirectory() const
+{
+    if (!m_overrideDatabaseDirectory.isEmpty())
+        return m_overrideDatabaseDirectory;
+
+    return platformDefaultDatabaseDirectory();
+}
+
 } // namespace WebKit
index e973160..ebf1914 100644 (file)
@@ -137,6 +137,8 @@ public:
     };
     static Statistics& statistics();
 
+    void setDatabaseDirectory(const String& dir) { m_overrideDatabaseDirectory = dir; }
+
 private:
     WebContext(ProcessModel, const String& injectedBundlePath);
 
@@ -162,6 +164,9 @@ private:
     static void languageChanged(void* context);
     void languageChanged();
 
+    String databaseDirectory() const;
+    String platformDefaultDatabaseDirectory() const;
+
     ProcessModel m_processModel;
     
     // FIXME: In the future, this should be one or more WebProcessProxies.
@@ -203,6 +208,8 @@ private:
 #if PLATFORM(WIN)
     bool m_shouldPaintNativeControls;
 #endif
+
+    String m_overrideDatabaseDirectory;
 };
 
 } // namespace WebKit
index a0e3b05..3bc3253 100644 (file)
@@ -90,5 +90,10 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     parameters.uiProcessBundleResourcePath = fileSystemRepresentation([[NSBundle mainBundle] resourcePath]);
 }
 
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+    return [@"~/Library/WebKit/Databases" stringByStandardizingPath];
+}
+
 } // namespace WebKit
 
index f6b846d..5241b67 100644 (file)
@@ -46,4 +46,10 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters&)
     qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
 }
 
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+    // FIXME: Implement.
+    return "";
+}
+
 } // namespace WebKit
index 83b586d..001436f 100644 (file)
@@ -52,5 +52,10 @@ void WebContext::platformInitializeWebProcess(WebProcessCreationParameters& para
     parameters.shouldPaintNativeControls = m_shouldPaintNativeControls;
 }
 
+String WebContext::platformDefaultDatabaseDirectory() const
+{
+    return WebCore::pathByAppendingComponent(WebCore::localUserSpecificStorageDirectory(), "Databases");
+}
+
 } // namespace WebKit
 
index ea98904..632c3d1 100644 (file)
@@ -663,7 +663,6 @@ SOURCES += \
     WebProcess/WebCoreSupport/WebPopupMenu.cpp \
     WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp \
     WebProcess/WebCoreSupport/qt/WebContextMenuClientQt.cpp \
-    WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp \
     WebProcess/WebCoreSupport/qt/WebErrorsQt.cpp \
     WebProcess/WebCoreSupport/qt/WebFrameNetworkingContext.cpp \
     WebProcess/WebCoreSupport/qt/WebPopupMenuQt.cpp \
index fed1ef6..a2b9d9a 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 */
                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 */
                        children = (
                                C554FFA212E4E8EA002F22C0 /* WebDragClientMac.mm */,
                                51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */,
-                               F6A25FD812ADC6BD00DC40CC /* WebDatabaseManagerMac.mm */,
                                C5237F5F12441CA300780472 /* WebEditorClientMac.mm */,
                                BC111ADF112F5BC200337BAB /* WebErrorsMac.mm */,
                                9391F283121B38F500EBF7E8 /* WebFrameNetworkingContext.h */,
                                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 */,
                                51021E9C12B16788005C033C /* WebContextMenuClientMac.mm in Sources */,
                                1AAF061512B01131008E49E2 /* PDFViewController.mm in Sources */,
index cc61b04..5c1d159 100644 (file)
@@ -45,9 +45,13 @@ WebDatabaseManager& WebDatabaseManager::shared()
     return shared;
 }
 
+void WebDatabaseManager::initialize(const String& databaseDirectory)
+{
+    DatabaseTracker::initializeTracker(databaseDirectory);
+}
+
 WebDatabaseManager::WebDatabaseManager()
 {
-    DatabaseTracker::initializeTracker(databaseDirectory());
     DatabaseTracker::tracker().setClient(this);
 }
 
index 4701645..96ed83e 100644 (file)
@@ -43,6 +43,7 @@ class WebDatabaseManager : public WebCore::DatabaseTrackerClient {
     WTF_MAKE_NONCOPYABLE(WebDatabaseManager);
 public:
     static WebDatabaseManager& shared();
+    static void initialize(const String& databaseDirectory);
 
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::ArgumentDecoder*);
 
@@ -63,8 +64,6 @@ private:
     // WebCore::DatabaseTrackerClient
     virtual void dispatchDidModifyOrigin(WebCore::SecurityOrigin*);
     virtual void dispatchDidModifyDatabase(WebCore::SecurityOrigin*, const String& databaseIdentifier);
-
-    String databaseDirectory() const;
 };
 
 } // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebDatabaseManagerGtk.cpp
deleted file mode 100644 (file)
index b3c1289..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Portions Copyright (c) 2010 Motorola Mobility, 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 "NotImplemented.h"
-
-namespace WebKit {
-
-String WebDatabaseManager::databaseDirectory() const
-{
-    notImplemented();
-    return String();
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm b/Source/WebKit2/WebProcess/WebCoreSupport/mac/WebDatabaseManagerMac.mm
deleted file mode 100644 (file)
index a7b708a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-
-#import "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/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/qt/WebDatabaseManagerQt.cpp
deleted file mode 100644 (file)
index 11f929c..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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 {
-
-String WebDatabaseManager::databaseDirectory() const
-{
-    // FIXME: Implement.
-    return "";
-}
-
-} // namespace WebKit
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/win/WebDatabaseManagerWin.cpp
deleted file mode 100644 (file)
index b6d15fd..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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 47f4125..4247c9c 100644 (file)
@@ -119,11 +119,6 @@ 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)
@@ -159,6 +154,11 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame
         }
     }
 
+#if ENABLE(DATABASE)
+    // Make sure the WebDatabaseManager is initialized so that the Database directory is set.
+    WebDatabaseManager::initialize(parameters.databaseDirectory);
+#endif
+
 #if ENABLE(OFFLINE_WEB_APPLICATIONS)
     if (!parameters.applicationCacheDirectory.isEmpty())
         cacheStorage().setCacheDirectory(parameters.applicationCacheDirectory);
index df57bde..030e0d5 100644 (file)
 (if (positive? (string-length (param "DARWIN_USER_TEMP_DIR")))
     (allow file* (subpath (param "DARWIN_USER_TEMP_DIR"))))
 
+;; Database dir
+(if (positive? (string-length (param "WEBKIT_DATABASE_DIR")))
+    (allow file* (subpath (param "WEBKIT_DATABASE_DIR"))))
+
 ;; The NSURLCache directory.
 (if (positive? (string-length (param "NSURL_CACHE_DIR")))
     (allow file* (subpath (param "NSURL_CACHE_DIR"))))
index 80ff722..7fa0194 100644 (file)
@@ -135,6 +135,7 @@ static void initializeSandbox(const WebProcessCreationParameters& parameters)
         "WEBKIT2_FRAMEWORK_DIR", frameworkPath,
         "DARWIN_USER_TEMP_DIR", (const char*)tmpRealPath,
         "DARWIN_USER_CACHE_DIR", (const char*)cacheRealPath,
+        "WEBKIT_DATABASE_DIR", (const char*)parameters.databaseDirectory.data(),
         "NSURL_CACHE_DIR", (const char*)parameters.nsURLCachePath.data(),
         "UI_PROCESS_BUNDLE_RESOURCE_DIR", (const char*)parameters.uiProcessBundleResourcePath.data(),
         NULL
index 9c612c2..e8c0be1 100755 (executable)
                                                >
                                        </File>
                                        <File
-                                               RelativePath="..\WebProcess\WebCoreSupport\win\WebDatabaseManagerWin.cpp"
-                                               >
-                                       </File>
-                                       <File
                                                RelativePath="..\WebProcess\WebCoreSupport\win\WebErrorsWin.cpp"
                                                >
                                        </File>
index 8dd03ff..e5c64db 100644 (file)
@@ -1,3 +1,23 @@
+2011-01-24  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Anders Carlsson.
+
+        Use designated temp directory for the database for WebKit2
+        https://bugs.webkit.org/show_bug.cgi?id=53052
+        
+        Adopt the new WK2 API for this.
+
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::libraryPathForTesting):
+        (WTR::TestController::initialize):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        (WTR::TestController::platformLibraryPathForTesting):
+        * WebKitTestRunner/qt/TestControllerQt.cpp:
+        (WTR::TestController::platformLibraryPathForTesting):
+        * WebKitTestRunner/win/TestControllerWin.cpp:
+        (WTR::TestController::platformLibraryPathForTesting):
+
 2011-01-24  Lucas Forschler  <lforschler@apple.com>
 
         Reviewed by Stephanie Lewis.
index e856176..23a8732 100644 (file)
@@ -32,6 +32,7 @@
 #include <WebKit2/WKPageGroup.h>
 #include <WebKit2/WKContextPrivate.h>
 #include <WebKit2/WKPreferencesPrivate.h>
+#include <WebKit2/WKRetainPtr.h>
 #include <wtf/PassOwnPtr.h>
 
 namespace WTR {
@@ -164,6 +165,18 @@ WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKDictionaryRef, WK
     return newPage;
 }
 
+const char* TestController::libraryPathForTesting()
+{
+    // FIXME: This may not be sufficient to prevent interactions/crashes
+    // when running more than one copy of DumpRenderTree.
+    // See https://bugs.webkit.org/show_bug.cgi?id=10906
+    char* dumpRenderTreeTemp = getenv("DUMPRENDERTREE_TEMP");
+    if (dumpRenderTreeTemp)
+        return dumpRenderTreeTemp;
+    return platformLibraryPathForTesting();
+}
+
+
 void TestController::initialize(int argc, const char* argv[])
 {
     platformInitialize();
@@ -219,6 +232,15 @@ void TestController::initialize(int argc, const char* argv[])
     m_pageGroup.adopt(WKPageGroupCreateWithIdentifier(pageGroupIdentifier.get()));
 
     m_context.adopt(WKContextCreateWithInjectedBundlePath(injectedBundlePath()));
+
+    const char* path = libraryPathForTesting();
+    if (path) {
+        Vector<char> databaseDirectory(strlen(path) + strlen("/Databases"));
+        sprintf(databaseDirectory.data(), "%s%s", path, "/Databases");
+        WKRetainPtr<WKStringRef> databaseDirectoryWK(AdoptWK, WKStringCreateWithUTF8CString(databaseDirectory.data()));
+        WKContextSetDatabaseDirectory(m_context.get(), databaseDirectoryWK.get());
+    }
+
     platformInitializeContext();
 
     WKContextInjectedBundleClient injectedBundleClient = {
index 65305a2..fe37952 100644 (file)
@@ -90,6 +90,9 @@ private:
     static void runModal(WKPageRef, const void* clientInfo);
     static void runModal(PlatformWebView*);
 
+    static const char* libraryPathForTesting();
+    static const char* platformLibraryPathForTesting();
+
     OwnPtr<TestInvocation> m_currentInvocation;
 
     bool m_dumpPixels;
index 8107890..8ceabc1 100644 (file)
@@ -71,4 +71,9 @@ void TestController::runModal(PlatformWebView* view)
     [NSApp runModalForWindow:window];
 }
 
+const char* TestController::platformLibraryPathForTesting()
+{
+    return [[@"~/Library/Application Support/DumpRenderTree" stringByExpandingTildeInPath] UTF8String];
+}
+
 } // namespace WTR
index df977fb..30a1b5c 100644 (file)
@@ -133,6 +133,11 @@ void TestController::runModal(PlatformWebView*)
     // FIXME: Need to implement this to test showModalDialog.
 }
 
+const char* TestController::platformLibraryPathForTesting()
+{
+    return 0;
+}
+
 #include "TestControllerQt.moc"
 
 } // namespace WTR
index 08f188f..5af5503 100644 (file)
@@ -157,4 +157,9 @@ void TestController::runModal(PlatformWebView*)
     // FIXME: Need to implement this to test showModalDialog.
 }
 
+const char* TestController::platformLibraryPathForTesting()
+{
+    return 0;
+}
+
 } // namespace WTR