Bloom filter should support longer hashes
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Apr 2015 18:45:38 +0000 (18:45 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Apr 2015 18:45:38 +0000 (18:45 +0000)
commit8cf95d47f30eacda3d72a77644ea7bbe6084526c
treecc8c0f6d331fe842cc82039d818d6b5e84f80322
parent35368bd5f14848803c2df050eb95e4eabdf5aaac
Bloom filter should support longer hashes
https://bugs.webkit.org/show_bug.cgi?id=143419

Reviewed by Dan Bernstein.

Source/WebKit2:

Use the hash digest directly in the contents filter instead of going via shortHash.

* NetworkProcess/cache/NetworkCacheKey.h:
(WebKit::NetworkCache::Key::hash):
(WebKit::NetworkCache::Key::shortHash): Deleted.
(WebKit::NetworkCache::Key::toShortHash): Deleted.

    No longer needed.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::synchronize):
(WebKit::NetworkCache::Storage::addToContentsFilter):
(WebKit::NetworkCache::Storage::mayContain):
* NetworkProcess/cache/NetworkCacheStorage.h:

Source/WTF:

It currently supports 'unsigned' hash only which is inconvenient and doesn't have enough independent bits for larger filters.

Support arbitrarily sized hashes of type std::array<uint8_t, hashSize> (like SHA1::Digest and MD5::Digest).

* wtf/BloomFilter.h:
(WTF::BloomFilter<keyBits>::keysFromHash):
(WTF::BloomFilter<keyBits>::mayContain):
(WTF::BloomFilter<keyBits>::add):

Tools:

* TestWebKitAPI/Tests/WTF/BloomFilter.cpp:
(TestWebKitAPI::generateRandomDigests):
(TestWebKitAPI::TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182363 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/BloomFilter.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/BloomFilter.cpp