Skip to content
Permalink
Browse files
[EFL] Add API for Web Database handling
https://bugs.webkit.org/show_bug.cgi?id=85178

Patch by Thiago Marcos P. Santos <thiago.santos@intel.com> on 2012-05-17
Reviewed by Antonio Gomes.

Source/WebKit:

Added the new Web Database API to the buildsystem.

* PlatformEfl.cmake:

Source/WebKit/efl:

Add API for Web Database. This API will allow a browser
to query information about size, name, filename and remove
databases based on the origin. It will be also possible to
list all databases for a given origin.

* ewk/EWebKit.h:
* ewk/ewk_security_origin.cpp:
(ewk_security_origin_web_database_get_all):
* ewk/ewk_security_origin.h:
* ewk/ewk_settings.cpp:
* ewk/ewk_settings.h:
* ewk/ewk_web_database.cpp: Added.
(_Ewk_Web_Database):
(ewk_web_database_display_name_get):
(ewk_web_database_expected_size_get):
(ewk_web_database_filename_get):
(ewk_web_database_name_get):
(ewk_web_database_security_origin_get):
(ewk_web_database_size_get):
(ewk_web_database_remove):
(ewk_web_database_remove_all):
(ewk_web_database_free):
(ewk_web_database_list_free):
(ewk_web_database_new):
* ewk/ewk_web_database.h: Added.
* ewk/ewk_web_database_private.h: Copied from Source/WebKit/efl/ewk/EWebKit.h.
(WebCore):

Tools:

Use the newly introduced Web Database API in EFL's DRT.

* DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
(DumpRenderTreeChrome::resetDefaultsToConsistentValues):
* DumpRenderTree/efl/LayoutTestControllerEfl.cpp:
(LayoutTestController::clearAllDatabases):

Canonical link: https://commits.webkit.org/104371@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@117464 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Thiago Marcos P. Santos authored and webkit-commit-queue committed May 17, 2012
1 parent 4e49d16 commit 148e3b7af47dc8f65822ac823a62ecdbfbc095c2
@@ -1,3 +1,14 @@
2012-05-17 Thiago Marcos P. Santos <thiago.santos@intel.com>

[EFL] Add API for Web Database handling
https://bugs.webkit.org/show_bug.cgi?id=85178

Reviewed by Antonio Gomes.

Added the new Web Database API to the buildsystem.

* PlatformEfl.cmake:

2012-05-17 Thiago Marcos P. Santos <thiago.santos@intel.com>

[EFL] Fix link error caused by not directly linking with edbus
@@ -120,6 +120,7 @@ LIST(APPEND WebKit_SOURCES
efl/ewk/ewk_view_single.cpp
efl/ewk/ewk_view_tiled.cpp
efl/ewk/ewk_window_features.cpp
efl/ewk/ewk_web_database.cpp
)

