Add release logging for quota checks
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 20:14:05 +0000 (20:14 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Jul 2019 20:14:05 +0000 (20:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199697

Reviewed by Alex Christensen.

Source/WebCore:

Log whether a request to extend quota is made and the result of the request.
This logging should happen in the networking process.
No change of behavior.

* platform/Logging.h:
* storage/StorageQuotaManager.cpp:
(WebCore::StorageQuotaManager::askForMoreSpace):
(WebCore::StorageQuotaManager::processPendingRequests):

Source/WebKit:

Log requests made to the page and the result from the application.

* Platform/Logging.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestStorageSpace):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/Logging.h
Source/WebCore/storage/StorageQuotaManager.cpp
Source/WebKit/ChangeLog
Source/WebKit/Platform/Logging.h
Source/WebKit/UIProcess/WebPageProxy.cpp

index dbf92a6..6da8d7f 100644 (file)
@@ -1,5 +1,21 @@
 2019-07-12  Youenn Fablet  <youenn@apple.com>
 
+        Add release logging for quota checks
+        https://bugs.webkit.org/show_bug.cgi?id=199697
+
+        Reviewed by Alex Christensen.
+
+        Log whether a request to extend quota is made and the result of the request.
+        This logging should happen in the networking process.
+        No change of behavior.
+
+        * platform/Logging.h:
+        * storage/StorageQuotaManager.cpp:
+        (WebCore::StorageQuotaManager::askForMoreSpace):
+        (WebCore::StorageQuotaManager::processPendingRequests):
+
+2019-07-12  Youenn Fablet  <youenn@apple.com>
+
         Stopping a cloned MediaStream video track should not stop any other video track
         https://bugs.webkit.org/show_bug.cgi?id=199635
 
index 27bfebb..1ef7256 100644 (file)
@@ -96,6 +96,7 @@ namespace WebCore {
     M(ServiceWorker) \
     M(SpellingAndGrammar) \
     M(SQLDatabase) \
+    M(Storage) \
     M(StorageAPI) \
     M(SVG) \
     M(TextAutosizing) \
index 9933c0e..767ad2e 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "StorageQuotaManager.h"
 
+#include "Logging.h"
 #include "StorageQuotaUser.h"
 
 namespace WebCore {
@@ -155,10 +156,15 @@ void StorageQuotaManager::askForMoreSpace(uint64_t spaceIncrease)
 {
     ASSERT(shouldAskForMoreSpace(spaceIncrease));
     ASSERT(!m_isWaitingForSpaceIncreaseResponse);
+
+    RELEASE_LOG(Storage, "%p - StorageQuotaManager::askForMoreSpace %" PRIu64, this, spaceIncrease);
     m_isWaitingForSpaceIncreaseResponse = true;
     m_spaceIncreaseRequester(m_quota, spaceUsage(), spaceIncrease, [this, weakThis = makeWeakPtr(*this)](Optional<uint64_t> newQuota) {
         if (!weakThis)
             return;
+
+        RELEASE_LOG(Storage, "%p - StorageQuotaManager::askForMoreSpace received response %" PRIu64, this, newQuota ? *newQuota : 0);
+
         m_isWaitingForSpaceIncreaseResponse = false;
         processPendingRequests(newQuota, ShouldDequeueFirstPendingRequest::Yes);
     });
@@ -180,8 +186,11 @@ void StorageQuotaManager::processPendingRequests(Optional<uint64_t> newQuota, Sh
 
     if (shouldDequeueFirstPendingRequest == ShouldDequeueFirstPendingRequest::Yes) {
         auto request = m_pendingRequests.takeFirst();
-        auto decision = shouldAskForMoreSpace(request.spaceIncrease) ? Decision::Deny : Decision::Grant;
-        request.callback(decision);
+        bool shouldAllowRequest = !shouldAskForMoreSpace(request.spaceIncrease);
+
+        RELEASE_LOG(Storage, "%p - StorageQuotaManager::processPendingRequests first request decision is %d", this, shouldAllowRequest);
+
+        request.callback(shouldAllowRequest ? Decision::Grant : Decision::Deny);
     }
 
     while (!m_pendingRequests.isEmpty()) {
index 95095c8..3285e6f 100644 (file)
@@ -1,5 +1,18 @@
 2019-07-12  Youenn Fablet  <youenn@apple.com>
 
+        Add release logging for quota checks
+        https://bugs.webkit.org/show_bug.cgi?id=199697
+
+        Reviewed by Alex Christensen.
+
+        Log requests made to the page and the result from the application.
+
+        * Platform/Logging.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestStorageSpace):
+
+2019-07-12  Youenn Fablet  <youenn@apple.com>
+
         Remove unneeded variable in LocalStorageNamespace::getOrCreateStorageArea
         https://bugs.webkit.org/show_bug.cgi?id=199477
 
index d838e30..7aa9c72 100644 (file)
@@ -82,6 +82,7 @@ extern "C" {
     M(Selection) \
     M(ServiceWorker) \
     M(SessionState) \
+    M(Storage) \
     M(StorageAPI) \
     M(TextInput) \
     M(UIHitTesting) \
index 68d881c..24f1e60 100644 (file)
@@ -7302,10 +7302,17 @@ void WebPageProxy::exceededDatabaseQuota(uint64_t frameID, const String& originI
 
 void WebPageProxy::requestStorageSpace(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, CompletionHandler<void(uint64_t)>&& completionHandler)
 {
+    RELEASE_LOG_IF_ALLOWED(Storage, "requestStorageSpace for frame %" PRIu64 ", current quota %" PRIu64 " current usage %" PRIu64 " expected usage %" PRIu64, frameID, currentQuota, currentDatabaseUsage, expectedUsage);
+
     StorageRequests::singleton().processOrAppend([this, protectedThis = makeRef(*this), pageURL = currentURL(), frameID, originIdentifier, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, completionHandler = WTFMove(completionHandler)]() mutable {
-        this->makeStorageSpaceRequest(frameID, originIdentifier, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, [this, protectedThis = WTFMove(protectedThis), pageURL = WTFMove(pageURL), completionHandler = WTFMove(completionHandler), currentQuota](auto quota) mutable {
-            if (quota <= currentQuota && this->currentURL() == pageURL)
+        this->makeStorageSpaceRequest(frameID, originIdentifier, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, [this, protectedThis = WTFMove(protectedThis), frameID, pageURL = WTFMove(pageURL), completionHandler = WTFMove(completionHandler), currentQuota](auto quota) mutable {
+
+            RELEASE_LOG_IF_ALLOWED(Storage, "requestStorageSpace response for frame %" PRIu64 ", quota %" PRIu64, frameID, quota);
+
+            if (quota <= currentQuota && this->currentURL() == pageURL) {
+                RELEASE_LOG_IF_ALLOWED(Storage, "storage space increase denied");
                 m_isQuotaIncreaseDenied =  true;
+            }
             completionHandler(quota);
             StorageRequests::singleton().processNextIfAny();
         });