Title: [210739] branches/safari-603-branch/Source/WebKit2

Diff

Modified: branches/safari-603-branch/Source/WebKit2/ChangeLog (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/ChangeLog	2017-01-13 19:18:30 UTC (rev 210739)
@@ -1,3 +1,7 @@
+2017-01-13  Matthew Hanson  <matthew_han...@apple.com>
+
+        Rollout r210726. rdar://problem/29428877
+
 2017-01-12  Matthew Hanson  <matthew_han...@apple.com>
 
         Merge r209189. rdar://problem/29428877

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp	2017-01-13 19:18:30 UTC (rev 210739)
@@ -114,7 +114,7 @@
     m_storage->setCapacity(maximumSize);
 }
 
-static Key makeCacheKey(const WebCore::ResourceRequest& request)
+Key Cache::makeCacheKey(const WebCore::ResourceRequest& request)
 {
 #if ENABLE(CACHE_PARTITIONING)
     String partition = request.cachePartition();
@@ -125,7 +125,7 @@
     // FIXME: This implements minimal Range header disk cache support. We don't parse
     // ranges so only the same exact range request will be served from the cache.
     String range = request.httpHeaderField(WebCore::HTTPHeaderName::Range);
-    return { partition, resourceType(), range, request.url().string() };
+    return { partition, resourceType(), range, request.url().string(), m_storage->salt() };
 }
 
 static bool cachePolicyAllowsExpired(WebCore::ResourceRequestCachePolicy policy)

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCache.h (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCache.h	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCache.h	2017-01-13 19:18:30 UTC (rev 210739)
@@ -129,6 +129,8 @@
     Cache() = default;
     ~Cache() = delete;
 
+    Key makeCacheKey(const WebCore::ResourceRequest&);
+
     String dumpFilePath() const;
     void deleteDumpFile();
 

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.cpp (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.cpp	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.cpp	2017-01-13 19:18:30 UTC (rev 210739)
@@ -40,8 +40,9 @@
 namespace WebKit {
 namespace NetworkCache {
 
-BlobStorage::BlobStorage(const String& blobDirectoryPath)
+BlobStorage::BlobStorage(const String& blobDirectoryPath, Salt salt)
     : m_blobDirectoryPath(blobDirectoryPath)
+    , m_salt(salt)
 {
 }
 
@@ -85,7 +86,7 @@
 {
     ASSERT(!RunLoop::isMain());
 
-    auto hash = computeSHA1(data);
+    auto hash = computeSHA1(data, m_salt);
     if (data.isEmpty())
         return { data, hash };
 
@@ -123,7 +124,7 @@
     auto linkPath = WebCore::fileSystemRepresentation(path);
     auto data = ""
 
-    return { data, computeSHA1(data) };
+    return { data, computeSHA1(data, m_salt) };
 }
 
 void BlobStorage::remove(const String& path)

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.h (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.h	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheBlobStorage.h	2017-01-13 19:18:30 UTC (rev 210739)
@@ -39,7 +39,7 @@
 class BlobStorage {
     WTF_MAKE_NONCOPYABLE(BlobStorage);
 public:
-    BlobStorage(const String& blobDirectoryPath);
+    BlobStorage(const String& blobDirectoryPath, Salt);
 
     struct Blob {
         Data data;
@@ -63,6 +63,7 @@
     String blobPathForHash(const SHA1::Digest&) const;
 
     const String m_blobDirectoryPath;
+    const Salt m_salt;
 
     std::atomic<size_t> m_approximateSize { 0 };
 };

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.cpp (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.cpp	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.cpp	2017-01-13 19:18:30 UTC (rev 210739)
@@ -28,9 +28,11 @@
 
 #if ENABLE(NETWORK_CACHE)
 
+#include <WebCore/FileSystem.h>
 #include <fcntl.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
+#include <wtf/CryptographicallyRandomNumber.h>
 
 namespace WebKit {
 namespace NetworkCache {
@@ -103,13 +105,15 @@
     return Data::adoptMap(map, size, fd);
 }
 
-SHA1::Digest computeSHA1(const Data& data)
+SHA1::Digest computeSHA1(const Data& data, const Salt& salt)
 {
     SHA1 sha1;
+    sha1.addBytes(salt.data(), salt.size());
     data.apply([&sha1](const uint8_t* data, size_t size) {
         sha1.addBytes(data, size);
         return true;
     });
+
     SHA1::Digest digest;
     sha1.computeHash(digest);
     return digest;
@@ -124,6 +128,35 @@
     return !memcmp(a.data(), b.data(), a.size());
 }
 
+static Salt makeSalt()
+{
+    Salt salt;
+    static_assert(salt.size() == 8, "Salt size");
+    *reinterpret_cast<uint32_t*>(&salt[0]) = cryptographicallyRandomNumber();
+    *reinterpret_cast<uint32_t*>(&salt[4]) = cryptographicallyRandomNumber();
+    return salt;
+}
+
+std::optional<Salt> readOrMakeSalt(const String& path)
+{
+    auto cpath = WebCore::fileSystemRepresentation(path);
+    auto fd = open(cpath.data(), O_RDONLY, 0);
+    Salt salt;
+    auto bytesRead = read(fd, salt.data(), salt.size());
+    close(fd);
+    if (bytesRead != salt.size()) {
+        salt = makeSalt();
+
+        unlink(cpath.data());
+        fd = open(cpath.data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
+        bool success = write(fd, salt.data(), salt.size()) == salt.size();
+        close(fd);
+        if (!success)
+            return { };
+    }
+    return salt;
+}
+
 } // namespace NetworkCache
 } // namespace WebKit
 

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.h (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.h	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheData.h	2017-01-13 19:18:30 UTC (rev 210739)
@@ -156,8 +156,12 @@
 bool bytesEqual(const Data&, const Data&);
 Data adoptAndMapFile(int fd, size_t offset, size_t);
 Data mapFile(const char* path);
-SHA1::Digest computeSHA1(const Data&);
 
+using Salt = std::array<uint8_t, 8>;
+
+std::optional<Salt> readOrMakeSalt(const String& path);
+SHA1::Digest computeSHA1(const Data&, const Salt&);
+
 }
 }
 

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp	2017-01-13 19:18:30 UTC (rev 210739)
@@ -37,12 +37,6 @@
 namespace WebKit {
 namespace NetworkCache {
 
-static const String& noPartitionString()
-{
-    static NeverDestroyed<String> noPartition(ASCIILiteral("No partition"));
-    return noPartition;
-}
-
 Key::Key(const Key& o)
     : m_partition(o.m_partition.isolatedCopy())
     , m_type(o.m_type.isolatedCopy())
@@ -49,15 +43,17 @@
     , m_identifier(o.m_identifier.isolatedCopy())
     , m_range(o.m_range.isolatedCopy())
     , m_hash(o.m_hash)
+    , m_partitionHash(o.m_partitionHash)
 {
 }
 
-Key::Key(const String& partition, const String& type, const String& range, const String& identifier)
-    : m_partition(partition.isEmpty() ? noPartitionString() : partition)
+Key::Key(const String& partition, const String& type, const String& range, const String& identifier, const Salt& salt)
+    : m_partition(partition)
     , m_type(type)
     , m_identifier(identifier)
     , m_range(range)
-    , m_hash(computeHash())
+    , m_hash(computeHash(salt))
+    , m_partitionHash(computePartitionHash(salt))
 {
 }
 
@@ -66,11 +62,6 @@
 {
 }
 
-bool Key::hasPartition() const
-{
-    return m_partition != noPartitionString();
-}
-
 Key& Key::operator=(const Key& other)
 {
     m_partition = other.m_partition.isolatedCopy();
@@ -98,25 +89,40 @@
     sha1.addBytes(reinterpret_cast<const uint8_t*>(cString.data()), cString.length() + 1);
 }
 
-Key::HashType Key::computeHash() const
+Key::HashType Key::computeHash(const Salt& salt) const
 {
     // We don't really need a cryptographic hash. The key is always verified against the entry header.
     // SHA1 just happens to be suitably sized, fast and available.
     SHA1 sha1;
+    sha1.addBytes(salt.data(), salt.size());
+
     hashString(sha1, m_partition);
     hashString(sha1, m_type);
     hashString(sha1, m_identifier);
     hashString(sha1, m_range);
+
     SHA1::Digest hash;
     sha1.computeHash(hash);
     return hash;
 }
 
-String Key::hashAsString() const
+Key::HashType Key::computePartitionHash(const Salt& salt) const
 {
+    SHA1 sha1;
+    sha1.addBytes(salt.data(), salt.size());
+
+    hashString(sha1, m_partition);
+
+    SHA1::Digest hash;
+    sha1.computeHash(hash);
+    return hash;
+}
+
+String Key::hashAsString(const HashType& hash)
+{
     StringBuilder builder;
     builder.reserveCapacity(hashStringLength());
-    for (auto byte : m_hash) {
+    for (auto byte : hash) {
         builder.append(upperNibbleToASCIIHexDigit(byte));
         builder.append(lowerNibbleToASCIIHexDigit(byte));
     }

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h	2017-01-13 19:18:30 UTC (rev 210739)
@@ -28,6 +28,7 @@
 
 #if ENABLE(NETWORK_CACHE)
 
+#include "NetworkCacheData.h"
 #include <wtf/SHA1.h>
 #include <wtf/text/WTFString.h>
 
@@ -44,7 +45,7 @@
     Key() { }
     Key(const Key&);
     Key(Key&&) = default;
-    Key(const String& partition, const String& type, const String& range, const String& identifier);
+    Key(const String& partition, const String& type, const String& range, const String& identifier, const Salt&);
 
     Key& operator=(const Key&);
     Key& operator=(Key&&) = default;
@@ -54,18 +55,19 @@
 
     bool isNull() const { return m_identifier.isNull(); }
 
-    bool hasPartition() const;
     const String& partition() const { return m_partition; }
     const String& identifier() const { return m_identifier; }
     const String& type() const { return m_type; }
     const String& range() const { return m_range; }
 
-    HashType hash() const { return m_hash; }
+    const HashType& hash() const { return m_hash; }
+    const HashType& partitionHash() const { return m_partitionHash; }
 
     static bool stringToHash(const String&, HashType&);
 
     static size_t hashStringLength() { return 2 * sizeof(m_hash); }
-    String hashAsString() const;
+    String hashAsString() const { return hashAsString(m_hash); }
+    String partitionHashAsString() const { return hashAsString(m_partitionHash); }
 
     void encode(Encoder&) const;
     static bool decode(Decoder&, Key&);
@@ -74,7 +76,9 @@
     bool operator!=(const Key& other) const { return !(*this == other); }
 
 private:
-    HashType computeHash() const;
+    static String hashAsString(const HashType&);
+    HashType computeHash(const Salt&) const;
+    HashType computePartitionHash(const Salt&) const;
 
     String m_partition;
     String m_type;
@@ -81,6 +85,7 @@
     String m_identifier;
     String m_range;
     HashType m_hash;
+    HashType m_partitionHash;
 };
 
 }

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp	2017-01-13 19:18:30 UTC (rev 210739)
@@ -79,9 +79,9 @@
     return resource;
 }
 
-static inline Key makeSubresourcesKey(const Key& resourceKey)
+static inline Key makeSubresourcesKey(const Key& resourceKey, const Salt& salt)
 {
-    return Key(resourceKey.partition(), subresourcesType(), resourceKey.range(), resourceKey.identifier());
+    return Key(resourceKey.partition(), subresourcesType(), resourceKey.range(), resourceKey.identifier(), salt);
 }
 
 static inline ResourceRequest constructRevalidationRequest(const Entry& entry, const SubresourceInfo& subResourceInfo)
@@ -90,7 +90,7 @@
     revalidationRequest.setHTTPHeaderFields(subResourceInfo.requestHeaders());
     revalidationRequest.setFirstPartyForCookies(subResourceInfo.firstPartyForCookies());
 #if ENABLE(CACHE_PARTITIONING)
-    if (entry.key().hasPartition())
+    if (!entry.key().partition().isEmpty())
         revalidationRequest.setCachePartition(entry.key().partition());
 #endif
     ASSERT_WITH_MESSAGE(entry.key().range().isEmpty(), "range is not supported");
@@ -226,7 +226,7 @@
             m_existingEntry->updateSubresourceLoads(m_subresourceLoads);
             m_storage.store(m_existingEntry->encodeAsStorageRecord(), [](const Data&) { });
         } else {
-            SubresourcesEntry entry(makeSubresourcesKey(m_mainResourceKey), m_subresourceLoads);
+            SubresourcesEntry entry(makeSubresourcesKey(m_mainResourceKey, m_storage.salt()), m_subresourceLoads);
             m_storage.store(entry.encodeAsStorageRecord(), [](const Data&) { });
         }
     }
@@ -521,7 +521,7 @@
 void SpeculativeLoadManager::retrieveSubresourcesEntry(const Key& storageKey, std::function<void (std::unique_ptr<SubresourcesEntry>)>&& completionHandler)
 {
     ASSERT(storageKey.type() == "Resource");
-    auto subresourcesStorageKey = makeSubresourcesKey(storageKey);
+    auto subresourcesStorageKey = makeSubresourcesKey(storageKey, m_storage.salt());
     m_storage.retrieve(subresourcesStorageKey, static_cast<unsigned>(ResourceLoadPriority::Medium), [completionHandler = WTFMove(completionHandler)](auto record) {
         if (!record) {
             completionHandler(nullptr);

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp	2017-01-13 19:18:30 UTC (rev 210739)
@@ -42,6 +42,7 @@
 namespace WebKit {
 namespace NetworkCache {
 
+static const char saltFileName[] = "salt";
 static const char versionDirectoryPrefix[] = "Version ";
 static const char recordsDirectoryName[] = "Records";
 static const char blobsDirectoryName[] = "Blobs";
@@ -127,15 +128,6 @@
     unsigned activeCount { 0 };
 };
 
-std::unique_ptr<Storage> Storage::open(const String& cachePath)
-{
-    ASSERT(RunLoop::isMain());
-
-    if (!WebCore::makeAllDirectories(cachePath))
-        return nullptr;
-    return std::unique_ptr<Storage>(new Storage(cachePath));
-}
-
 static String makeVersionedDirectoryPath(const String& baseDirectoryPath)
 {
     String versionSubdirectory = versionDirectoryPrefix + String::number(Storage::version);
@@ -152,13 +144,30 @@
     return WebCore::pathByAppendingComponent(makeVersionedDirectoryPath(baseDirectoryPath), blobsDirectoryName);
 }
 
-void traverseRecordsFiles(const String& recordsPath, const String& expectedType, const std::function<void (const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath)>& function)
+static String makeSaltFilePath(const String& baseDirectoryPath)
 {
-    traverseDirectory(recordsPath, [&recordsPath, &function, &expectedType](const String& partitionName, DirectoryEntryType entryType) {
+    return WebCore::pathByAppendingComponent(makeVersionedDirectoryPath(baseDirectoryPath), saltFileName);
+}
+
+std::unique_ptr<Storage> Storage::open(const String& cachePath)
+{
+    ASSERT(RunLoop::isMain());
+
+    if (!WebCore::makeAllDirectories(makeVersionedDirectoryPath(cachePath)))
+        return nullptr;
+    auto salt = readOrMakeSalt(makeSaltFilePath(cachePath));
+    if (!salt)
+        return nullptr;
+    return std::unique_ptr<Storage>(new Storage(cachePath, *salt));
+}
+
+void traverseRecordsFiles(const String& recordsPath, const String& expectedType, const RecordFileTraverseFunction& function)
+{
+    traverseDirectory(recordsPath, [&](const String& partitionName, DirectoryEntryType entryType) {
         if (entryType != DirectoryEntryType::Directory)
             return;
         String partitionPath = WebCore::pathByAppendingComponent(recordsPath, partitionName);
-        traverseDirectory(partitionPath, [&function, &partitionPath, &expectedType](const String& actualType, DirectoryEntryType entryType) {
+        traverseDirectory(partitionPath, [&](const String& actualType, DirectoryEntryType entryType) {
             if (entryType != DirectoryEntryType::Directory)
                 return;
             if (!expectedType.isEmpty() && expectedType != actualType)
@@ -198,15 +207,16 @@
     });
 }
 
-Storage::Storage(const String& baseDirectoryPath)
+Storage::Storage(const String& baseDirectoryPath, Salt salt)
     : m_basePath(baseDirectoryPath)
     , m_recordsPath(makeRecordsDirectoryPath(baseDirectoryPath))
+    , m_salt(salt)
     , m_readOperationTimeoutTimer(*this, &Storage::cancelAllReadOperations)
     , m_writeOperationDispatchTimer(*this, &Storage::dispatchPendingWriteOperations)
     , m_ioQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage", WorkQueue::Type::Concurrent))
     , m_backgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.background", WorkQueue::Type::Concurrent, WorkQueue::QOS::Background))
     , m_serialBackgroundIOQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage.serialBackground", WorkQueue::Type::Serial, WorkQueue::QOS::Background))
-    , m_blobStorage(makeBlobDirectoryPath(baseDirectoryPath))
+    , m_blobStorage(makeBlobDirectoryPath(baseDirectoryPath), m_salt)
 {
     deleteOldVersions();
     synchronize();
@@ -326,9 +336,8 @@
 
 String Storage::recordDirectoryPathForKey(const Key& key) const
 {
-    ASSERT(!key.partition().isEmpty());
     ASSERT(!key.type().isEmpty());
-    return WebCore::pathByAppendingComponent(WebCore::pathByAppendingComponent(recordsPath(), key.partition()), key.type());
+    return WebCore::pathByAppendingComponent(WebCore::pathByAppendingComponent(recordsPath(), key.partitionHashAsString()), key.type());
 }
 
 String Storage::recordPathForKey(const Key& key) const
@@ -397,7 +406,7 @@
     return success;
 }
 
-static bool decodeRecordHeader(const Data& fileData, RecordMetaData& metaData, Data& headerData)
+static bool decodeRecordHeader(const Data& fileData, RecordMetaData& metaData, Data& headerData, const Salt& salt)
 {
     if (!decodeRecordMetaData(metaData, fileData)) {
         LOG(NetworkCacheStorage, "(NetworkProcess) meta data decode failure");
@@ -410,7 +419,7 @@
     }
 
     headerData = fileData.subrange(metaData.headerOffset, metaData.headerSize);
-    if (metaData.headerHash != computeSHA1(headerData)) {
+    if (metaData.headerHash != computeSHA1(headerData, salt)) {
         LOG(NetworkCacheStorage, "(NetworkProcess) header checksum mismatch");
         return false;
     }
@@ -423,7 +432,7 @@
 
     RecordMetaData metaData;
     Data headerData;
-    if (!decodeRecordHeader(recordData, metaData, headerData))
+    if (!decodeRecordHeader(recordData, metaData, headerData, m_salt))
         return;
 
     if (metaData.key != readOperation.key)
@@ -440,7 +449,7 @@
         if (bodyOffset + metaData.bodySize != recordData.size())
             return;
         bodyData = recordData.subrange(bodyOffset, metaData.bodySize);
-        if (metaData.bodyHash != computeSHA1(bodyData))
+        if (metaData.bodyHash != computeSHA1(bodyData, m_salt))
             return;
     }
 
@@ -502,9 +511,9 @@
 
     RecordMetaData metaData(record.key);
     metaData.epochRelativeTimeStamp = std::chrono::duration_cast<std::chrono::milliseconds>(record.timeStamp.time_since_epoch());
-    metaData.headerHash = computeSHA1(record.header);
+    metaData.headerHash = computeSHA1(record.header, m_salt);
     metaData.headerSize = record.header.size();
-    metaData.bodyHash = blob ? blob.value().hash : computeSHA1(record.body);
+    metaData.bodyHash = blob ? blob.value().hash : computeSHA1(record.body, m_salt);
     metaData.bodySize = record.body.size();
     metaData.isBodyInline = !blob;
 
@@ -823,7 +832,7 @@
             channel->read(0, std::numeric_limits<size_t>::max(), nullptr, [this, &traverseOperation, worth, bodyShareCount](Data& fileData, int) {
                 RecordMetaData metaData;
                 Data headerData;
-                if (decodeRecordHeader(fileData, metaData, headerData)) {
+                if (decodeRecordHeader(fileData, metaData, headerData, m_salt)) {
                     Record record {
                         metaData.key,
                         std::chrono::system_clock::time_point(metaData.epochRelativeTimeStamp),

Modified: branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h (210738 => 210739)


--- branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h	2017-01-13 19:18:25 UTC (rev 210738)
+++ branches/safari-603-branch/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h	2017-01-13 19:18:30 UTC (rev 210739)
@@ -87,7 +87,7 @@
     size_t capacity() const { return m_capacity; }
     size_t approximateSize() const;
 
-    static const unsigned version = 10;
+    static const unsigned version = 11;
 #if PLATFORM(MAC)
     /// Allow the last stable version of the cache to co-exist with the latest development one.
     static const unsigned lastStableVersion = 9;
@@ -97,10 +97,12 @@
     String versionPath() const;
     String recordsPath() const;
 
+    const Salt& salt() const { return m_salt; }
+
     ~Storage();
 
 private:
-    Storage(const String& directoryPath);
+    Storage(const String& directoryPath, Salt);
 
     String recordDirectoryPathForKey(const Key&) const;
     String recordPathForKey(const Key&) const;
@@ -141,6 +143,8 @@
     const String m_basePath;
     const String m_recordsPath;
 
+    const Salt m_salt;
+
     size_t m_capacity { std::numeric_limits<size_t>::max() };
     size_t m_approximateRecordsSize { 0 };
 
@@ -175,7 +179,8 @@
 };
 
 // FIXME: Remove, used by NetworkCacheStatistics only.
-void traverseRecordsFiles(const String& recordsPath, const String& type, const std::function<void (const String& fileName, const String& hashString, const String& type, bool isBodyBlob, const String& recordDirectoryPath)>&);
+using RecordFileTraverseFunction = std::function<void (const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath)>;
+void traverseRecordsFiles(const String& recordsPath, const String& type, const RecordFileTraverseFunction&);
 
 }
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to