LIST(APPEND WebKit_LIBRARIES
@@ -267,6 +268,7 @@ SET(EWebKit_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_settings.h
${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_view.h
${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_window_features.h
${CMAKE_CURRENT_SOURCE_DIR}/efl/ewk/ewk_web_database.h
)

INSTALL(FILES ${EWebKit_HEADERS}
@@ -1,3 +1,38 @@
2012-05-17 Thiago Marcos P. Santos <thiago.santos@intel.com>

[EFL] Add API for Web Database handling
https://bugs.webkit.org/show_bug.cgi?id=85178

Reviewed by Antonio Gomes.

Add API for Web Database. This API will allow a browser
to query information about size, name, filename and remove
databases based on the origin. It will be also possible to
list all databases for a given origin.

* ewk/EWebKit.h:
* ewk/ewk_security_origin.cpp:
(ewk_security_origin_web_database_get_all):
* ewk/ewk_security_origin.h:
* ewk/ewk_settings.cpp:
* ewk/ewk_settings.h:
* ewk/ewk_web_database.cpp: Added.
(_Ewk_Web_Database):
(ewk_web_database_display_name_get):
(ewk_web_database_expected_size_get):
(ewk_web_database_filename_get):
(ewk_web_database_name_get):
(ewk_web_database_security_origin_get):
(ewk_web_database_size_get):
(ewk_web_database_remove):
(ewk_web_database_remove_all):
(ewk_web_database_free):
(ewk_web_database_list_free):
(ewk_web_database_new):
* ewk/ewk_web_database.h: Added.
* ewk/ewk_web_database_private.h: Copied from Source/WebKit/efl/ewk/EWebKit.h.
(WebCore):

2012-05-17 Mariusz Grzegorczyk <mariusz.g@samsung.com>

[EFL] [DRT] EFL's DumpRenderTree should support LayoutTestController's dumpEditingCallbacks()
@@ -41,6 +41,7 @@
#include "ewk_security_policy.h"
#include "ewk_settings.h"
#include "ewk_view.h"
#include "ewk_web_database.h"
#include "ewk_window_features.h"

#include <Evas.h>
@@ -24,8 +24,12 @@
#include "DatabaseTracker.h"
#include "SecurityOrigin.h"
#include "ewk_private.h"
#include "ewk_security_origin_private.h"
#include "ewk_web_database.h"
#include "ewk_web_database_private.h"
#include <Eina.h>
#include <wtf/RefPtr.h>
#include <wtf/UnusedParam.h>
#include <wtf/text/CString.h>

struct _Ewk_Security_Origin {
@@ -85,6 +89,25 @@ void ewk_security_origin_application_cache_quota_set(const Ewk_Security_Origin*
WebCore::cacheStorage().storeUpdatedQuotaForOrigin(origin->securityOrigin.get(), quota);
}

Eina_List* ewk_security_origin_web_database_get_all(const Ewk_Security_Origin* origin)
{
Eina_List* databases = 0;
#if ENABLE(SQL_DATABASE)
Vector<WTF::String> names;

if (!WebCore::DatabaseTracker::tracker().databaseNamesForOrigin(origin->securityOrigin.get(), names))
return 0;

for (unsigned i = 0; i < names.size(); i++) {
Ewk_Web_Database* database = ewk_web_database_new(origin->securityOrigin.get(), names[i].utf8().data());
databases = eina_list_append(databases, database);
}
#else
UNUSED_PARAM(origin);
#endif
return databases;
}

void ewk_security_origin_free(Ewk_Security_Origin* origin)
{
origin->securityOrigin = 0;
@@ -117,6 +117,24 @@ EAPI void ewk_security_origin_web_database_quota_set(const Ewk_Security_
*/
EAPI void ewk_security_origin_application_cache_quota_set(const Ewk_Security_Origin *o, int64_t quota);

/**
* Return the list of web databases in the security origin.
*
* Each item of the list should be release using ewk_web_database_free() or
* use ewk_web_database_list_free() as convenience.
*
* This function won't work if Web SQL Database was not enabled when
* building WebKit and will just return 0.
*
* @param o security origin object
*
* @return list of web databases in the security origin
*
* @see ewk_web_database_free()
* @see ewk_web_database_list_free()
*/
EAPI Eina_List *ewk_security_origin_web_database_get_all(const Ewk_Security_Origin *o);

/**
* Release all resources allocated by a security origin object.
*
@@ -105,13 +105,6 @@ void ewk_settings_web_database_default_quota_set(uint64_t maximumSize)
s_webDatabaseQuota = maximumSize;
}

void ewk_settings_web_database_clear()
{
#if ENABLE(SQL_DATABASE)
WebCore::DatabaseTracker::tracker().deleteAllDatabases();
#endif
}

void ewk_settings_local_storage_path_set(const char* path)
{
WebCore::StorageTracker::tracker().setDatabaseDirectoryPath(WTF::String::fromUTF8(path));
@@ -52,11 +52,6 @@ EAPI uint64_t ewk_settings_web_database_default_quota_get(void);
*/
EAPI void ewk_settings_web_database_default_quota_set(uint64_t maximum_size);

/**
* Removes all HTML5 Web Database databases.
*/
EAPI void ewk_settings_web_database_clear(void);

/**
* Sets the current path to the directory WebKit will write Web
* Database databases.
@@ -0,0 +1,182 @@
/*
Copyright (C) 2012 Intel Corporation
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/

#include "config.h"
#include "ewk_web_database.h"

#include "DatabaseTracker.h"
#include "SecurityOrigin.h"
#include "ewk_security_origin.h"
#include "ewk_security_origin_private.h"
#include "ewk_web_database_private.h"
#include <Eina.h>
#include <wtf/RefPtr.h>
#include <wtf/UnusedParam.h>
#include <wtf/text/WTFString.h>

struct _Ewk_Web_Database {
WTF::RefPtr<WebCore::SecurityOrigin> securityOrigin;
WTF::String coreName;
const char* displayName;
const char* filename;
const char* name;
};

const char* ewk_web_database_display_name_get(Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
if (database->displayName)
return database->displayName;

WebCore::SecurityOrigin* origin = database->securityOrigin.get();
WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(database->name, origin);
database->displayName = eina_stringshare_add(details.displayName().utf8().data());

return database->displayName;
#else
UNUSED_PARAM(database);
return 0;
#endif
}

uint64_t ewk_web_database_expected_size_get(const Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
WebCore::SecurityOrigin* origin = database->securityOrigin.get();
WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(database->name, origin);
return details.expectedUsage();
#else
UNUSED_PARAM(database);
return 0;
#endif
}

const char* ewk_web_database_filename_get(Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
if (database->filename)
return database->filename;

WebCore::SecurityOrigin* origin = database->securityOrigin.get();
WTF::String path = WebCore::DatabaseTracker::tracker().fullPathForDatabase(origin, database->coreName);
database->filename = eina_stringshare_add(path.utf8().data());

return database->filename;
#else
UNUSED_PARAM(database);
return 0;
#endif
}

const char* ewk_web_database_name_get(Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
if (database->name)
return database->name;

database->name = eina_stringshare_add(database->coreName.utf8().data());

return database->name;
#else
UNUSED_PARAM(database);
return 0;
#endif
}

Ewk_Security_Origin* ewk_web_database_security_origin_get(const Ewk_Web_Database* database)
{
return ewk_security_origin_new(database->securityOrigin.get());
}

uint64_t ewk_web_database_size_get(const Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
WebCore::SecurityOrigin* origin = database->securityOrigin.get();
WebCore::DatabaseDetails details = WebCore::DatabaseTracker::tracker().detailsForNameAndOrigin(database->name, origin);
return details.currentUsage();
#else
UNUSED_PARAM(database);
return 0;
#endif
}

void ewk_web_database_remove(Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
WebCore::DatabaseTracker::tracker().deleteDatabase(database->securityOrigin.get(), database->coreName);
#else
UNUSED_PARAM(database);
#endif
}

void ewk_web_database_remove_all(void)
{
#if ENABLE(SQL_DATABASE)
WebCore::DatabaseTracker::tracker().deleteAllDatabases();
#endif
}

void ewk_web_database_free(Ewk_Web_Database* database)
{
#if ENABLE(SQL_DATABASE)
eina_stringshare_del(database->displayName);
eina_stringshare_del(database->filename);
eina_stringshare_del(database->name);

delete database;
#else
UNUSED_PARAM(database);
#endif
}

void ewk_web_database_list_free(Eina_List* databaseList)
{
void* database;
EINA_LIST_FREE(databaseList, database)
ewk_web_database_free(static_cast<Ewk_Web_Database*>(database));
}

/**
* @internal
* Creates a wrapper representing a Web Database.
*
* @param coreOrigin WebCore Security Origin object
* @param coreName Web Database name
*
* @return a wrapper for manipulating a Web Database. It should be freed
* by ewk_web_database_free().
*/
Ewk_Web_Database* ewk_web_database_new(WebCore::SecurityOrigin* coreOrigin, const WTF::String& coreName)
{
#if ENABLE(SQL_DATABASE)
Ewk_Web_Database* database = new Ewk_Web_Database;

database->securityOrigin = coreOrigin;
database->coreName = coreName;
database->displayName = 0;
database->filename = 0;
database->name = 0;

return database;
#else
UNUSED_PARAM(coreOrigin);
UNUSED_PARAM(coreName);
return 0;
#endif
}

0 comments on commit 148e3b7

Please sign in to comment.