From 4143f5e25d1907ab8b94b5887deee88cb87b7e3a Mon Sep 17 00:00:00 2001 From: Jihye Kang Date: Tue, 26 Mar 2013 15:34:41 +0900 Subject: [PATCH] [WK2] Apply new quota policy for Web Database [Title] Apply new quota policy for Web Database [Issue#] N/A [Problem] [Cause] [Solution] Apply new quota policy for Web Database - Default quota: 5*1024*1024 - Request quota for UA when opening database if it exceeds default quota - Quota cannot be exceeded while using database - ewk_view_exceeded_database_quota_callback_set() is added for calling the callback when request quota for UA Change-Id: Ifc1c3bdd1c112f770ddcb9e5fa2fd2b6abb645ad --- .../Modules/webdatabase/DatabaseContext.cpp | 12 +++++ .../Modules/webdatabase/DatabaseTracker.cpp | 13 +++++ .../Modules/webdatabase/SQLTransactionClient.cpp | 4 ++ Source/WebKit2/Platform/CoreIPC/HandleMessage.h | 6 +++ Source/WebKit2/UIProcess/API/C/WKPage.h | 6 ++- .../UIProcess/API/C/efl/tizen/WKPageTizen.cpp | 7 +++ .../UIProcess/API/C/efl/tizen/WKPageTizen.h | 3 ++ Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp | 8 --- Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h | 10 ++-- Source/WebKit2/UIProcess/API/efl/ewk_view.cpp | 62 +++++++++++++++++----- Source/WebKit2/UIProcess/API/efl/ewk_view.h | 6 +++ .../WebKit2/UIProcess/API/efl/ewk_view_private.h | 2 +- Source/WebKit2/UIProcess/WebPageProxy.cpp | 20 +++++++ Source/WebKit2/UIProcess/WebPageProxy.h | 11 ++++ Source/WebKit2/UIProcess/WebPageProxy.messages.in | 5 ++ Source/WebKit2/UIProcess/WebUIClient.cpp | 13 +++++ Source/WebKit2/UIProcess/WebUIClient.h | 4 ++ Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp | 4 +- Source/WebKit2/UIProcess/efl/PageUIClientEfl.h | 4 ++ Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp | 16 ++++++ .../WebProcess/WebCoreSupport/WebChromeClient.cpp | 18 +++++++ Tools/WebKitTestRunner/TestController.cpp | 8 ++- 22 files changed, 213 insertions(+), 29 deletions(-) diff --git a/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp b/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp index 0b662a8..d0150c4 100644 --- a/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp +++ b/Source/WebCore/Modules/webdatabase/DatabaseContext.cpp @@ -134,8 +134,20 @@ void DatabaseContext::databaseExceededQuota(const String& name) #if !PLATFORM(CHROMIUM) // FIXME: This needs a real implementation; this is a temporary solution for testing. const unsigned long long defaultQuota = 5 * 1024 * 1024; +#if ENABLE(TIZEN_SQL_DATABASE) + SecurityOrigin* origin = m_scriptExecutionContext->securityOrigin(); + DatabaseDetails details = DatabaseTracker::tracker().detailsForNameAndOrigin(name, origin); + unsigned long long currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin); + unsigned long long requirement = currentQuota + details.expectedUsage(); + + if (requirement <= defaultQuota) + DatabaseTracker::tracker().setQuota(origin, requirement); + else + DatabaseTracker::tracker().setQuota(origin, defaultQuota); +#else DatabaseTracker::tracker().setQuota(m_scriptExecutionContext->securityOrigin(), defaultQuota); #endif +#endif } } // namespace WebCore diff --git a/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp b/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp index efaf6d6..d2d8f7e 100644 --- a/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp +++ b/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp @@ -167,13 +167,25 @@ bool DatabaseTracker::canEstablishDatabase(ScriptExecutionContext* context, cons // Since we're imminently opening a database within this context's origin, make sure this origin is being tracked by the QuotaTracker // by fetching its current usage now. +#if ENABLE(TIZEN_SQL_DATABASE) + usageForOriginNoLock(origin); +#else unsigned long long usage = usageForOriginNoLock(origin); +#endif // If a database already exists, ignore the passed-in estimated size and say it's OK. if (hasEntryForDatabase(origin, name)) return true; // If the database will fit, allow its creation. +#if ENABLE(TIZEN_SQL_DATABASE) + unsigned long long originQuota = quotaForOriginNoLock(origin); + requirement = originQuota + max(1UL, estimatedSize); + if (requirement < originQuota) { + doneCreatingDatabase(origin, name); + return false; // If the estimated size is so big it causes an overflow, don't allow creation. + } +#else requirement = usage + max(1UL, estimatedSize); if (requirement < usage) { doneCreatingDatabase(origin, name); @@ -181,6 +193,7 @@ bool DatabaseTracker::canEstablishDatabase(ScriptExecutionContext* context, cons } if (requirement <= quotaForOriginNoLock(origin)) return true; +#endif // Give the chrome client a chance to increase the quota. // Temporarily make the details of the proposed database available, so the client can get at them. diff --git a/Source/WebCore/Modules/webdatabase/SQLTransactionClient.cpp b/Source/WebCore/Modules/webdatabase/SQLTransactionClient.cpp index 07c83d2..737cd6b 100644 --- a/Source/WebCore/Modules/webdatabase/SQLTransactionClient.cpp +++ b/Source/WebCore/Modules/webdatabase/SQLTransactionClient.cpp @@ -54,11 +54,15 @@ void SQLTransactionClient::didExecuteStatement(AbstractDatabase* database) bool SQLTransactionClient::didExceedQuota(AbstractDatabase* database) { +#if ENABLE(TIZEN_SQL_DATABASE) + return false; +#else ASSERT(database->scriptExecutionContext()->isContextThread()); unsigned long long currentQuota = DatabaseTracker::tracker().quotaForOrigin(database->securityOrigin()); database->databaseContext()->databaseExceededQuota(database->stringIdentifier()); unsigned long long newQuota = DatabaseTracker::tracker().quotaForOrigin(database->securityOrigin()); return (newQuota > currentQuota); +#endif } } diff --git a/Source/WebKit2/Platform/CoreIPC/HandleMessage.h b/Source/WebKit2/Platform/CoreIPC/HandleMessage.h index f494336..06d6469 100644 --- a/Source/WebKit2/Platform/CoreIPC/HandleMessage.h +++ b/Source/WebKit2/Platform/CoreIPC/HandleMessage.h @@ -214,6 +214,12 @@ void callMemberFunction(const Arguments3& args, PassRefPtr delaye { (object->*function)(args.argument1, args.argument2, args.argument3, delayedReply); } + +template +void callMemberFunction(const Arguments4& args, PassRefPtr delayedReply, C* object, MF function) +{ + (object->*function)(args.argument1, args.argument2, args.argument3, args.argument4, delayedReply); +} // ENDIF // Dispatch functions with connection parameter. diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h index 9a334e9..3843ebb 100755 --- a/Source/WebKit2/UIProcess/API/C/WKPage.h +++ b/Source/WebKit2/UIProcess/API/C/WKPage.h @@ -232,7 +232,11 @@ typedef void (*WKPageSetIsResizableCallback)(WKPageRef page, bool resizable, con typedef WKRect (*WKPageGetWindowFrameCallback)(WKPageRef page, const void *clientInfo); typedef void (*WKPageSetWindowFrameCallback)(WKPageRef page, WKRect frame, const void *clientInfo); typedef bool (*WKPageRunBeforeUnloadConfirmPanelCallback)(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo); -typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo); +// #if ENABLE(TIZEN_SQL_DATABASE) +typedef bool (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef displayName, unsigned long long expectedUsage, const void *clientInfo); +// #else +// typedef unsigned long long (*WKPageExceededDatabaseQuotaCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void *clientInfo); +// #endif //#if OS(TIZEN) typedef bool (*WKPageRunOpenPanelCallback)(WKPageRef page, WKFrameRef frame, WKOpenPanelParametersRef parameters, WKOpenPanelResultListenerRef listener, const void* clientInfo); //#else diff --git a/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.cpp b/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.cpp index 27a1df3..bdd1c8b 100644 --- a/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.cpp +++ b/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.cpp @@ -134,3 +134,10 @@ void WKPageReplyExceededIndexedDatabaseQuota(WKPageRef page, bool allow) toImpl(page)->replyExceededIndexedDatabaseQuota(allow); #endif } + +void WKPageReplyExceededDatabaseQuota(WKPageRef page, bool allow) +{ +#if ENABLE(TIZEN_SQL_DATABASE) + toImpl(page)->replyExceededDatabaseQuota(allow); +#endif +} diff --git a/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.h b/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.h index 09e73e7..a96728e 100644 --- a/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.h +++ b/Source/WebKit2/UIProcess/API/C/efl/tizen/WKPageTizen.h @@ -120,6 +120,9 @@ WK_EXPORT void WKPageReplyApplicationCachePermission(WKPageRef page, bool allow) WK_EXPORT void WKPageReplyExceededIndexedDatabaseQuota(WKPageRef page, bool allow); //#endif +// #if ENABLE(TIZEN_SQL_DATABASE) +WK_EXPORT void WKPageReplyExceededDatabaseQuota(WKPageRef page, bool allow); +// #endif #ifdef __cplusplus } #endif diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp index 55658c8..26d8971 100755 --- a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp @@ -143,9 +143,6 @@ EwkViewImpl::EwkViewImpl(Evas_Object* view) , notifications(0) , notificationPermissionRequests(0) #endif -#if ENABLE(TIZEN_SQL_DATABASE) - , exceededDatabaseQuota(0) -#endif #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL) , popupPicker(0) #endif @@ -286,11 +283,6 @@ EwkViewImpl::~EwkViewImpl() ewkNotificationDeletePermissionRequestList(notificationPermissionRequests); #endif -#if ENABLE(TIZEN_SQL_DATABASE) - if (exceededDatabaseQuota) - ewkContextDeleteExceededQuota(exceededDatabaseQuota); -#endif - #if ENABLE(TIZEN_RUNTIME_BACKEND_SELECTION) if (compositionAnimator) ecore_animator_del(compositionAnimator); diff --git a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h index 9ccb540..e90a50f 100755 --- a/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h +++ b/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h @@ -158,6 +158,9 @@ struct Ewk_View_Callback_Context { #if ENABLE(TIZEN_INDEXED_DATABASE) Ewk_View_Exceeded_Indexed_Database_Quota_Callback exceededIndexedDatabaseQuotaCallback; #endif +#if ENABLE(TIZEN_SQL_DATABASE) + Ewk_View_Exceeded_Database_Quota_Callback exceededDatabaseQuotaCallback; +#endif }; Evas_Object* ewkView; @@ -401,10 +404,6 @@ public: Eina_List* notificationPermissionRequests; #endif -#if ENABLE(TIZEN_SQL_DATABASE) - Ewk_Context_Exceeded_Quota* exceededDatabaseQuota; -#endif - #if ENABLE(TIZEN_WEBKIT2_POPUP_INTERNAL) Ewk_Popup_Picker* popupPicker; #endif @@ -464,6 +463,9 @@ public: #if ENABLE(TIZEN_INDEXED_DATABASE) OwnPtr exceededIndexedDatabaseQuotaContext; #endif +#if ENABLE(TIZEN_SQL_DATABASE) + OwnPtr exceededDatabaseQuotaContext; +#endif Ewk_Security_Origin* exceededQuotaOrigin; bool isWaitingForExceededQuotaPopupReply; #endif // #if OS(TIZEN) diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp index fe300fa..1f9a9ec 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.cpp @@ -1998,22 +1998,25 @@ void ewk_view_process_crashed(Evas_Object* ewkView) } #if ENABLE(TIZEN_SQL_DATABASE) -unsigned long long ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage) +bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, unsigned long long expectedUsage) { - EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, currentQuota); - EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, currentQuota); + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData, false); + EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl, false); - TIZEN_LOGI("database,quota,exceeded"); - uint64_t defaultQuota = ewkContextGetDatabaseQuota(impl->context.get()); - if (defaultQuota >= expectedUsage + currentQuota) - return defaultQuota; + if (!impl->exceededDatabaseQuotaContext || !impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback) + return false; - if (impl->exceededDatabaseQuota) - ewkContextDeleteExceededQuota(impl->exceededDatabaseQuota); - impl->exceededDatabaseQuota = ewkContextCreateExceededQuota(origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); - evas_object_smart_callback_call(ewkView, "database,quota,exceeded", impl->exceededDatabaseQuota); + TIZEN_LOGI("No error in prameter. Request to display user confirm popup. expectedUsage(%llu)", expectedUsage); + impl->isWaitingForExceededQuotaPopupReply = true; + if (impl->exceededQuotaOrigin) + deleteSecurityOrigin(impl->exceededQuotaOrigin); + impl->exceededQuotaOrigin = createSecurityOrigin(origin); - return ewkContextGetNewQuotaForExceededQuota(impl->context.get(), impl->exceededDatabaseQuota); + int length = WKStringGetMaximumUTF8CStringSize(databaseName); + OwnArrayPtr databaseNameBuffer = adoptArrayPtr(new char[length]); + WKStringGetUTF8CString(databaseName, databaseNameBuffer.get(), length); + + return impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback(ewkView, impl->exceededQuotaOrigin, databaseNameBuffer.get(), expectedUsage, impl->exceededDatabaseQuotaContext->userData) == EINA_TRUE; } #endif @@ -4597,3 +4600,38 @@ Eina_Bool ewk_view_text_matches_count(Evas_Object* ewkView, const char* text, Ew return true; } + +void ewk_view_exceeded_database_quota_callback_set(Evas_Object* ewkView, Ewk_View_Exceeded_Database_Quota_Callback callback, void* userData) +{ +#if ENABLE(TIZEN_SQL_DATABASE) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl); + + if (!impl->exceededDatabaseQuotaContext) + impl->exceededDatabaseQuotaContext = adoptPtr(new Ewk_View_Callback_Context); + impl->exceededDatabaseQuotaContext->exceededDatabaseQuotaCallback = callback; + impl->exceededDatabaseQuotaContext->userData = userData; +#else + UNUSED_PARAM(ewkView); + UNUSED_PARAM(callback); + UNUSED_PARAM(userData); +#endif +} + +void ewk_view_exceeded_database_quota_reply(Evas_Object* ewkView, Eina_Bool allow) +{ +#if ENABLE(TIZEN_SQL_DATABASE) + EWK_VIEW_SD_GET_OR_RETURN(ewkView, smartData); + EWK_VIEW_IMPL_GET_OR_RETURN(smartData, impl); + + TIZEN_LOGI("allow %d", allow); + WKPageReplyExceededDatabaseQuota(toAPI(impl->page()), allow == EINA_TRUE); + if (impl->exceededQuotaOrigin) + deleteSecurityOrigin(impl->exceededQuotaOrigin); + impl->exceededQuotaOrigin = 0; + impl->isWaitingForExceededQuotaPopupReply = false; +#else + UNUSED_PARAM(ewkView); + UNUSED_PARAM(allow); +#endif +} diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view.h b/Source/WebKit2/UIProcess/API/efl/ewk_view.h index c240161..b6d4433 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view.h @@ -711,6 +711,12 @@ EAPI void ewk_view_exceeded_indexed_database_quota_callback_set(Evas_Object* o, EAPI void ewk_view_exceeded_indexed_database_quota_reply(Evas_Object* o, Eina_Bool allow); //#endif +// #if ENABLE(TIZEN_SQL_DATABASE) +typedef Eina_Bool (*Ewk_View_Exceeded_Database_Quota_Callback)(Evas_Object* o, Ewk_Security_Origin* origin, const char* database_name, unsigned long long expectedQuota, void* user_data); +EAPI void ewk_view_exceeded_database_quota_callback_set(Evas_Object* o, Ewk_View_Exceeded_Database_Quota_Callback callback, void* user_data); +EAPI void ewk_view_exceeded_database_quota_reply(Evas_Object* o, Eina_Bool allow); +// #endif + /** * Gets the Ewk_Settings of this view. * diff --git a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h index d0d5e61..a1a1eff 100755 --- a/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h +++ b/Source/WebKit2/UIProcess/API/efl/ewk_view_private.h @@ -176,7 +176,7 @@ void ewkViewClearEdges(Evas_Object* ewkView); void ewkViewFrameRendered(Evas_Object* ewkView); #if ENABLE(TIZEN_SQL_DATABASE) -unsigned long long ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage); +bool ewkViewExceededDatabaseQuota(Evas_Object* ewkView, WKSecurityOriginRef origin, WKStringRef displayName, unsigned long long expectedUsage); Ewk_Context_Exceeded_Quota* ewkContextCreateExceededQuota(WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage); void ewkContextDeleteExceededQuota(Ewk_Context_Exceeded_Quota* exceededQuota); unsigned long long ewkContextGetNewQuotaForExceededQuota(Ewk_Context* context, Ewk_Context_Exceeded_Quota* exceededQuota); diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index f81ca4d..7e72a9d 100755 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -4240,6 +4240,25 @@ void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const Aut m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get()); } +#if ENABLE(TIZEN_SQL_DATABASE) +void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& displayName, uint64_t expectedUsage, PassRefPtr allowExceed) +{ + WebFrameProxy* frame = process()->webFrame(frameID); + MESSAGE_CHECK(frame); + + // Since exceededDatabaseQuota() can spin a nested run loop we need to turn off the responsiveness timer. + process()->responsivenessTimer()->stop(); + + m_exceededDatabaseQuotaReply = allowExceed; + RefPtr origin = WebSecurityOrigin::createFromDatabaseIdentifier(originIdentifier); +#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP) + process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(true); +#endif + + if (!m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), displayName, expectedUsage)) + replyExceededDatabaseQuota(false); +} +#else void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, uint64_t& newQuota) { WebFrameProxy* frame = process()->webFrame(frameID); @@ -4249,6 +4268,7 @@ void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originI newQuota = m_uiClient.exceededDatabaseQuota(this, frame, origin.get(), databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); } +#endif void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier) { diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index a91e088..e130191 100755 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -1035,6 +1035,10 @@ void recordingSurfaceSetEnableSet(bool enable); void replyExceededIndexedDatabaseQuota(bool allow); #endif +#if ENABLE(TIZEN_SQL_DATABASE) + void replyExceededDatabaseQuota(bool allow); +#endif + private: WebPageProxy(PageClient*, PassRefPtr, WebPageGroup*, uint64_t pageID); @@ -1154,7 +1158,11 @@ private: void pageDidScroll(); void runOpenPanel(uint64_t frameID, const WebCore::FileChooserSettings&); void printFrame(uint64_t frameID); +#if ENABLE(TIZEN_SQL_DATABASE) + void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& displayName, uint64_t expectedUsage, PassRefPtr); +#else void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, uint64_t& newQuota); +#endif #if ENABLE(TIZEN_APPLICATION_CACHE) void requestApplicationCachePermission(uint64_t frameID, const String& originIdentifier, PassRefPtr); #endif @@ -1632,6 +1640,9 @@ private: #if ENABLE(TIZEN_APPLICATION_CACHE) RefPtr m_applicationCacheReply; #endif +#if ENABLE(TIZEN_SQL_DATABASE) + RefPtr m_exceededDatabaseQuotaReply; +#endif #endif #if ENABLE(TIZEN_CERTIFICATE_HANDLING) diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index 8075b43..5b439e8 100755 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -304,7 +304,12 @@ messages -> WebPageProxy { DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID) # Database messages +#if ENABLE(TIZEN_SQL_DATABASE) + ExceededDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, WTF::String databaseDisplayName, uint64_t expectedUsage) -> (bool allowExceed) Delayed +#endif +#if !ENABLE(TIZEN_SQL_DATABASE) ExceededDatabaseQuota(uint64_t frameID, WTF::String originIdentifier, WTF::String databaseName, WTF::String databaseDisplayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage) -> (uint64_t newQuota) +#endif #if ENABLE(TIZEN_APPLICATION_CACHE) RequestApplicationCachePermission(uint64_t frameID, WTF::String originIdentifier) -> (bool allow) Delayed diff --git a/Source/WebKit2/UIProcess/WebUIClient.cpp b/Source/WebKit2/UIProcess/WebUIClient.cpp index eb2fde7..2994bf3 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.cpp +++ b/Source/WebKit2/UIProcess/WebUIClient.cpp @@ -366,6 +366,18 @@ void WebUIClient::pageDidScroll(WebPageProxy* page) m_client.pageDidScroll(toAPI(page), m_client.clientInfo); } +#if ENABLE(TIZEN_SQL_DATABASE) +bool WebUIClient::exceededDatabaseQuota(WebPageProxy* page, WebFrameProxy* frame, WebSecurityOrigin* origin, const String& databaseDisplayName, unsigned long long expectedUsage) +{ +#if ENABLE(TIZEN_WEBKIT2_EFL_WTR) + return false; +#endif + if (!m_client.exceededDatabaseQuota) + return false; + + return m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseDisplayName.impl()), expectedUsage, m_client.clientInfo); +} +#else unsigned long long WebUIClient::exceededDatabaseQuota(WebPageProxy* page, WebFrameProxy* frame, WebSecurityOrigin* origin, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage) { if (!m_client.exceededDatabaseQuota) @@ -373,6 +385,7 @@ unsigned long long WebUIClient::exceededDatabaseQuota(WebPageProxy* page, WebFra return m_client.exceededDatabaseQuota(toAPI(page), toAPI(frame), toAPI(origin), toAPI(databaseName.impl()), toAPI(databaseDisplayName.impl()), currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, m_client.clientInfo); } +#endif bool WebUIClient::runOpenPanel(WebPageProxy* page, WebFrameProxy* frame, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener) { diff --git a/Source/WebKit2/UIProcess/WebUIClient.h b/Source/WebKit2/UIProcess/WebUIClient.h index 5b0f5bd..42ca581 100644 --- a/Source/WebKit2/UIProcess/WebUIClient.h +++ b/Source/WebKit2/UIProcess/WebUIClient.h @@ -105,7 +105,11 @@ public: void didDraw(WebPageProxy*); void pageDidScroll(WebPageProxy*); +#if ENABLE(TIZEN_SQL_DATABASE) + bool exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, const String& databaseDisplayName, unsigned long long expectedUsage); +#else unsigned long long exceededDatabaseQuota(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, const String& databaseName, const String& databaseDisplayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage); +#endif bool runOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*); bool decidePolicyForGeolocationPermissionRequest(WebPageProxy*, WebFrameProxy*, WebSecurityOrigin*, GeolocationPermissionRequestProxy*); diff --git a/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp b/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp index c77aecf..8567dd8 100755 --- a/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/PageUIClientEfl.cpp @@ -118,9 +118,9 @@ void PageUIClientEfl::hideColorPicker(WKPageRef, const void* clientInfo) #if ENABLE(SQL_DATABASE) #if ENABLE(TIZEN_SQL_DATABASE) -unsigned long long PageUIClientEfl::exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef origin, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void* clientInfo) +bool PageUIClientEfl::exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef origin, WKStringRef displayName, unsigned long long expectedUsage, const void *clientInfo) { - return ewkViewExceededDatabaseQuota(toPageUIClientEfl(clientInfo)->m_viewImpl->view(), origin, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage); + return ewkViewExceededDatabaseQuota(toPageUIClientEfl(clientInfo)->m_viewImpl->view(), origin, displayName, expectedUsage); } #else unsigned long long PageUIClientEfl::exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef databaseName, WKStringRef displayName, unsigned long long currentQuota, unsigned long long currentOriginUsage, unsigned long long currentDatabaseUsage, unsigned long long expectedUsage, const void* clientInfo) diff --git a/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h b/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h index 87bbadf..621ca8c 100755 --- a/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h +++ b/Source/WebKit2/UIProcess/efl/PageUIClientEfl.h @@ -61,8 +61,12 @@ private: static void hideColorPicker(WKPageRef, const void*); #endif #if ENABLE(SQL_DATABASE) +#if ENABLE(TIZEN_SQL_DATABASE) + static bool exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, unsigned long long, const void *); +#else static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, WKStringRef, unsigned long long currentQuota, unsigned long long, unsigned long long, unsigned long long, const void*); #endif +#endif static void focus(WKPageRef, const void*); static void unfocus(WKPageRef, const void*); static void takeFocus(WKPageRef, WKFocusDirection, const void*); diff --git a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp index 138695f..4dff2e5 100755 --- a/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp +++ b/Source/WebKit2/UIProcess/efl/WebPageProxyEfl.cpp @@ -1083,6 +1083,22 @@ void WebPageProxy::replyExceededIndexedDatabaseQuota(bool allow) } #endif +#if ENABLE(TIZEN_SQL_DATABASE) +void WebPageProxy::replyExceededDatabaseQuota(bool allow) +{ + if (!m_exceededDatabaseQuotaReply) { + TIZEN_LOGE("m_exceededDatabaseQuotaReply does not exist"); + return; + } + + m_exceededDatabaseQuotaReply->send(allow); + m_exceededDatabaseQuotaReply = nullptr; +#if ENABLE(TIZEN_WEBKIT2_ROTATION_WHILE_JAVASCRIPT_POPUP) + process()->connection()->setForcelySetAllAsyncMessagesToDispatchEvenWhenWaitingForSyncReply(false); +#endif +} +#endif + #endif // #if OS(TIZEN) void WebPageProxy::handleInputMethodKeydown(bool& handled) diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp index f447031..6f83af7 100755 --- a/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp +++ b/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp @@ -662,9 +662,27 @@ void WebChromeClient::exceededDatabaseQuota(Frame* frame, const String& database uint64_t currentQuota = DatabaseTracker::tracker().quotaForOrigin(origin); uint64_t currentOriginUsage = DatabaseTracker::tracker().usageForOrigin(origin); uint64_t newQuota = 0; +#if ENABLE(TIZEN_SQL_DATABASE) + const uint64_t defaultQuota = 5 * 1024 * 1024; + uint64_t requirement = currentQuota + details.expectedUsage(); + if (requirement <= defaultQuota) + newQuota = requirement; + else { + unsigned syncSendFlags = (WebCore::AXObjectCache::accessibilityEnabled()) ? CoreIPC::SpinRunLoopWhileWaitingForReply : 0; + bool allowExceed = false; + WebProcess::shared().connection()->sendSync( + Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), details.displayName(), details.expectedUsage()), + Messages::WebPageProxy::ExceededDatabaseQuota::Reply(allowExceed), m_page->pageID(), CoreIPC::Connection::DefaultTimeout, syncSendFlags); + if (allowExceed) + newQuota = currentQuota + details.expectedUsage(); + else + newQuota = currentQuota; + } +#else WebProcess::shared().connection()->sendSync( Messages::WebPageProxy::ExceededDatabaseQuota(webFrame->frameID(), origin->databaseIdentifier(), databaseName, details.displayName(), currentQuota, currentOriginUsage, details.currentUsage(), details.expectedUsage()), Messages::WebPageProxy::ExceededDatabaseQuota::Reply(newQuota), m_page->pageID()); +#endif DatabaseTracker::tracker().setQuota(origin, newQuota); } diff --git a/Tools/WebKitTestRunner/TestController.cpp b/Tools/WebKitTestRunner/TestController.cpp index 6c5ae15..b4f6a22 100755 --- a/Tools/WebKitTestRunner/TestController.cpp +++ b/Tools/WebKitTestRunner/TestController.cpp @@ -131,12 +131,18 @@ static bool runBeforeUnloadConfirmPanel(WKPageRef page, WKStringRef message, WKF return testController->beforeUnloadReturnValue(); } +#if ENABLE(TIZEN_SQL_DATABASE) +static bool exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, unsigned long long, const void*) +{ + return true; +} +#else static unsigned long long exceededDatabaseQuota(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKStringRef, WKStringRef, unsigned long long, unsigned long long, unsigned long long, unsigned long long, const void*) { static const unsigned long long defaultQuota = 5 * 1024 * 1024; return defaultQuota; } - +#endif void TestController::runModal(WKPageRef page, const void* clientInfo) { -- 2.7.4