[WK2][EFL] Use WebsiteDataStore instead of WebDatabaseManager which has been deleted...
authorjh718.park@samsung.com <jh718.park@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Dec 2015 02:54:32 +0000 (02:54 +0000)
committerjh718.park@samsung.com <jh718.park@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Dec 2015 02:54:32 +0000 (02:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152460

Reviewed by Gyuyoung Kim.

Use WebsiteDataStore to support EFL WebDatabase API and to fix build break.

* PlatformEfl.cmake:
* UIProcess/API/APIWebsiteDataStore.cpp:
* UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp: Copied from Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp.
(API::WebsiteDataStore::defaultApplicationCacheDirectory):
(API::WebsiteDataStore::defaultNetworkCacheDirectory):
(API::WebsiteDataStore::defaultIndexedDBDatabaseDirectory):
(API::WebsiteDataStore::defaultLocalStorageDirectory):
(API::WebsiteDataStore::defaultMediaKeysStorageDirectory):
(API::WebsiteDataStore::defaultWebSQLDatabaseDirectory):
(API::WebsiteDataStore::cacheDirectoryFileSystemRepresentation):
(API::WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation):
(API::WebsiteDataStore::defaultDataStoreConfiguration):
* UIProcess/API/efl/ewk_context.cpp:
(EwkContext::EwkContext):
* UIProcess/API/efl/ewk_database_manager.cpp:
(EwkDatabaseManager::EwkDatabaseManager):
(EwkDatabaseManager::getDatabaseOrigins):
* UIProcess/API/efl/ewk_database_manager_private.h:
* UIProcess/efl/WebProcessPoolEfl.cpp:
(WebKit::WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultLocalStorageDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory):

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

Source/WebKit2/ChangeLog
Source/WebKit2/PlatformEfl.cmake
Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp
Source/WebKit2/UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
Source/WebKit2/UIProcess/API/efl/ewk_database_manager.cpp
Source/WebKit2/UIProcess/API/efl/ewk_database_manager_private.h
Source/WebKit2/UIProcess/efl/WebProcessPoolEfl.cpp

index af7658a..e6afb21 100644 (file)
@@ -1,3 +1,38 @@
+2015-12-20  Joonghun Park  <jh718.park@samsung.com>
+
+        [WK2][EFL] Use WebsiteDataStore instead of WebDatabaseManager which has been deleted in r194295
+        https://bugs.webkit.org/show_bug.cgi?id=152460
+
+        Reviewed by Gyuyoung Kim.
+
+        Use WebsiteDataStore to support EFL WebDatabase API and to fix build break.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/APIWebsiteDataStore.cpp:
+        * UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp: Copied from Source/WebKit2/UIProcess/API/APIWebsiteDataStore.cpp.
+        (API::WebsiteDataStore::defaultApplicationCacheDirectory):
+        (API::WebsiteDataStore::defaultNetworkCacheDirectory):
+        (API::WebsiteDataStore::defaultIndexedDBDatabaseDirectory):
+        (API::WebsiteDataStore::defaultLocalStorageDirectory):
+        (API::WebsiteDataStore::defaultMediaKeysStorageDirectory):
+        (API::WebsiteDataStore::defaultWebSQLDatabaseDirectory):
+        (API::WebsiteDataStore::cacheDirectoryFileSystemRepresentation):
+        (API::WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation):
+        (API::WebsiteDataStore::defaultDataStoreConfiguration):
+        * UIProcess/API/efl/ewk_context.cpp:
+        (EwkContext::EwkContext):
+        * UIProcess/API/efl/ewk_database_manager.cpp:
+        (EwkDatabaseManager::EwkDatabaseManager):
+        (EwkDatabaseManager::getDatabaseOrigins):
+        * UIProcess/API/efl/ewk_database_manager_private.h:
+        * UIProcess/efl/WebProcessPoolEfl.cpp:
+        (WebKit::WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultLocalStorageDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory):
+
 2015-12-20  Dan Bernstein  <mitz@apple.com>
 
         Remove unused setToolbarHeight
index ce8dae0..d305b2d 100644 (file)
@@ -83,6 +83,7 @@ list(APPEND WebKit2_SOURCES
 
     UIProcess/API/cpp/efl/WKEinaSharedString.cpp
 
+    UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp
     UIProcess/API/efl/EwkView.cpp
     UIProcess/API/efl/GestureRecognizer.cpp
     UIProcess/API/efl/SnapshotImageGL.cpp
index b4d52df..af29157 100644 (file)
@@ -66,7 +66,7 @@ bool WebsiteDataStore::isPersistent()
     return m_websiteDataStore->isPersistent();
 }
 
-#if !PLATFORM(COCOA) && !PLATFORM(GTK)
+#if !PLATFORM(COCOA) && !PLATFORM(EFL) && !PLATFORM(GTK)
 WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration()
 {
     // FIXME: Fill everything in.
diff --git a/Source/WebKit2/UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp b/Source/WebKit2/UIProcess/API/efl/APIWebsiteDataStoreEfl.cpp
new file mode 100644 (file)
index 0000000..bac53fa
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2015 Samsung Electronics
+ *
+ * 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 "APIWebsiteDataStore.h"
+
+#include <Efreet.h>
+#include <wtf/text/StringBuilder.h>
+
+namespace API {
+
+String WebsiteDataStore::defaultApplicationCacheDirectory()
+{
+    return String::fromUTF8(efreet_cache_home_get()) + "/WebKitEfl/Applications";
+}
+
+String WebsiteDataStore::defaultNetworkCacheDirectory()
+{
+#if ENABLE(NETWORK_CACHE)
+    static const char networkCacheSubdirectory[] = "WebKitCache";
+#else
+    static const char networkCacheSubdirectory[] = "webkit";
+#endif
+
+    StringBuilder diskCacheDirectory;
+    diskCacheDirectory.append(efreet_cache_home_get());
+    diskCacheDirectory.appendLiteral("/");
+    diskCacheDirectory.append(networkCacheSubdirectory);
+
+    return diskCacheDirectory.toString();
+}
+
+String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
+{
+    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/IndexedDB";
+}
+
+String WebsiteDataStore::defaultLocalStorageDirectory()
+{
+    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/LocalStorage";
+}
+
+String WebsiteDataStore::defaultMediaKeysStorageDirectory()
+{
+    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/MediaKeys";
+}
+
+String WebsiteDataStore::defaultWebSQLDatabaseDirectory()
+{
+    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/Databases";
+}
+
+String WebsiteDataStore::cacheDirectoryFileSystemRepresentation(const String& directoryName)
+{
+    return String::fromUTF8(efreet_cache_home_get()) + directoryName;
+}
+
+String WebsiteDataStore::websiteDataDirectoryFileSystemRepresentation(const String& directoryName)
+{
+    return String::fromUTF8(efreet_data_home_get()) + directoryName;
+}
+
+WebKit::WebsiteDataStore::Configuration WebsiteDataStore::defaultDataStoreConfiguration()
+{
+    WebKit::WebsiteDataStore::Configuration configuration;
+
+    configuration.applicationCacheDirectory = defaultApplicationCacheDirectory();
+    configuration.networkCacheDirectory = defaultNetworkCacheDirectory();
+
+    configuration.webSQLDatabaseDirectory = defaultWebSQLDatabaseDirectory();
+    configuration.localStorageDirectory = defaultLocalStorageDirectory();
+    configuration.mediaKeysStorageDirectory = defaultMediaKeysStorageDirectory();
+
+    return configuration;
+}
+
+} // namespace API
index a530ef5..600c912 100644 (file)
@@ -66,7 +66,7 @@ static inline ContextMap& contextMap()
 
 EwkContext::EwkContext(WKContextRef context, const String& extensionsPath)
     : m_context(context)
-    , m_databaseManager(std::make_unique<EwkDatabaseManager>(WKContextGetDatabaseManager(context)))
+    , m_databaseManager(std::make_unique<EwkDatabaseManager>())
     , m_storageManager(std::make_unique<EwkStorageManager>(WKContextGetKeyValueStorageManager(context)))
 #if ENABLE(BATTERY_STATUS)
     , m_batteryProvider(BatteryProvider::create(context))
index 4fdbe65..037d1c0 100644 (file)
 #include "config.h"
 #include "ewk_database_manager.h"
 
+#include "APIWebsiteDataStore.h"
+#include "GenericCallback.h"
 #include "WKAPICast.h"
 #include "WKArray.h"
 #include "ewk_database_manager_private.h"
 #include "ewk_security_origin_private.h"
+#include <WebCore/DatabaseTracker.h>
+#include <WebCore/OriginLock.h>
+#include <WebCore/SecurityOrigin.h>
 
 using namespace WebKit;
 
-EwkDatabaseManager::EwkDatabaseManager(WKDatabaseManagerRef databaseManager)
-    : m_databaseManager(databaseManager)
+typedef GenericCallback<API::Array*> ArrayCallback;
+
+EwkDatabaseManager::EwkDatabaseManager()
 {
-    ASSERT(databaseManager);
 }
 
-void EwkDatabaseManager::getDatabaseOrigins(WKDatabaseManagerGetDatabaseOriginsFunction callback, void* context) const
+void EwkDatabaseManager::getDatabaseOrigins(Ewk_Database_Manager_Get_Database_Origins_Function callback, void* context) const
 {
-    WKDatabaseManagerGetDatabaseOrigins(m_databaseManager.get(), context, callback);
+    if (!callback)
+        return;
+
+    RefPtr<ArrayCallback> arrayCallback = ArrayCallback::create(toGenericCallbackFunction(context, callback));
+
+    Vector<RefPtr<WebCore::SecurityOrigin>> origins;
+    Vector<RefPtr<API::Object>> securityOrigins;
+
+    WebCore::DatabaseTracker::trackerWithDatabasePath(API::WebsiteDataStore::defaultWebSQLDatabaseDirectory())->origins(origins);
+    securityOrigins.reserveInitialCapacity(origins.size());
+
+    for (const auto& originIdentifier : origins)
+        securityOrigins.uncheckedAppend(API::SecurityOrigin::create(*originIdentifier));
+
+    arrayCallback->performCallbackWithReturnValue(API::Array::create(WTF::move(securityOrigins)).ptr());
 }
 
 Eina_List* EwkDatabaseManager::createOriginList(WKArrayRef origins) const
index 0ee1f08..69f19d6 100644 (file)
 #ifndef ewk_database_manager_private_h
 #define ewk_database_manager_private_h
 
-#include "WKDatabaseManager.h"
 #include "WKRetainPtr.h"
+#include "WebsiteDataStore.h"
 #include "ewk_security_origin_private.h"
 #include <WebKit/WKBase.h>
 
 using namespace WebKit;
 
+typedef void (*Ewk_Database_Manager_Get_Database_Origins_Function)(WKArrayRef, WKErrorRef, void*);
+
 class EwkDatabaseManager {
 public:
-    explicit EwkDatabaseManager(WKDatabaseManagerRef);
+    EwkDatabaseManager();
 
     Eina_List* createOriginList(WKArrayRef wkList) const;
-    void getDatabaseOrigins(WKDatabaseManagerGetDatabaseOriginsFunction callback, void* context) const;
+    void getDatabaseOrigins(Ewk_Database_Manager_Get_Database_Origins_Function callback, void* context) const;
 
 private:
-    WKRetainPtr<WKDatabaseManagerRef> m_databaseManager;
     mutable HashMap<WKSecurityOriginRef, RefPtr<EwkSecurityOrigin> > m_wrapperCache;
 };
 #endif // ewk_database_manager_private_h
index 5c560fb..67791e6 100644 (file)
@@ -84,7 +84,7 @@ static void initializeInspectorServer()
 
 String WebProcessPool::legacyPlatformDefaultApplicationCacheDirectory()
 {
-    return String::fromUTF8(efreet_cache_home_get()) + "/WebKitEfl/Applications";
+    return API::WebsiteDataStore::defaultApplicationCacheDirectory();
 }
 
 void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
@@ -99,12 +99,12 @@ void WebProcessPool::platformInvalidateContext()
 
 String WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory()
 {
-    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/Databases";
+    return API::WebsiteDataStore::defaultWebSQLDatabaseDirectory();
 }
 
 String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
 {
-    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/IndexedDB";
+    return API::WebsiteDataStore::defaultIndexedDBDatabaseDirectory();
 }
 
 String WebProcessPool::platformDefaultIconDatabasePath() const
@@ -114,28 +114,17 @@ String WebProcessPool::platformDefaultIconDatabasePath() const
 
 String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
 {
-    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/LocalStorage";
+    return API::WebsiteDataStore::defaultLocalStorageDirectory();
 }
 
 String WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory()
 {
-    return String::fromUTF8(efreet_data_home_get()) + "/WebKitEfl/MediaKeys";
+    return API::WebsiteDataStore::defaultMediaKeysStorageDirectory();
 }
 
 String WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory()
 {
-#if ENABLE(NETWORK_CACHE)
-    static const char networkCacheSubdirectory[] = "WebKitCache";
-#else
-    static const char networkCacheSubdirectory[] = "webkit";
-#endif
-
-    StringBuilder diskCacheDirectory;
-    diskCacheDirectory.append(efreet_cache_home_get());
-    diskCacheDirectory.appendLiteral("/");
-    diskCacheDirectory.append(networkCacheSubdirectory);
-
-    return diskCacheDirectory.toString();
+    return API::WebsiteDataStore::defaultNetworkCacheDirectory();
 }
 
 void WebProcessPool::setIgnoreTLSErrors(bool ignoreTLSErrors)