Title: [250666] trunk/Source/WebCore
Revision
250666
Author
[email protected]
Date
2019-10-03 12:03:57 -0700 (Thu, 03 Oct 2019)

Log Message

IndexedDB: add size estimate for key path when estimate task size
https://bugs.webkit.org/show_bug.cgi?id=202480

Reviewed by Geoffrey Garen.

No observable behavior change.

* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::estimateSize):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (250665 => 250666)


--- trunk/Source/WebCore/ChangeLog	2019-10-03 18:32:37 UTC (rev 250665)
+++ trunk/Source/WebCore/ChangeLog	2019-10-03 19:03:57 UTC (rev 250666)
@@ -1,3 +1,15 @@
+2019-10-03  Sihui Liu  <[email protected]>
+
+        IndexedDB: add size estimate for key path when estimate task size
+        https://bugs.webkit.org/show_bug.cgi?id=202480
+
+        Reviewed by Geoffrey Garen.
+
+        No observable behavior change.
+
+        * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+        (WebCore::IDBServer::estimateSize):
+
 2019-10-03  youenn fablet  <[email protected]>
 
         Regression: iOS 13.1 MediaStreamTrack.enabled = false kills audio track

Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (250665 => 250666)


--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2019-10-03 18:32:37 UTC (rev 250665)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp	2019-10-03 19:03:57 UTC (rev 250666)
@@ -88,10 +88,23 @@
     return size;
 }
 
+static inline uint64_t estimateSize(const IDBKeyPath& keyPath)
+{
+    return WTF::switchOn(keyPath, [](const String& path) {
+        return path.sizeInBytes();
+    }, [](const Vector<String>& paths) {
+        uint64_t size = 0;
+        for (auto path : paths)
+            size += path.sizeInBytes();
+        return size;
+    });
+}
+
 static inline uint64_t estimateSize(const IDBIndexInfo& info)
 {
     uint64_t size = 4;
     size += info.name().sizeInBytes();
+    size += estimateSize(info.keyPath());
     return size;
 }
 
@@ -99,9 +112,8 @@
 {
     uint64_t size = 4;
     size += info.name().sizeInBytes();
-    // FIXME: estimate keyPath.
-    for (auto& indexInfo : info.indexMap().values())
-        size += estimateSize(indexInfo);
+    if (auto keyPath = info.keyPath())
+        size += estimateSize(*keyPath);
     return size;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to