Move disk cache classes to namespace
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Mar 2015 08:00:22 +0000 (08:00 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Mar 2015 08:00:22 +0000 (08:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=142339

Reviewed by Anders Carlsson.

Move everything to NetworkCache namespace.

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

21 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCache.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheCoder.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheData.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheDataCocoa.mm
Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystemPosix.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannel.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheIOChannelCocoa.mm
Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheStatisticsCocoa.mm
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorageCocoa.mm

index adae593..023c15c 100644 (file)
@@ -1,3 +1,12 @@
+2015-03-05  Antti Koivisto  <antti@apple.com>
+
+        Move disk cache classes to namespace
+        https://bugs.webkit.org/show_bug.cgi?id=142339
+
+        Reviewed by Anders Carlsson.
+
+        Move everything to NetworkCache namespace. 
+
 2015-03-05  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         REGRESSION(r180924): ASSERTION FAILED: !from.isEmpty() in WebCore::TransformationMatrix::rectToRect
index 8c58367..03c24b3 100644 (file)
 #endif
 
 namespace WebKit {
+namespace NetworkCache {
 
-NetworkCache& NetworkCache::singleton()
+Cache& singleton()
 {
-    static NeverDestroyed<NetworkCache> instance;
+    static NeverDestroyed<Cache> instance;
     return instance;
 }
 
-bool NetworkCache::initialize(const String& cachePath, bool enableEfficacyLogging)
+bool Cache::initialize(const String& cachePath, bool enableEfficacyLogging)
 {
-    m_storage = NetworkCacheStorage::open(cachePath);
+    m_storage = Storage::open(cachePath);
 
     if (enableEfficacyLogging)
-        m_statistics = NetworkCacheStatistics::open(cachePath);
+        m_statistics = Statistics::open(cachePath);
 
 #if PLATFORM(COCOA)
     // Triggers with "notifyutil -p com.apple.WebKit.Cache.dump".
@@ -77,14 +78,14 @@ bool NetworkCache::initialize(const String& cachePath, bool enableEfficacyLoggin
     return !!m_storage;
 }
 
-void NetworkCache::setMaximumSize(size_t maximumSize)
+void Cache::setMaximumSize(size_t maximumSize)
 {
     if (!m_storage)
         return;
     m_storage->setMaximumSize(maximumSize);
 }
 
-static NetworkCacheKey makeCacheKey(const WebCore::ResourceRequest& request)
+static Key makeCacheKey(const WebCore::ResourceRequest& request)
 {
 #if ENABLE(CACHE_PARTITIONING)
     String partition = request.cachePartition();
@@ -96,9 +97,9 @@ static NetworkCacheKey makeCacheKey(const WebCore::ResourceRequest& request)
     return { request.httpMethod(), partition, request.url().string()  };
 }
 
-static NetworkCacheStorage::Entry encodeStorageEntry(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, PassRefPtr<WebCore::SharedBuffer> responseData)
+static Storage::Entry encodeStorageEntry(const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& response, PassRefPtr<WebCore::SharedBuffer> responseData)
 {
-    NetworkCacheEncoder encoder;
+    Encoder encoder;
     encoder << response;
 
     String varyValue = response.httpHeaderField(WebCore::HTTPHeaderName::Vary);
@@ -120,8 +121,8 @@ static NetworkCacheStorage::Entry encodeStorageEntry(const WebCore::ResourceRequ
     encoder.encodeChecksum();
 
     auto timeStamp = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
-    NetworkCacheData header(encoder.buffer(), encoder.bufferSize());
-    NetworkCacheData body;
+    Data header(encoder.buffer(), encoder.bufferSize());
+    Data body;
     if (responseData)
         body = { reinterpret_cast<const uint8_t*>(responseData->data()), responseData->size() };
 
@@ -155,39 +156,39 @@ static bool cachePolicyAllowsExpired(WebCore::ResourceRequestCachePolicy policy)
     return false;
 }
 
-static std::unique_ptr<NetworkCache::Entry> decodeStorageEntry(const NetworkCacheStorage::Entry& storageEntry, const WebCore::ResourceRequest& request, NetworkCache::CachedEntryReuseFailure& failure)
+static std::unique_ptr<Entry> decodeStorageEntry(const Storage::Entry& storageEntry, const WebCore::ResourceRequest& request, CachedEntryReuseFailure& failure)
 {
-    NetworkCacheDecoder decoder(storageEntry.header.data(), storageEntry.header.size());
+    Decoder decoder(storageEntry.header.data(), storageEntry.header.size());
 
     WebCore::ResourceResponse cachedResponse;
     if (!decoder.decode(cachedResponse)) {
         LOG(NetworkCache, "(NetworkProcess) response decoding failed\n");
-        failure = NetworkCache::CachedEntryReuseFailure::Other;
+        failure = CachedEntryReuseFailure::Other;
         return nullptr;
     }
 
     bool hasVaryingRequestHeaders;
     if (!decoder.decode(hasVaryingRequestHeaders)) {
-        failure = NetworkCache::CachedEntryReuseFailure::Other;
+        failure = CachedEntryReuseFailure::Other;
         return nullptr;
     }
 
     if (hasVaryingRequestHeaders) {
         Vector<std::pair<String, String>> varyingRequestHeaders;
         if (!decoder.decode(varyingRequestHeaders)) {
-            failure = NetworkCache::CachedEntryReuseFailure::Other;
+            failure = CachedEntryReuseFailure::Other;
             return nullptr;
         }
 
         if (!verifyVaryingRequestHeaders(varyingRequestHeaders, request)) {
             LOG(NetworkCache, "(NetworkProcess) varying header mismatch\n");
-            failure = NetworkCache::CachedEntryReuseFailure::VaryingHeaderMismatch;
+            failure = CachedEntryReuseFailure::VaryingHeaderMismatch;
             return nullptr;
         }
     }
     if (!decoder.verifyChecksum()) {
         LOG(NetworkCache, "(NetworkProcess) checksum verification failure\n");
-        failure = NetworkCache::CachedEntryReuseFailure::Other;
+        failure = CachedEntryReuseFailure::Other;
         return nullptr;
     }
 
@@ -202,12 +203,12 @@ static std::unique_ptr<NetworkCache::Entry> decodeStorageEntry(const NetworkCach
         bool hasValidatorFields = cachedResponse.hasCacheValidatorFields();
         LOG(NetworkCache, "(NetworkProcess) needsRevalidation hasValidatorFields=%d isExpired=%d age=%f lifetime=%f", isExpired, hasValidatorFields, age, lifetime);
         if (!hasValidatorFields) {
-            failure = NetworkCache::CachedEntryReuseFailure::MissingValidatorFields;
+            failure = CachedEntryReuseFailure::MissingValidatorFields;
             return nullptr;
         }
     }
 
-    auto entry = std::make_unique<NetworkCache::Entry>();
+    auto entry = std::make_unique<Entry>();
     entry->storageEntry = storageEntry;
     entry->needsRevalidation = needsRevalidation;
 
@@ -227,29 +228,29 @@ static std::unique_ptr<NetworkCache::Entry> decodeStorageEntry(const NetworkCach
     return entry;
 }
 
-static NetworkCache::RetrieveDecision canRetrieve(const WebCore::ResourceRequest& request)
+static RetrieveDecision canRetrieve(const WebCore::ResourceRequest& request)
 {
     if (!request.url().protocolIsInHTTPFamily())
-        return NetworkCache::RetrieveDecision::NoDueToProtocol;
+        return RetrieveDecision::NoDueToProtocol;
     // FIXME: Support HEAD and OPTIONS requests.
     if (request.httpMethod() != "GET")
-        return NetworkCache::RetrieveDecision::NoDueToHTTPMethod;
+        return RetrieveDecision::NoDueToHTTPMethod;
     // FIXME: We should be able to validate conditional requests using cache.
     if (request.isConditional())
-        return NetworkCache::RetrieveDecision::NoDueToConditionalRequest;
+        return RetrieveDecision::NoDueToConditionalRequest;
     if (request.cachePolicy() == WebCore::ReloadIgnoringCacheData)
-        return NetworkCache::RetrieveDecision::NoDueToReloadIgnoringCache;
+        return RetrieveDecision::NoDueToReloadIgnoringCache;
 
-    return NetworkCache::RetrieveDecision::Yes;
+    return RetrieveDecision::Yes;
 }
 
-void NetworkCache::retrieve(const WebCore::ResourceRequest& originalRequest, uint64_t webPageID, std::function<void (std::unique_ptr<Entry>)> completionHandler)
+void Cache::retrieve(const WebCore::ResourceRequest& originalRequest, uint64_t webPageID, std::function<void (std::unique_ptr<Entry>)> completionHandler)
 {
     ASSERT(isEnabled());
 
     LOG(NetworkCache, "(NetworkProcess) retrieving %s priority %u", originalRequest.url().string().ascii().data(), originalRequest.priority());
 
-    NetworkCacheKey storageKey = makeCacheKey(originalRequest);
+    Key storageKey = makeCacheKey(originalRequest);
     RetrieveDecision retrieveDecision = canRetrieve(originalRequest);
     if (retrieveDecision != RetrieveDecision::Yes) {
         if (m_statistics)
@@ -262,7 +263,7 @@ void NetworkCache::retrieve(const WebCore::ResourceRequest& originalRequest, uin
     auto startTime = std::chrono::system_clock::now();
     unsigned priority = originalRequest.priority();
 
-    m_storage->retrieve(storageKey, priority, [this, originalRequest, completionHandler, startTime, storageKey, webPageID](std::unique_ptr<NetworkCacheStorage::Entry> entry) {
+    m_storage->retrieve(storageKey, priority, [this, originalRequest, completionHandler, startTime, storageKey, webPageID](std::unique_ptr<Storage::Entry> entry) {
         if (!entry) {
             LOG(NetworkCache, "(NetworkProcess) not found in storage");
 
@@ -289,19 +290,19 @@ void NetworkCache::retrieve(const WebCore::ResourceRequest& originalRequest, uin
     });
 }
 
-static NetworkCache::StoreDecision canStore(const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceResponse& response)
+static StoreDecision canStore(const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceResponse& response)
 {
     if (!originalRequest.url().protocolIsInHTTPFamily() || !response.isHTTP()) {
         LOG(NetworkCache, "(NetworkProcess) not HTTP");
-        return NetworkCache::StoreDecision::NoDueToProtocol;
+        return StoreDecision::NoDueToProtocol;
     }
     if (originalRequest.httpMethod() != "GET") {
         LOG(NetworkCache, "(NetworkProcess) method %s", originalRequest.httpMethod().utf8().data());
-        return NetworkCache::StoreDecision::NoDueToHTTPMethod;
+        return StoreDecision::NoDueToHTTPMethod;
     }
     if (response.isAttachment()) {
         LOG(NetworkCache, "(NetworkProcess) attachment");
-        return NetworkCache::StoreDecision::NoDueToAttachmentResponse;
+        return StoreDecision::NoDueToAttachmentResponse;
     }
 
     switch (response.httpStatusCode()) {
@@ -314,17 +315,17 @@ static NetworkCache::StoreDecision canStore(const WebCore::ResourceRequest& orig
     case 410: // Gone
         if (response.cacheControlContainsNoStore()) {
             LOG(NetworkCache, "(NetworkProcess) Cache-control:no-store");
-            return NetworkCache::StoreDecision::NoDueToNoStoreResponse;
+            return StoreDecision::NoDueToNoStoreResponse;
         }
-        return NetworkCache::StoreDecision::Yes;
+        return StoreDecision::Yes;
     default:
         LOG(NetworkCache, "(NetworkProcess) status code %d", response.httpStatusCode());
     }
 
-    return NetworkCache::StoreDecision::NoDueToHTTPStatusCode;
+    return StoreDecision::NoDueToHTTPStatusCode;
 }
 
-void NetworkCache::store(const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceResponse& response, RefPtr<WebCore::SharedBuffer>&& responseData, std::function<void (MappedBody&)> completionHandler)
+void Cache::store(const WebCore::ResourceRequest& originalRequest, const WebCore::ResourceResponse& response, RefPtr<WebCore::SharedBuffer>&& responseData, std::function<void (MappedBody&)> completionHandler)
 {
     ASSERT(isEnabled());
     ASSERT(responseData);
@@ -343,7 +344,7 @@ void NetworkCache::store(const WebCore::ResourceRequest& originalRequest, const
 
     auto storageEntry = encodeStorageEntry(originalRequest, response, WTF::move(responseData));
 
-    m_storage->store(storageEntry, [completionHandler](bool success, const NetworkCacheData& bodyData) {
+    m_storage->store(storageEntry, [completionHandler](bool success, const Data& bodyData) {
         MappedBody mappedBody;
 #if ENABLE(SHAREABLE_RESOURCE)
         if (bodyData.isMap()) {
@@ -358,7 +359,7 @@ void NetworkCache::store(const WebCore::ResourceRequest& originalRequest, const
     });
 }
 
-void NetworkCache::update(const WebCore::ResourceRequest& originalRequest, const Entry& entry, const WebCore::ResourceResponse& validatingResponse)
+void Cache::update(const WebCore::ResourceRequest& originalRequest, const Entry& entry, const WebCore::ResourceResponse& validatingResponse)
 {
     LOG(NetworkCache, "(NetworkProcess) updating %s", originalRequest.url().string().latin1().data());
 
@@ -367,25 +368,25 @@ void NetworkCache::update(const WebCore::ResourceRequest& originalRequest, const
 
     auto updateEntry = encodeStorageEntry(originalRequest, response, entry.buffer);
 
-    m_storage->update(updateEntry, entry.storageEntry, [](bool success, const NetworkCacheData&) {
+    m_storage->update(updateEntry, entry.storageEntry, [](bool success, const Data&) {
         LOG(NetworkCache, "(NetworkProcess) updated, success=%d", success);
     });
 }
 
-void NetworkCache::traverse(std::function<void (const Entry*)>&& traverseHandler)
+void Cache::traverse(std::function<void (const Entry*)>&& traverseHandler)
 {
     ASSERT(isEnabled());
 
-    m_storage->traverse([traverseHandler](const NetworkCacheStorage::Entry* entry) {
+    m_storage->traverse([traverseHandler](const Storage::Entry* entry) {
         if (!entry) {
             traverseHandler(nullptr);
             return;
         }
 
-        NetworkCache::Entry cacheEntry;
+        Entry cacheEntry;
         cacheEntry.storageEntry = *entry;
 
-        NetworkCacheDecoder decoder(cacheEntry.storageEntry.header.data(), cacheEntry.storageEntry.header.size());
+        Decoder decoder(cacheEntry.storageEntry.header.data(), cacheEntry.storageEntry.header.size());
         if (!decoder.decode(cacheEntry.response))
             return;
 
@@ -393,14 +394,14 @@ void NetworkCache::traverse(std::function<void (const Entry*)>&& traverseHandler
     });
 }
 
-String NetworkCache::dumpFilePath() const
+String Cache::dumpFilePath() const
 {
     return WebCore::pathByAppendingComponent(m_storage->baseDirectoryPath(), "dump.json");
 }
 
-static bool entryAsJSON(StringBuilder& json, const NetworkCacheStorage::Entry& entry)
+static bool entryAsJSON(StringBuilder& json, const Storage::Entry& entry)
 {
-    NetworkCacheDecoder decoder(entry.header.data(), entry.header.size());
+    Decoder decoder(entry.header.data(), entry.header.size());
     WebCore::ResourceResponse cachedResponse;
     if (!decoder.decode(cachedResponse))
         return false;
@@ -433,7 +434,7 @@ static bool entryAsJSON(StringBuilder& json, const NetworkCacheStorage::Entry& e
     return true;
 }
 
-void NetworkCache::dumpContentsToFile()
+void Cache::dumpContentsToFile()
 {
     if (!m_storage)
         return;
@@ -441,7 +442,7 @@ void NetworkCache::dumpContentsToFile()
     if (!dumpFileHandle)
         return;
     WebCore::writeToFile(dumpFileHandle, "[\n", 2);
-    m_storage->traverse([dumpFileHandle](const NetworkCacheStorage::Entry* entry) {
+    m_storage->traverse([dumpFileHandle](const Storage::Entry* entry) {
         if (!entry) {
             WebCore::writeToFile(dumpFileHandle, "{}\n]\n", 5);
             auto handle = dumpFileHandle;
@@ -457,7 +458,7 @@ void NetworkCache::dumpContentsToFile()
     });
 }
 
-void NetworkCache::clear()
+void Cache::clear()
 {
     LOG(NetworkCache, "(NetworkProcess) clearing cache");
     if (m_storage) {
@@ -473,11 +474,12 @@ void NetworkCache::clear()
         m_statistics->clear();
 }
 
-String NetworkCache::storagePath() const
+String Cache::storagePath() const
 {
     return m_storage ? m_storage->directoryPath() : String();
 }
 
 }
+}
 
 #endif
index e34563a..48b2d81 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -40,62 +40,65 @@ class URL;
 }
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheStatistics;
+class Cache;
+class Statistics;
 
-class NetworkCache {
-    WTF_MAKE_NONCOPYABLE(NetworkCache);
-    friend class WTF::NeverDestroyed<NetworkCache>;
-public:
-    enum class RetrieveDecision {
-        Yes,
-        NoDueToProtocol,
-        NoDueToHTTPMethod,
-        NoDueToConditionalRequest,
-        NoDueToReloadIgnoringCache
-    };
-
-    enum class StoreDecision {
-        Yes,
-        NoDueToProtocol,
-        NoDueToHTTPMethod,
-        NoDueToAttachmentResponse,
-        NoDueToNoStoreResponse,
-        NoDueToHTTPStatusCode
-    };
-
-    enum class CachedEntryReuseFailure {
-        None,
-        VaryingHeaderMismatch,
-        MissingValidatorFields,
-        Other,
-    };
-
-    static NetworkCache& singleton();
+Cache& singleton();
+
+struct MappedBody {
+#if ENABLE(SHAREABLE_RESOURCE)
+    RefPtr<ShareableResource> shareableResource;
+    ShareableResource::Handle shareableResourceHandle;
+#endif
+};
+
+struct Entry {
+    Storage::Entry storageEntry;
+    WebCore::ResourceResponse response;
+    RefPtr<WebCore::SharedBuffer> buffer;
+#if ENABLE(SHAREABLE_RESOURCE)
+    ShareableResource::Handle shareableResourceHandle;
+#endif
+    bool needsRevalidation;
+};
+
+enum class RetrieveDecision {
+    Yes,
+    NoDueToProtocol,
+    NoDueToHTTPMethod,
+    NoDueToConditionalRequest,
+    NoDueToReloadIgnoringCache
+};
 
+enum class StoreDecision {
+    Yes,
+    NoDueToProtocol,
+    NoDueToHTTPMethod,
+    NoDueToAttachmentResponse,
+    NoDueToNoStoreResponse,
+    NoDueToHTTPStatusCode
+};
+
+enum class CachedEntryReuseFailure {
+    None,
+    VaryingHeaderMismatch,
+    MissingValidatorFields,
+    Other,
+};
+
+class Cache {
+    WTF_MAKE_NONCOPYABLE(Cache);
+    friend class WTF::NeverDestroyed<Cache>;
+public:
     bool initialize(const String& cachePath, bool enableEfficacyLogging);
     void setMaximumSize(size_t);
 
     bool isEnabled() const { return !!m_storage; }
 
-    struct Entry {
-        NetworkCacheStorage::Entry storageEntry;
-        WebCore::ResourceResponse response;
-        RefPtr<WebCore::SharedBuffer> buffer;
-#if ENABLE(SHAREABLE_RESOURCE)
-        ShareableResource::Handle shareableResourceHandle;
-#endif
-        bool needsRevalidation;
-    };
     // Completion handler may get called back synchronously on failure.
     void retrieve(const WebCore::ResourceRequest&, uint64_t webPageID, std::function<void (std::unique_ptr<Entry>)>);
-
-    struct MappedBody {
-#if ENABLE(SHAREABLE_RESOURCE)
-        RefPtr<ShareableResource> shareableResource;
-        ShareableResource::Handle shareableResourceHandle;
-#endif
-    };
     void store(const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, RefPtr<WebCore::SharedBuffer>&&, std::function<void (MappedBody&)>);
     void update(const WebCore::ResourceRequest&, const Entry&, const WebCore::ResourceResponse& validatingResponse);
 
@@ -108,15 +111,16 @@ public:
     String storagePath() const;
 
 private:
-    NetworkCache() = default;
-    ~NetworkCache() = delete;
+    Cache() = default;
+    ~Cache() = delete;
 
     String dumpFilePath() const;
 
-    std::unique_ptr<NetworkCacheStorage> m_storage;
-    std::unique_ptr<NetworkCacheStatistics> m_statistics;
+    std::unique_ptr<Storage> m_storage;
+    std::unique_ptr<Statistics> m_statistics;
 };
 
 }
+}
 #endif
 #endif
index 0009c74..4b4be36 100644 (file)
 #if ENABLE(NETWORK_CACHE)
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheDecoder;
-class NetworkCacheEncoder;
+class Decoder;
+class Encoder;
     
-template<typename T> struct NetworkCacheCoder {
-    static void encode(NetworkCacheEncoder& encoder, const T& t)
+template<typename T> struct Coder {
+    static void encode(Encoder& encoder, const T& t)
     {
         t.encode(encoder);
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, T& t)
+    static bool decode(Decoder& decoder, T& t)
     {
         return T::decode(decoder, t);
     }
 };
 
 }
+}
 
 #endif
 #endif
index f458d61..b3e906b 100644 (file)
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-void NetworkCacheCoder<AtomicString>::encode(NetworkCacheEncoder& encoder, const AtomicString& atomicString)
+void Coder<AtomicString>::encode(Encoder& encoder, const AtomicString& atomicString)
 {
     encoder << atomicString.string();
 }
 
-bool NetworkCacheCoder<AtomicString>::decode(NetworkCacheDecoder& decoder, AtomicString& atomicString)
+bool Coder<AtomicString>::decode(Decoder& decoder, AtomicString& atomicString)
 {
     String string;
     if (!decoder.decode(string))
@@ -49,7 +50,7 @@ bool NetworkCacheCoder<AtomicString>::decode(NetworkCacheDecoder& decoder, Atomi
     return true;
 }
 
-void NetworkCacheCoder<CString>::encode(NetworkCacheEncoder& encoder, const CString& string)
+void Coder<CString>::encode(Encoder& encoder, const CString& string)
 {
     // Special case the null string.
     if (string.isNull()) {
@@ -62,7 +63,7 @@ void NetworkCacheCoder<CString>::encode(NetworkCacheEncoder& encoder, const CStr
     encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length);
 }
 
-bool NetworkCacheCoder<CString>::decode(NetworkCacheDecoder& decoder, CString& result)
+bool Coder<CString>::decode(Decoder& decoder, CString& result)
 {
     uint32_t length;
     if (!decoder.decode(length))
@@ -90,7 +91,7 @@ bool NetworkCacheCoder<CString>::decode(NetworkCacheDecoder& decoder, CString& r
 }
 
 
-void NetworkCacheCoder<String>::encode(NetworkCacheEncoder& encoder, const String& string)
+void Coder<String>::encode(Encoder& encoder, const String& string)
 {
     // Special case the null string.
     if (string.isNull()) {
@@ -110,7 +111,7 @@ void NetworkCacheCoder<String>::encode(NetworkCacheEncoder& encoder, const Strin
 }
 
 template <typename CharacterType>
-static inline bool decodeStringText(NetworkCacheDecoder& decoder, uint32_t length, String& result)
+static inline bool decodeStringText(Decoder& decoder, uint32_t length, String& result)
 {
     // Before allocating the string, make sure that the decoder buffer is big enough.
     if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length)) {
@@ -127,7 +128,7 @@ static inline bool decodeStringText(NetworkCacheDecoder& decoder, uint32_t lengt
     return true;    
 }
 
-bool NetworkCacheCoder<String>::decode(NetworkCacheDecoder& decoder, String& result)
+bool Coder<String>::decode(Decoder& decoder, String& result)
 {
     uint32_t length;
     if (!decoder.decode(length))
@@ -148,7 +149,7 @@ bool NetworkCacheCoder<String>::decode(NetworkCacheDecoder& decoder, String& res
     return decodeStringText<UChar>(decoder, length, result);
 }
 
-void NetworkCacheCoder<WebCore::CertificateInfo>::encode(NetworkCacheEncoder& encoder, const WebCore::CertificateInfo& certificateInfo)
+void Coder<WebCore::CertificateInfo>::encode(Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
 {
     // FIXME: Cocoa CertificateInfo is a CF object tree. Generalize CF type coding so we don't need to use ArgumentCoder here.
     IPC::ArgumentEncoder argumentEncoder;
@@ -157,7 +158,7 @@ void NetworkCacheCoder<WebCore::CertificateInfo>::encode(NetworkCacheEncoder& en
     encoder.encodeFixedLengthData(argumentEncoder.buffer(), argumentEncoder.bufferSize());
 }
 
-bool NetworkCacheCoder<WebCore::CertificateInfo>::decode(NetworkCacheDecoder& decoder, WebCore::CertificateInfo& certificateInfo)
+bool Coder<WebCore::CertificateInfo>::decode(Decoder& decoder, WebCore::CertificateInfo& certificateInfo)
 {
     uint64_t certificateSize;
     if (!decoder.decode(certificateSize))
@@ -173,16 +174,17 @@ bool NetworkCacheCoder<WebCore::CertificateInfo>::decode(NetworkCacheDecoder& de
     return true;
 }
 
-void NetworkCacheCoder<MD5::Digest>::encode(NetworkCacheEncoder& encoder, const MD5::Digest& digest)
+void Coder<MD5::Digest>::encode(Encoder& encoder, const MD5::Digest& digest)
 {
     encoder.encodeFixedLengthData(digest.data(), sizeof(digest));
 }
 
-bool NetworkCacheCoder<MD5::Digest>::decode(NetworkCacheDecoder& decoder, MD5::Digest& digest)
+bool Coder<MD5::Digest>::decode(Decoder& decoder, MD5::Digest& digest)
 {
     return decoder.decodeFixedLengthData(digest.data(), sizeof(digest));
 }
 
 }
+}
 
 #endif
index 92c28b0..4429d3b 100644 (file)
 #include <wtf/Vector.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-template<typename T, typename U> struct NetworkCacheCoder<std::pair<T, U>> {
-    static void encode(NetworkCacheEncoder& encoder, const std::pair<T, U>& pair)
+template<typename T, typename U> struct Coder<std::pair<T, U>> {
+    static void encode(Encoder& encoder, const std::pair<T, U>& pair)
     {
         encoder << pair.first << pair.second;
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, std::pair<T, U>& pair)
+    static bool decode(Decoder& decoder, std::pair<T, U>& pair)
     {
         T first;
         if (!decoder.decode(first))
@@ -62,14 +63,14 @@ template<typename T, typename U> struct NetworkCacheCoder<std::pair<T, U>> {
     }
 };
 
-template<typename Rep, typename Period> struct NetworkCacheCoder<std::chrono::duration<Rep, Period>> {
-    static void encode(NetworkCacheEncoder& encoder, const std::chrono::duration<Rep, Period>& duration)
+template<typename Rep, typename Period> struct Coder<std::chrono::duration<Rep, Period>> {
+    static void encode(Encoder& encoder, const std::chrono::duration<Rep, Period>& duration)
     {
         static_assert(std::is_integral<Rep>::value && std::is_signed<Rep>::value && sizeof(Rep) <= sizeof(int64_t), "Serialization of this Rep type is not supported yet. Only signed integer type which can be fit in an int64_t is currently supported.");
         encoder << static_cast<int64_t>(duration.count());
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, std::chrono::duration<Rep, Period>& result)
+    static bool decode(Decoder& decoder, std::chrono::duration<Rep, Period>& result)
     {
         int64_t count;
         if (!decoder.decode(count))
@@ -79,13 +80,13 @@ template<typename Rep, typename Period> struct NetworkCacheCoder<std::chrono::du
     }
 };
 
-template<typename KeyType, typename ValueType> struct NetworkCacheCoder<WTF::KeyValuePair<KeyType, ValueType>> {
-    static void encode(NetworkCacheEncoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair)
+template<typename KeyType, typename ValueType> struct Coder<WTF::KeyValuePair<KeyType, ValueType>> {
+    static void encode(Encoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair)
     {
         encoder << pair.key << pair.value;
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
+    static bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
     {
         KeyType key;
         if (!decoder.decode(key))
@@ -101,17 +102,17 @@ template<typename KeyType, typename ValueType> struct NetworkCacheCoder<WTF::Key
     }
 };
 
-template<bool fixedSizeElements, typename T, size_t inlineCapacity> struct VectorNetworkCacheCoder;
+template<bool fixedSizeElements, typename T, size_t inlineCapacity> struct VectorCoder;
 
-template<typename T, size_t inlineCapacity> struct VectorNetworkCacheCoder<false, T, inlineCapacity> {
-    static void encode(NetworkCacheEncoder& encoder, const Vector<T, inlineCapacity>& vector)
+template<typename T, size_t inlineCapacity> struct VectorCoder<false, T, inlineCapacity> {
+    static void encode(Encoder& encoder, const Vector<T, inlineCapacity>& vector)
     {
         encoder << static_cast<uint64_t>(vector.size());
         for (size_t i = 0; i < vector.size(); ++i)
             encoder << vector[i];
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, Vector<T, inlineCapacity>& vector)
+    static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
     {
         uint64_t size;
         if (!decoder.decode(size))
@@ -132,14 +133,14 @@ template<typename T, size_t inlineCapacity> struct VectorNetworkCacheCoder<false
     }
 };
 
-template<typename T, size_t inlineCapacity> struct VectorNetworkCacheCoder<true, T, inlineCapacity> {
-    static void encode(NetworkCacheEncoder& encoder, const Vector<T, inlineCapacity>& vector)
+template<typename T, size_t inlineCapacity> struct VectorCoder<true, T, inlineCapacity> {
+    static void encode(Encoder& encoder, const Vector<T, inlineCapacity>& vector)
     {
         encoder << static_cast<uint64_t>(vector.size());
         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(vector.data()), vector.size() * sizeof(T), alignof(T));
     }
     
-    static bool decode(NetworkCacheDecoder& decoder, Vector<T, inlineCapacity>& vector)
+    static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
     {
         uint64_t size;
         if (!decoder.decode(size))
@@ -163,19 +164,19 @@ template<typename T, size_t inlineCapacity> struct VectorNetworkCacheCoder<true,
     }
 };
 
-template<typename T, size_t inlineCapacity> struct NetworkCacheCoder<Vector<T, inlineCapacity>> : VectorNetworkCacheCoder<std::is_arithmetic<T>::value, T, inlineCapacity> { };
+template<typename T, size_t inlineCapacity> struct Coder<Vector<T, inlineCapacity>> : VectorCoder<std::is_arithmetic<T>::value, T, inlineCapacity> { };
 
-template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg> struct NetworkCacheCoder<HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>> {
+template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg> struct Coder<HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>> {
     typedef HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> HashMapType;
 
-    static void encode(NetworkCacheEncoder& encoder, const HashMapType& hashMap)
+    static void encode(Encoder& encoder, const HashMapType& hashMap)
     {
         encoder << static_cast<uint64_t>(hashMap.size());
         for (typename HashMapType::const_iterator it = hashMap.begin(), end = hashMap.end(); it != end; ++it)
             encoder << *it;
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, HashMapType& hashMap)
+    static bool decode(Decoder& decoder, HashMapType& hashMap)
     {
         uint64_t hashMapSize;
         if (!decoder.decode(hashMapSize))
@@ -202,17 +203,17 @@ template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTrai
     }
 };
 
-template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct NetworkCacheCoder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
+template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct Coder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
     typedef HashSet<KeyArg, HashArg, KeyTraitsArg> HashSetType;
 
-    static void encode(NetworkCacheEncoder& encoder, const HashSetType& hashSet)
+    static void encode(Encoder& encoder, const HashSetType& hashSet)
     {
         encoder << static_cast<uint64_t>(hashSet.size());
         for (typename HashSetType::const_iterator it = hashSet.begin(), end = hashSet.end(); it != end; ++it)
             encoder << *it;
     }
 
-    static bool decode(NetworkCacheDecoder& decoder, HashSetType& hashSet)
+    static bool decode(Decoder& decoder, HashSetType& hashSet)
     {
         uint64_t hashSetSize;
         if (!decoder.decode(hashSetSize))
@@ -236,32 +237,32 @@ template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct Networ
     }
 };
 
-template<> struct NetworkCacheCoder<AtomicString> {
-    static void encode(NetworkCacheEncoder&, const AtomicString&);
-    static bool decode(NetworkCacheDecoder&, AtomicString&);
+template<> struct Coder<AtomicString> {
+    static void encode(Encoder&, const AtomicString&);
+    static bool decode(Decoder&, AtomicString&);
 };
 
-template<> struct NetworkCacheCoder<CString> {
-    static void encode(NetworkCacheEncoder&, const CString&);
-    static bool decode(NetworkCacheDecoder&, CString&);
+template<> struct Coder<CString> {
+    static void encode(Encoder&, const CString&);
+    static bool decode(Decoder&, CString&);
 };
 
-template<> struct NetworkCacheCoder<String> {
-    static void encode(NetworkCacheEncoder&, const String&);
-    static bool decode(NetworkCacheDecoder&, String&);
+template<> struct Coder<String> {
+    static void encode(Encoder&, const String&);
+    static bool decode(Decoder&, String&);
 };
 
-template<> struct NetworkCacheCoder<WebCore::CertificateInfo> {
-    static void encode(NetworkCacheEncoder&, const WebCore::CertificateInfo&);
-    static bool decode(NetworkCacheDecoder&, WebCore::CertificateInfo&);
+template<> struct Coder<WebCore::CertificateInfo> {
+    static void encode(Encoder&, const WebCore::CertificateInfo&);
+    static bool decode(Decoder&, WebCore::CertificateInfo&);
 };
 
-template<> struct NetworkCacheCoder<MD5::Digest> {
-    static void encode(NetworkCacheEncoder&, const MD5::Digest&);
-    static bool decode(NetworkCacheDecoder&, MD5::Digest&);
+template<> struct Coder<MD5::Digest> {
+    static void encode(Encoder&, const MD5::Digest&);
+    static bool decode(Decoder&, MD5::Digest&);
 };
 
 }
-
+}
 #endif
 #endif
index 1dfdfab..4908fa4 100644 (file)
@@ -34,6 +34,7 @@
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
 #if PLATFORM(COCOA)
 template <typename T> class DispatchPtr;
@@ -92,14 +93,14 @@ template <typename T> DispatchPtr<T> adoptDispatch(T dispatchObject)
 }
 #endif
 
-class NetworkCacheData {
+class Data {
 public:
-    NetworkCacheData() { }
-    NetworkCacheData(const uint8_t*, size_t);
+    Data() { }
+    Data(const uint8_t*, size_t);
 
     enum class Backing { Buffer, Map };
 #if PLATFORM(COCOA)
-    NetworkCacheData(DispatchPtr<dispatch_data_t>, Backing = Backing::Buffer);
+    Data(DispatchPtr<dispatch_data_t>, Backing = Backing::Buffer);
 #endif
     bool isNull() const;
 
@@ -120,6 +121,7 @@ private:
 };
 
 }
+}
 
 #endif
 #endif
index 5638752..92bf4ac 100644 (file)
  */
 
 #include "config.h"
-#include "NetworkCachedata.h"
+#include "NetworkCacheData.h"
 
 #if ENABLE(NETWORK_CACHE)
 
 #include <dispatch/dispatch.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-NetworkCacheData::NetworkCacheData(const uint8_t* data, size_t size)
+Data::Data(const uint8_t* data, size_t size)
     : m_dispatchData(adoptDispatch(dispatch_data_create(data, size, nullptr, DISPATCH_DATA_DESTRUCTOR_DEFAULT)))
     , m_size(size)
 {
 }
 
-NetworkCacheData::NetworkCacheData(DispatchPtr<dispatch_data_t> dispatchData, Backing backing)
+Data::Data(DispatchPtr<dispatch_data_t> dispatchData, Backing backing)
 {
     if (!dispatchData)
         return;
@@ -48,7 +49,7 @@ NetworkCacheData::NetworkCacheData(DispatchPtr<dispatch_data_t> dispatchData, Ba
     m_isMap = m_size && backing == Backing::Map;
 }
 
-const uint8_t* NetworkCacheData::data() const
+const uint8_t* Data::data() const
 {
     if (!m_data) {
         const void* data;
@@ -60,11 +61,12 @@ const uint8_t* NetworkCacheData::data() const
     return m_data;
 }
 
-bool NetworkCacheData::isNull() const
+bool Data::isNull() const
 {
     return !m_dispatchData;
 }
 
 }
+}
 
 #endif
index a297905..a9b0886 100644 (file)
@@ -31,8 +31,9 @@
 #include "NetworkCacheEncoder.h"
 
 namespace WebKit {
+namespace NetworkCache {
 
-NetworkCacheDecoder::NetworkCacheDecoder(const uint8_t* buffer, size_t bufferSize)
+Decoder::Decoder(const uint8_t* buffer, size_t bufferSize)
     : m_buffer(buffer)
     , m_bufferPosition(buffer)
     , m_bufferEnd(buffer + bufferSize)
@@ -40,16 +41,16 @@ NetworkCacheDecoder::NetworkCacheDecoder(const uint8_t* buffer, size_t bufferSiz
 {
 }
 
-NetworkCacheDecoder::~NetworkCacheDecoder()
+Decoder::~Decoder()
 {
 }
 
-bool NetworkCacheDecoder::bufferIsLargeEnoughToContain(size_t size) const
+bool Decoder::bufferIsLargeEnoughToContain(size_t size) const
 {
     return m_bufferPosition + size <= m_bufferEnd;
 }
 
-bool NetworkCacheDecoder::decodeFixedLengthData(uint8_t* data, size_t size)
+bool Decoder::decodeFixedLengthData(uint8_t* data, size_t size)
 {
     if (!bufferIsLargeEnoughToContain(size))
         return false;
@@ -57,12 +58,12 @@ bool NetworkCacheDecoder::decodeFixedLengthData(uint8_t* data, size_t size)
     memcpy(data, m_bufferPosition, size);
     m_bufferPosition += size;
 
-    NetworkCacheEncoder::updateChecksumForData(m_checksum, data, size);
+    Encoder::updateChecksumForData(m_checksum, data, size);
     return true;
 }
 
 template<typename Type>
-bool NetworkCacheDecoder::decodeNumber(Type& value)
+bool Decoder::decodeNumber(Type& value)
 {
     if (!bufferIsLargeEnoughToContain(sizeof(value)))
         return false;
@@ -70,56 +71,56 @@ bool NetworkCacheDecoder::decodeNumber(Type& value)
     memcpy(&value, m_bufferPosition, sizeof(value));
     m_bufferPosition += sizeof(Type);
 
-    NetworkCacheEncoder::updateChecksumForNumber(m_checksum, value);
+    Encoder::updateChecksumForNumber(m_checksum, value);
     return true;
 }
 
-bool NetworkCacheDecoder::decode(bool& result)
+bool Decoder::decode(bool& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(uint8_t& result)
+bool Decoder::decode(uint8_t& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(uint16_t& result)
+bool Decoder::decode(uint16_t& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(uint32_t& result)
+bool Decoder::decode(uint32_t& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(uint64_t& result)
+bool Decoder::decode(uint64_t& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(int32_t& result)
+bool Decoder::decode(int32_t& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(int64_t& result)
+bool Decoder::decode(int64_t& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(float& result)
+bool Decoder::decode(float& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::decode(double& result)
+bool Decoder::decode(double& result)
 {
     return decodeNumber(result);
 }
 
-bool NetworkCacheDecoder::verifyChecksum()
+bool Decoder::verifyChecksum()
 {
     unsigned computedChecksum = m_checksum;
     unsigned decodedChecksum;
@@ -129,5 +130,6 @@ bool NetworkCacheDecoder::verifyChecksum()
 }
 
 }
+}
 
 #endif
index 0d2e970..1d76773 100644 (file)
 #include "NetworkCacheCoder.h"
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheDecoder {
+class Decoder {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    NetworkCacheDecoder(const uint8_t* buffer, size_t bufferSize);
-    virtual ~NetworkCacheDecoder();
+    Decoder(const uint8_t* buffer, size_t bufferSize);
+    virtual ~Decoder();
 
     size_t length() const { return m_bufferEnd - m_buffer; }
     size_t currentOffset() const { return m_bufferPosition - m_buffer; }
@@ -72,7 +73,7 @@ public:
 
     template<typename T> bool decode(T& t)
     {
-        return NetworkCacheCoder<T>::decode(*this, t);
+        return Coder<T>::decode(*this, t);
     }
 
     template<typename T>
@@ -98,6 +99,7 @@ private:
 };
 
 } 
+}
 
 #endif
 #endif
index 8c7eeca..c74e600 100644 (file)
 #if ENABLE(NETWORK_CACHE)
 
 namespace WebKit {
+namespace NetworkCache {
 
-NetworkCacheEncoder::NetworkCacheEncoder()
+Encoder::Encoder()
     : m_checksum(0)
 {
 }
 
-NetworkCacheEncoder::~NetworkCacheEncoder()
+Encoder::~Encoder()
 {
 }
 
-uint8_t* NetworkCacheEncoder::grow(size_t size)
+uint8_t* Encoder::grow(size_t size)
 {
     size_t newPosition = m_buffer.size();
     m_buffer.grow(m_buffer.size() + size);
     return m_buffer.data() + newPosition;
 }
 
-void NetworkCacheEncoder::updateChecksumForData(unsigned& checksum, const uint8_t* data, size_t size)
+void Encoder::updateChecksumForData(unsigned& checksum, const uint8_t* data, size_t size)
 {
     // FIXME: hashMemory should not require alignment.
     size_t hashSize = size - size % 2;
-    unsigned hash = StringHasher::hashMemory(data, hashSize) ^ NetworkCacheEncoder::Salt<uint8_t*>::value;
+    unsigned hash = StringHasher::hashMemory(data, hashSize) ^ Encoder::Salt<uint8_t*>::value;
     checksum = WTF::pairIntHash(checksum, hash);
 }
 
-void NetworkCacheEncoder::encodeFixedLengthData(const uint8_t* data, size_t size)
+void Encoder::encodeFixedLengthData(const uint8_t* data, size_t size)
 {
     updateChecksumForData(m_checksum, data, size);
 
@@ -63,64 +64,65 @@ void NetworkCacheEncoder::encodeFixedLengthData(const uint8_t* data, size_t size
 }
 
 template<typename Type>
-void NetworkCacheEncoder::encodeNumber(Type value)
+void Encoder::encodeNumber(Type value)
 {
-    NetworkCacheEncoder::updateChecksumForNumber(m_checksum, value);
+    Encoder::updateChecksumForNumber(m_checksum, value);
 
     uint8_t* buffer = grow(sizeof(Type));
     memcpy(buffer, &value, sizeof(Type));
 }
 
-void NetworkCacheEncoder::encode(bool value)
+void Encoder::encode(bool value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(uint8_t value)
+void Encoder::encode(uint8_t value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(uint16_t value)
+void Encoder::encode(uint16_t value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(uint32_t value)
+void Encoder::encode(uint32_t value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(uint64_t value)
+void Encoder::encode(uint64_t value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(int32_t value)
+void Encoder::encode(int32_t value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(int64_t value)
+void Encoder::encode(int64_t value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(float value)
+void Encoder::encode(float value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encode(double value)
+void Encoder::encode(double value)
 {
     encodeNumber(value);
 }
 
-void NetworkCacheEncoder::encodeChecksum()
+void Encoder::encodeChecksum()
 {
     encodeNumber(m_checksum);
 }
 
 }
+}
 
 #endif
index d6a4ae0..6f4ff13 100644 (file)
 #include <wtf/Vector.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheEncoder;
+class Encoder;
 class DataReference;
 
-class NetworkCacheEncoder {
+class Encoder {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    NetworkCacheEncoder();
-    virtual ~NetworkCacheEncoder();
+    Encoder();
+    virtual ~Encoder();
 
     void encodeChecksum();
     void encodeFixedLengthData(const uint8_t*, size_t);
@@ -56,10 +57,10 @@ public:
 
     template<typename T> void encode(const T& t)
     {
-        NetworkCacheCoder<T>::encode(*this, t);
+        Coder<T>::encode(*this, t);
     }
 
-    template<typename T> NetworkCacheEncoder& operator<<(const T& t)
+    template<typename T> Encoder& operator<<(const T& t)
     {
         encode(t);
         return *this;
@@ -92,25 +93,26 @@ private:
     unsigned m_checksum;
 };
 
-template <> struct NetworkCacheEncoder::Salt<bool> { static const unsigned value = 3; };
-template <> struct NetworkCacheEncoder::Salt<uint8_t> { static const  unsigned value = 5; };
-template <> struct NetworkCacheEncoder::Salt<uint16_t> { static const unsigned value = 7; };
-template <> struct NetworkCacheEncoder::Salt<uint32_t> { static const unsigned value = 11; };
-template <> struct NetworkCacheEncoder::Salt<uint64_t> { static const unsigned value = 13; };
-template <> struct NetworkCacheEncoder::Salt<int32_t> { static const unsigned value = 17; };
-template <> struct NetworkCacheEncoder::Salt<int64_t> { static const unsigned value = 19; };
-template <> struct NetworkCacheEncoder::Salt<float> { static const unsigned value = 23; };
-template <> struct NetworkCacheEncoder::Salt<double> { static const unsigned value = 29; };
-template <> struct NetworkCacheEncoder::Salt<uint8_t*> { static const unsigned value = 101; };
+template <> struct Encoder::Salt<bool> { static const unsigned value = 3; };
+template <> struct Encoder::Salt<uint8_t> { static const  unsigned value = 5; };
+template <> struct Encoder::Salt<uint16_t> { static const unsigned value = 7; };
+template <> struct Encoder::Salt<uint32_t> { static const unsigned value = 11; };
+template <> struct Encoder::Salt<uint64_t> { static const unsigned value = 13; };
+template <> struct Encoder::Salt<int32_t> { static const unsigned value = 17; };
+template <> struct Encoder::Salt<int64_t> { static const unsigned value = 19; };
+template <> struct Encoder::Salt<float> { static const unsigned value = 23; };
+template <> struct Encoder::Salt<double> { static const unsigned value = 29; };
+template <> struct Encoder::Salt<uint8_t*> { static const unsigned value = 101; };
 
 template <typename Type>
-void NetworkCacheEncoder::updateChecksumForNumber(unsigned& checksum, Type value)
+void Encoder::updateChecksumForNumber(unsigned& checksum, Type value)
 {
-    unsigned hash = WTF::intHash(static_cast<uint64_t>(value)) ^ NetworkCacheEncoder::Salt<Type>::value;
+    unsigned hash = WTF::intHash(static_cast<uint64_t>(value)) ^ Encoder::Salt<Type>::value;
     checksum = WTF::pairIntHash(checksum, hash);
 }
 
 }
+}
 
 #endif
 #endif
index e2a7603..5748aba 100644 (file)
@@ -34,6 +34,7 @@
 #include <wtf/text/CString.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
 template <typename Function>
 static void traverseDirectory(const String& path, uint8_t type, const Function& function)
@@ -59,14 +60,15 @@ inline void traverseCacheFiles(const String& cachePath, const Function& function
     traverseDirectory(cachePath, DT_DIR, [&cachePath, &function](const String& subdirName) {
         String partitionPath = WebCore::pathByAppendingComponent(cachePath, subdirName);
         traverseDirectory(partitionPath, DT_REG, [&function, &partitionPath](const String& fileName) {
-            if (fileName.length() != NetworkCacheKey::hashStringLength())
+            if (fileName.length() != Key::hashStringLength())
                 return;
             function(fileName, partitionPath);
         });
     });
 }
 
-} // namespace WebKit
+}
+}
 
 #endif // ENABLE(NETWORK_CACHE)
 
index fed4b4e..1ceda3e 100644 (file)
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheIOChannel : public ThreadSafeRefCounted<NetworkCacheIOChannel> {
+class IOChannel : public ThreadSafeRefCounted<IOChannel> {
 public:
     enum class Type { Read, Write, Create };
-    static Ref<NetworkCacheIOChannel> open(const String& file, Type);
+    static Ref<IOChannel> open(const String& file, Type);
 
-    void read(size_t offset, size_t, std::function<void (NetworkCacheData&, int error)>);
-    void write(size_t offset, const NetworkCacheData&, std::function<void (int error)>);
+    void read(size_t offset, size_t, std::function<void (Data&, int error)>);
+    void write(size_t offset, const Data&, std::function<void (int error)>);
 
     int fileDescriptor() const { return m_fileDescriptor; }
 
 private:
-    NetworkCacheIOChannel(int fd);
+    IOChannel(int fd);
 
 #if PLATFORM(COCOA)
     DispatchPtr<dispatch_io_t> m_dispatchIO;
@@ -55,6 +56,7 @@ private:
 };
 
 }
+}
 
 #endif
 #endif
index 742be26..e023fa8 100644 (file)
@@ -37,8 +37,9 @@
 #include <wtf/text/StringBuilder.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-NetworkCacheIOChannel::NetworkCacheIOChannel(int fd)
+IOChannel::IOChannel(int fd)
     : m_fileDescriptor(fd)
 {
     m_dispatchIO = adoptDispatch(dispatch_io_create(DISPATCH_IO_RANDOM, fd, dispatch_get_main_queue(), [fd](int) {
@@ -49,7 +50,7 @@ NetworkCacheIOChannel::NetworkCacheIOChannel(int fd)
     dispatch_io_set_low_water(m_dispatchIO.get(), std::numeric_limits<size_t>::max());
 }
 
-Ref<NetworkCacheIOChannel> NetworkCacheIOChannel::open(const String& filePath, NetworkCacheIOChannel::Type type)
+Ref<IOChannel> IOChannel::open(const String& filePath, IOChannel::Type type)
 {
     int oflag;
     mode_t mode;
@@ -71,31 +72,31 @@ Ref<NetworkCacheIOChannel> NetworkCacheIOChannel::open(const String& filePath, N
     CString path = WebCore::fileSystemRepresentation(filePath);
     int fd = ::open(path.data(), oflag, mode);
 
-    return adoptRef(*new NetworkCacheIOChannel(fd));
+    return adoptRef(*new IOChannel(fd));
 }
 
-void NetworkCacheIOChannel::read(size_t offset, size_t size, std::function<void ( NetworkCacheData&, int error)> completionHandler)
+void IOChannel::read(size_t offset, size_t size, std::function<void ( Data&, int error)> completionHandler)
 {
-    RefPtr<NetworkCacheIOChannel> channel(this);
+    RefPtr<IOChannel> channel(this);
     bool didCallCompletionHandler = false;
     dispatch_io_read(m_dispatchIO.get(), offset, size, dispatch_get_main_queue(), [channel, completionHandler, didCallCompletionHandler](bool done, dispatch_data_t fileData, int error) mutable {
         if (done) {
             if (!didCallCompletionHandler) {
-                NetworkCacheData nullData;
+                Data nullData;
                 completionHandler(nullData, error);
             }
             return;
         }
         ASSERT(!didCallCompletionHandler);
-        NetworkCacheData data(fileData);
+        Data data(fileData);
         completionHandler(data, error);
         didCallCompletionHandler = true;
     });
 }
 
-void NetworkCacheIOChannel::write(size_t offset, const NetworkCacheData& data, std::function<void (int error)> completionHandler)
+void IOChannel::write(size_t offset, const Data& data, std::function<void (int error)> completionHandler)
 {
-    RefPtr<NetworkCacheIOChannel> channel(this);
+    RefPtr<IOChannel> channel(this);
     auto dispatchData = data.dispatchData();
     dispatch_io_write(m_dispatchIO.get(), offset, dispatchData, dispatch_get_main_queue(), [channel, completionHandler](bool done, dispatch_data_t fileData, int error) {
         ASSERT_UNUSED(done, done);
@@ -104,4 +105,6 @@ void NetworkCacheIOChannel::write(size_t offset, const NetworkCacheData& data, s
 }
 
 }
+}
+
 #endif
index c721bec..c2a3006 100644 (file)
@@ -34,8 +34,9 @@
 #include <wtf/text/StringBuilder.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-NetworkCacheKey::NetworkCacheKey(const NetworkCacheKey& o)
+Key::Key(const Key& o)
     : m_method(o.m_method.isolatedCopy())
     , m_partition(o.m_partition.isolatedCopy())
     , m_identifier(o.m_identifier.isolatedCopy())
@@ -43,7 +44,7 @@ NetworkCacheKey::NetworkCacheKey(const NetworkCacheKey& o)
 {
 }
 
-NetworkCacheKey::NetworkCacheKey(NetworkCacheKey&& o)
+Key::Key(Key&& o)
     : m_method(WTF::move(o.m_method))
     , m_partition(WTF::move(o.m_partition))
     , m_identifier(WTF::move(o.m_identifier))
@@ -51,7 +52,7 @@ NetworkCacheKey::NetworkCacheKey(NetworkCacheKey&& o)
 {
 }
 
-NetworkCacheKey::NetworkCacheKey(const String& method, const String& partition, const String& identifier)
+Key::Key(const String& method, const String& partition, const String& identifier)
     : m_method(method.isolatedCopy())
     , m_partition(partition.isolatedCopy())
     , m_identifier(identifier.isolatedCopy())
@@ -59,7 +60,7 @@ NetworkCacheKey::NetworkCacheKey(const String& method, const String& partition,
 {
 }
 
-NetworkCacheKey& NetworkCacheKey::operator=(const NetworkCacheKey& other)
+Key& Key::operator=(const Key& other)
 {
     m_method = other.m_method.isolatedCopy();
     m_partition = other.m_partition.isolatedCopy();
@@ -81,7 +82,7 @@ static void hashString(MD5& md5, const String& string)
     md5.addBytes(&zero, 1);
 }
 
-NetworkCacheKey::HashType NetworkCacheKey::computeHash() const
+Key::HashType Key::computeHash() const
 {
     // We don't really need a cryptographic hash. The key is always verified against the entry header.
     // MD5 just happens to be suitably sized, fast and available.
@@ -94,7 +95,7 @@ NetworkCacheKey::HashType NetworkCacheKey::computeHash() const
     return hash;
 }
 
-String NetworkCacheKey::hashAsString() const
+String Key::hashAsString() const
 {
     StringBuilder builder;
     builder.reserveCapacity(hashStringLength());
@@ -105,7 +106,7 @@ String NetworkCacheKey::hashAsString() const
     return builder.toString();
 }
 
-template <typename CharType> bool hexDigitsToHash(CharType* characters, NetworkCacheKey::HashType& hash)
+template <typename CharType> bool hexDigitsToHash(CharType* characters, Key::HashType& hash)
 {
     for (unsigned i = 0; i < sizeof(hash); ++i) {
         auto high = characters[2 * i];
@@ -117,7 +118,7 @@ template <typename CharType> bool hexDigitsToHash(CharType* characters, NetworkC
     return true;
 }
 
-bool NetworkCacheKey::stringToHash(const String& string, HashType& hash)
+bool Key::stringToHash(const String& string, HashType& hash)
 {
     if (string.length() != hashStringLength())
         return false;
@@ -126,12 +127,12 @@ bool NetworkCacheKey::stringToHash(const String& string, HashType& hash)
     return hexDigitsToHash(string.characters16(), hash);
 }
 
-bool NetworkCacheKey::operator==(const NetworkCacheKey& other) const
+bool Key::operator==(const Key& other) const
 {
     return m_hash == other.m_hash && m_method == other.m_method && m_partition == other.m_partition && m_identifier == other.m_identifier;
 }
 
-void NetworkCacheKey::encode(NetworkCacheEncoder& encoder) const
+void Key::encode(Encoder& encoder) const
 {
     encoder << m_method;
     encoder << m_partition;
@@ -139,11 +140,12 @@ void NetworkCacheKey::encode(NetworkCacheEncoder& encoder) const
     encoder << m_hash;
 }
 
-bool NetworkCacheKey::decode(NetworkCacheDecoder& decoder, NetworkCacheKey& key)
+bool Key::decode(Decoder& decoder, Key& key)
 {
     return decoder.decode(key.m_method) && decoder.decode(key.m_partition) && decoder.decode(key.m_identifier) && decoder.decode(key.m_hash);
 }
 
 }
+}
 
 #endif
index fc0ce42..cf04a87 100644 (file)
 #include <wtf/text/WTFString.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheEncoder;
-class NetworkCacheDecoder;
+class Encoder;
+class Decoder;
 
-class NetworkCacheKey {
+class Key {
 public:
     typedef MD5::Digest HashType;
 
-    NetworkCacheKey() { }
-    NetworkCacheKey(const NetworkCacheKey&);
-    NetworkCacheKey(NetworkCacheKey&&);
-    NetworkCacheKey(const String& method, const String& partition, const String& identifier);
+    Key() { }
+    Key(const Key&);
+    Key(Key&&);
+    Key(const String& method, const String& partition, const String& identifier);
 
-    NetworkCacheKey& operator=(const NetworkCacheKey&);
+    Key& operator=(const Key&);
 
     bool isNull() const { return m_identifier.isNull(); }
 
@@ -62,11 +63,11 @@ public:
     static size_t hashStringLength() { return 2 * sizeof(m_hash); }
     String hashAsString() const;
 
-    void encode(NetworkCacheEncoder&) const;
-    static bool decode(NetworkCacheDecoder&, NetworkCacheKey&);
+    void encode(Encoder&) const;
+    static bool decode(Decoder&, Key&);
 
-    bool operator==(const NetworkCacheKey&) const;
-    bool operator!=(const NetworkCacheKey& other) const { return !(*this == other); }
+    bool operator==(const Key&) const;
+    bool operator!=(const Key& other) const { return !(*this == other); }
 
 private:
     HashType computeHash() const;
@@ -78,6 +79,7 @@ private:
 };
 
 }
+}
 
 #endif
 #endif
index 8cc1f0b..d024a24 100644 (file)
@@ -39,20 +39,21 @@ class ResourceRequest;
 }
 
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheStatistics {
+class Statistics {
 public:
-    static std::unique_ptr<NetworkCacheStatistics> open(const String& cachePath);
+    static std::unique_ptr<Statistics> open(const String& cachePath);
 
     void clear();
 
-    void recordNotCachingResponse(const NetworkCacheKey&, NetworkCache::StoreDecision);
-    void recordNotUsingCacheForRequest(uint64_t webPageID, const NetworkCacheKey&, const WebCore::ResourceRequest&, NetworkCache::RetrieveDecision);
-    void recordRetrievalFailure(uint64_t webPageID, const NetworkCacheKey&, const WebCore::ResourceRequest&);
-    void recordRetrievedCachedEntry(uint64_t webPageID, const NetworkCacheKey&, const WebCore::ResourceRequest&, NetworkCache::CachedEntryReuseFailure);
+    void recordNotCachingResponse(const Key&, StoreDecision);
+    void recordNotUsingCacheForRequest(uint64_t webPageID, const Key&, const WebCore::ResourceRequest&, RetrieveDecision);
+    void recordRetrievalFailure(uint64_t webPageID, const Key&, const WebCore::ResourceRequest&);
+    void recordRetrievedCachedEntry(uint64_t webPageID, const Key&, const WebCore::ResourceRequest&, CachedEntryReuseFailure);
 
 private:
-    explicit NetworkCacheStatistics(const String& databasePath);
+    explicit Statistics(const String& databasePath);
 
     void initialize(const String& databasePath);
     void bootstrapFromNetworkCache(const String& networkCachePath);
@@ -62,7 +63,7 @@ private:
     void addStoreDecisionsToDatabase(const Vector<std::pair<StringCapture, NetworkCache::StoreDecision>>&);
     void writeTimerFired();
 
-    typedef std::function<void (bool wasEverRequested, const Optional<NetworkCache::StoreDecision>&)> RequestedCompletionHandler;
+    typedef std::function<void (bool wasEverRequested, const Optional<StoreDecision>&)> RequestedCompletionHandler;
     enum class NeedUncachedReason { No, Yes };
     void queryWasEverRequested(const String&, NeedUncachedReason, const RequestedCompletionHandler&);
     void markAsRequested(const String& hash);
@@ -85,7 +86,8 @@ private:
     WebCore::Timer m_writeTimer;
 };
 
-} // namespace WebKit
+}
+}
 
 #endif // ENABLE(NETWORK_CACHE)
 
index f806904..b3842e7 100644 (file)
@@ -41,8 +41,9 @@
 #include <wtf/RunLoop.h>
 
 namespace WebKit {
+namespace NetworkCache {
 
-static const char* networkCacheStatisticsDatabaseName = "WebKitCacheStatistics.db";
+static const char* StatisticsDatabaseName = "WebKitCacheStatistics.db";
 static const std::chrono::milliseconds mininumWriteInterval = std::chrono::milliseconds(10000);
 
 static bool executeSQLCommand(WebCore::SQLiteDatabase& database, const String& sql)
@@ -72,31 +73,31 @@ static bool executeSQLStatement(WebCore::SQLiteStatement& statement)
     return true;
 }
 
-std::unique_ptr<NetworkCacheStatistics> NetworkCacheStatistics::open(const String& cachePath)
+std::unique_ptr<Statistics> Statistics::open(const String& cachePath)
 {
     ASSERT(RunLoop::isMain());
 
-    String databasePath = WebCore::pathByAppendingComponent(cachePath, networkCacheStatisticsDatabaseName);
-    return std::unique_ptr<NetworkCacheStatistics>(new NetworkCacheStatistics(databasePath));
+    String databasePath = WebCore::pathByAppendingComponent(cachePath, StatisticsDatabaseName);
+    return std::unique_ptr<Statistics>(new Statistics(databasePath));
 }
 
-NetworkCacheStatistics::NetworkCacheStatistics(const String& databasePath)
+Statistics::Statistics(const String& databasePath)
     : m_backgroundIOQueue(adoptDispatch(dispatch_queue_create("com.apple.WebKit.Cache.Statistics.Background", DISPATCH_QUEUE_SERIAL)))
-    , m_writeTimer(*this, &NetworkCacheStatistics::writeTimerFired)
+    , m_writeTimer(*this, &Statistics::writeTimerFired)
 {
     dispatch_set_target_queue(m_backgroundIOQueue.get(), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));
 
     initialize(databasePath);
 }
 
-void NetworkCacheStatistics::initialize(const String& databasePath)
+void Statistics::initialize(const String& databasePath)
 {
     ASSERT(RunLoop::isMain());
 
     auto startTime = std::chrono::system_clock::now();
 
     StringCapture databasePathCapture(databasePath);
-    StringCapture networkCachePathCapture(NetworkCache::singleton().storagePath());
+    StringCapture networkCachePathCapture(singleton().storagePath());
     dispatch_async(m_backgroundIOQueue.get(), [this, databasePathCapture, networkCachePathCapture, startTime] {
         WebCore::SQLiteTransactionInProgressAutoCounter transactionCounter;
 
@@ -138,7 +139,7 @@ void NetworkCacheStatistics::initialize(const String& databasePath)
     });
 }
 
-void NetworkCacheStatistics::bootstrapFromNetworkCache(const String& networkCachePath)
+void Statistics::bootstrapFromNetworkCache(const String& networkCachePath)
 {
     ASSERT(!RunLoop::isMain());
 
@@ -158,7 +159,7 @@ void NetworkCacheStatistics::bootstrapFromNetworkCache(const String& networkCach
     writeTransaction.commit();
 }
 
-void NetworkCacheStatistics::shrinkIfNeeded()
+void Statistics::shrinkIfNeeded()
 {
     ASSERT(RunLoop::isMain());
     const size_t maxEntries = 100000;
@@ -170,47 +171,47 @@ void NetworkCacheStatistics::shrinkIfNeeded()
 
     clear();
 
-    StringCapture networkCachePathCapture(NetworkCache::singleton().storagePath());
+    StringCapture networkCachePathCapture(singleton().storagePath());
     dispatch_async(m_backgroundIOQueue.get(), [this, networkCachePathCapture] {
         bootstrapFromNetworkCache(networkCachePathCapture.string());
         LOG(NetworkCache, "(NetworkProcess) statistics cache shrink completed m_approximateEntryCount=%lu", static_cast<size_t>(m_approximateEntryCount));
     });
 }
 
-void NetworkCacheStatistics::recordNotCachingResponse(const NetworkCacheKey& key, NetworkCache::StoreDecision storeDecision)
+void Statistics::recordNotCachingResponse(const Key& key, StoreDecision storeDecision)
 {
-    ASSERT(storeDecision != NetworkCache::StoreDecision::Yes);
+    ASSERT(storeDecision != StoreDecision::Yes);
 
     m_storeDecisionsToAdd.set(key.hashAsString(), storeDecision);
     if (!m_writeTimer.isActive())
         m_writeTimer.startOneShot(mininumWriteInterval);
 }
 
-static String retrieveDecisionToDiagnosticKey(NetworkCache::RetrieveDecision retrieveDecision)
+static String retrieveDecisionToDiagnosticKey(RetrieveDecision retrieveDecision)
 {
     switch (retrieveDecision) {
-    case NetworkCache::RetrieveDecision::NoDueToProtocol:
+    case RetrieveDecision::NoDueToProtocol:
         return WebCore::DiagnosticLoggingKeys::notHTTPFamilyKey();
-    case NetworkCache::RetrieveDecision::NoDueToHTTPMethod:
+    case RetrieveDecision::NoDueToHTTPMethod:
         return WebCore::DiagnosticLoggingKeys::unsupportedHTTPMethodKey();
-    case NetworkCache::RetrieveDecision::NoDueToConditionalRequest:
+    case RetrieveDecision::NoDueToConditionalRequest:
         return WebCore::DiagnosticLoggingKeys::isConditionalRequestKey();
-    case NetworkCache::RetrieveDecision::NoDueToReloadIgnoringCache:
+    case RetrieveDecision::NoDueToReloadIgnoringCache:
         return WebCore::DiagnosticLoggingKeys::isReloadIgnoringCacheDataKey();
-    case NetworkCache::RetrieveDecision::Yes:
+    case RetrieveDecision::Yes:
         ASSERT_NOT_REACHED();
         break;
     }
     return emptyString();
 }
 
-void NetworkCacheStatistics::recordNotUsingCacheForRequest(uint64_t webPageID, const NetworkCacheKey& key, const WebCore::ResourceRequest& request, NetworkCache::RetrieveDecision retrieveDecision)
+void Statistics::recordNotUsingCacheForRequest(uint64_t webPageID, const Key& key, const WebCore::ResourceRequest& request, RetrieveDecision retrieveDecision)
 {
-    ASSERT(retrieveDecision != NetworkCache::RetrieveDecision::Yes);
+    ASSERT(retrieveDecision != RetrieveDecision::Yes);
 
     String hash = key.hashAsString();
     WebCore::URL requestURL = request.url();
-    queryWasEverRequested(hash, NeedUncachedReason::No, [this, hash, requestURL, webPageID, retrieveDecision](bool wasEverRequested, const Optional<NetworkCache::StoreDecision>&) {
+    queryWasEverRequested(hash, NeedUncachedReason::No, [this, hash, requestURL, webPageID, retrieveDecision](bool wasEverRequested, const Optional<StoreDecision>&) {
         if (wasEverRequested) {
             String diagnosticKey = retrieveDecisionToDiagnosticKey(retrieveDecision);
             LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s was previously requested but we are not using the cache, reason: %s", webPageID, requestURL.string().ascii().data(), diagnosticKey.utf8().data());
@@ -220,31 +221,31 @@ void NetworkCacheStatistics::recordNotUsingCacheForRequest(uint64_t webPageID, c
     });
 }
 
-static String storeDecisionToDiagnosticKey(NetworkCache::StoreDecision storeDecision)
+static String storeDecisionToDiagnosticKey(StoreDecision storeDecision)
 {
     switch (storeDecision) {
-    case NetworkCache::StoreDecision::NoDueToProtocol:
+    case StoreDecision::NoDueToProtocol:
         return WebCore::DiagnosticLoggingKeys::notHTTPFamilyKey();
-    case NetworkCache::StoreDecision::NoDueToHTTPMethod:
+    case StoreDecision::NoDueToHTTPMethod:
         return WebCore::DiagnosticLoggingKeys::unsupportedHTTPMethodKey();
-    case NetworkCache::StoreDecision::NoDueToAttachmentResponse:
+    case StoreDecision::NoDueToAttachmentResponse:
         return WebCore::DiagnosticLoggingKeys::isAttachmentKey();
-    case NetworkCache::StoreDecision::NoDueToNoStoreResponse:
+    case StoreDecision::NoDueToNoStoreResponse:
         return WebCore::DiagnosticLoggingKeys::cacheControlNoStoreKey();
-    case NetworkCache::StoreDecision::NoDueToHTTPStatusCode:
+    case StoreDecision::NoDueToHTTPStatusCode:
         return WebCore::DiagnosticLoggingKeys::uncacheableStatusCodeKey();
-    case NetworkCache::StoreDecision::Yes:
+    case StoreDecision::Yes:
         // It was stored but could not be retrieved so it must have been pruned from the cache.
         return WebCore::DiagnosticLoggingKeys::noLongerInCacheKey();
     }
     return String();
 }
 
-void NetworkCacheStatistics::recordRetrievalFailure(uint64_t webPageID, const NetworkCacheKey& key, const WebCore::ResourceRequest& request)
+void Statistics::recordRetrievalFailure(uint64_t webPageID, const Key& key, const WebCore::ResourceRequest& request)
 {
     String hash = key.hashAsString();
     WebCore::URL requestURL = request.url();
-    queryWasEverRequested(hash, NeedUncachedReason::Yes, [this, hash, requestURL, webPageID](bool wasPreviouslyRequested, const Optional<NetworkCache::StoreDecision>& storeDecision) {
+    queryWasEverRequested(hash, NeedUncachedReason::Yes, [this, hash, requestURL, webPageID](bool wasPreviouslyRequested, const Optional<StoreDecision>& storeDecision) {
         if (wasPreviouslyRequested) {
             String diagnosticKey = storeDecisionToDiagnosticKey(storeDecision.value());
             LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s was previously request but is not in the cache, reason: %s", webPageID, requestURL.string().ascii().data(), diagnosticKey.utf8().data());
@@ -254,26 +255,26 @@ void NetworkCacheStatistics::recordRetrievalFailure(uint64_t webPageID, const Ne
     });
 }
 
-static String cachedEntryReuseFailureToDiagnosticKey(NetworkCache::CachedEntryReuseFailure failure)
+static String cachedEntryReuseFailureToDiagnosticKey(CachedEntryReuseFailure failure)
 {
     switch (failure) {
-    case NetworkCache::CachedEntryReuseFailure::VaryingHeaderMismatch:
+    case CachedEntryReuseFailure::VaryingHeaderMismatch:
         return WebCore::DiagnosticLoggingKeys::varyingHeaderMismatchKey();
-    case NetworkCache::CachedEntryReuseFailure::MissingValidatorFields:
+    case CachedEntryReuseFailure::MissingValidatorFields:
         return WebCore::DiagnosticLoggingKeys::missingValidatorFieldsKey();
-    case NetworkCache::CachedEntryReuseFailure::Other:
+    case CachedEntryReuseFailure::Other:
         return WebCore::DiagnosticLoggingKeys::otherKey();
-    case NetworkCache::CachedEntryReuseFailure::None:
+    case CachedEntryReuseFailure::None:
         ASSERT_NOT_REACHED();
         break;
     }
     return emptyString();
 }
 
-void NetworkCacheStatistics::recordRetrievedCachedEntry(uint64_t webPageID, const NetworkCacheKey& key, const WebCore::ResourceRequest& request, NetworkCache::CachedEntryReuseFailure failure)
+void Statistics::recordRetrievedCachedEntry(uint64_t webPageID, const Key& key, const WebCore::ResourceRequest& request, CachedEntryReuseFailure failure)
 {
     WebCore::URL requestURL = request.url();
-    if (failure == NetworkCache::CachedEntryReuseFailure::None) {
+    if (failure == CachedEntryReuseFailure::None) {
         LOG(NetworkCache, "(NetworkProcess) webPageID %llu: %s is in the cache and is used", webPageID, requestURL.string().ascii().data());
         NetworkProcess::singleton().logDiagnosticMessageWithResult(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::retrievalKey(), WebCore::DiagnosticLoggingResultPass, WebCore::ShouldSample::Yes);
         return;
@@ -284,7 +285,7 @@ void NetworkCacheStatistics::recordRetrievedCachedEntry(uint64_t webPageID, cons
     NetworkProcess::singleton().logDiagnosticMessageWithValue(webPageID, WebCore::DiagnosticLoggingKeys::networkCacheKey(), WebCore::DiagnosticLoggingKeys::unusableCachedEntryKey(), diagnosticKey, WebCore::ShouldSample::Yes);
 }
 
-void NetworkCacheStatistics::markAsRequested(const String& hash)
+void Statistics::markAsRequested(const String& hash)
 {
     ASSERT(RunLoop::isMain());
 
@@ -293,7 +294,7 @@ void NetworkCacheStatistics::markAsRequested(const String& hash)
         m_writeTimer.startOneShot(mininumWriteInterval);
 }
 
-void NetworkCacheStatistics::writeTimerFired()
+void Statistics::writeTimerFired()
 {
     ASSERT(RunLoop::isMain());
 
@@ -301,7 +302,7 @@ void NetworkCacheStatistics::writeTimerFired()
     copyToVector(m_hashesToAdd, hashesToAdd);
     m_hashesToAdd.clear();
 
-    Vector<std::pair<StringCapture, NetworkCache::StoreDecision>> storeDecisionsToAdd;
+    Vector<std::pair<StringCapture, StoreDecision>> storeDecisionsToAdd;
     copyToVector(m_storeDecisionsToAdd, storeDecisionsToAdd);
     m_storeDecisionsToAdd.clear();
 
@@ -322,7 +323,7 @@ void NetworkCacheStatistics::writeTimerFired()
     });
 }
 
-void NetworkCacheStatistics::queryWasEverRequested(const String& hash, NeedUncachedReason needUncachedReason, const RequestedCompletionHandler& completionHandler)
+void Statistics::queryWasEverRequested(const String& hash, NeedUncachedReason needUncachedReason, const RequestedCompletionHandler& completionHandler)
 {
     ASSERT(RunLoop::isMain());
 
@@ -343,7 +344,7 @@ void NetworkCacheStatistics::queryWasEverRequested(const String& hash, NeedUncac
     m_activeQueries.add(WTF::move(everRequestedQuery));
     dispatch_async(m_backgroundIOQueue.get(), [this, wasAlreadyRequested, &query] () mutable {
         WebCore::SQLiteTransactionInProgressAutoCounter transactionCounter;
-        Optional<NetworkCache::StoreDecision> storeDecision;
+        Optional<StoreDecision> storeDecision;
         if (m_database.isOpen()) {
             if (!wasAlreadyRequested) {
                 WebCore::SQLiteStatement statement(m_database, ASCIILiteral("SELECT hash FROM AlreadyRequested WHERE hash=?"));
@@ -354,11 +355,11 @@ void NetworkCacheStatistics::queryWasEverRequested(const String& hash, NeedUncac
             }
             if (wasAlreadyRequested && query.needUncachedReason) {
                 WebCore::SQLiteStatement statement(m_database, ASCIILiteral("SELECT reason FROM UncachedReason WHERE hash=?"));
-                storeDecision = NetworkCache::StoreDecision::Yes;
+                storeDecision = StoreDecision::Yes;
                 if (statement.prepare() == WebCore::SQLResultOk) {
                     statement.bindText(1, query.hash);
                     if (statement.step() == WebCore::SQLResultRow)
-                        storeDecision = static_cast<NetworkCache::StoreDecision>(statement.getColumnInt(0));
+                        storeDecision = static_cast<StoreDecision>(statement.getColumnInt(0));
                 }
             }
         }
@@ -369,7 +370,7 @@ void NetworkCacheStatistics::queryWasEverRequested(const String& hash, NeedUncac
     });
 }
 
-void NetworkCacheStatistics::clear()
+void Statistics::clear()
 {
     ASSERT(RunLoop::isMain());
 
@@ -386,7 +387,7 @@ void NetworkCacheStatistics::clear()
     });
 }
 
-void NetworkCacheStatistics::addHashesToDatabase(const Vector<StringCapture>& hashes)
+void Statistics::addHashesToDatabase(const Vector<StringCapture>& hashes)
 {
     ASSERT(!RunLoop::isMain());
     ASSERT(WebCore::SQLiteDatabaseTracker::hasTransactionInProgress());
@@ -404,7 +405,7 @@ void NetworkCacheStatistics::addHashesToDatabase(const Vector<StringCapture>& ha
     }
 }
 
-void NetworkCacheStatistics::addStoreDecisionsToDatabase(const Vector<std::pair<StringCapture, NetworkCache::StoreDecision>>& storeDecisions)
+void Statistics::addStoreDecisionsToDatabase(const Vector<std::pair<StringCapture, StoreDecision>>& storeDecisions)
 {
     ASSERT(!RunLoop::isMain());
     ASSERT(WebCore::SQLiteDatabaseTracker::hasTransactionInProgress());
@@ -422,6 +423,7 @@ void NetworkCacheStatistics::addStoreDecisionsToDatabase(const Vector<std::pair<
     }
 }
 
-} // namespace WebKit
+}
+}
 
 #endif // ENABLE(NETWORK_CACHE)
index 97c0a57..b56b1b3 100644 (file)
 #include <wtf/WorkQueue.h>
 #include <wtf/text/WTFString.h>
 
-namespace WebCore {
-class SharedBuffer;
-}
-
-namespace IPC {
-class ArgumentEncoder;
-class ArgumentDecoder;
-}
-
 namespace WebKit {
+namespace NetworkCache {
 
-class NetworkCacheStorage {
-    WTF_MAKE_NONCOPYABLE(NetworkCacheStorage);
+class Storage {
+    WTF_MAKE_NONCOPYABLE(Storage);
 public:
-    static std::unique_ptr<NetworkCacheStorage> open(const String& cachePath);
+    static std::unique_ptr<Storage> open(const String& cachePath);
 
     struct Entry {
-        NetworkCacheKey key;
+        Key key;
         std::chrono::milliseconds timeStamp;
-        NetworkCacheData header;
-        NetworkCacheData body;
+        Data header;
+        Data body;
     };
     // This may call completion handler synchronously on failure.
     typedef std::function<bool (std::unique_ptr<Entry>)> RetrieveCompletionHandler;
-    void retrieve(const NetworkCacheKey&, unsigned priority, RetrieveCompletionHandler&&);
+    void retrieve(const Key&, unsigned priority, RetrieveCompletionHandler&&);
 
-    typedef std::function<void (bool success, const NetworkCacheData& mappedBody)> StoreCompletionHandler;
+    typedef std::function<void (bool success, const Data& mappedBody)> StoreCompletionHandler;
     void store(const Entry&, StoreCompletionHandler&&);
     void update(const Entry& updateEntry, const Entry& existingEntry, StoreCompletionHandler&&);
 
@@ -79,16 +71,16 @@ public:
     const String& directoryPath() const { return m_directoryPath; }
 
 private:
-    NetworkCacheStorage(const String& directoryPath);
+    Storage(const String& directoryPath);
 
     void initialize();
     void deleteOldVersions();
     void shrinkIfNeeded();
 
-    void removeEntry(const NetworkCacheKey&);
+    void removeEntry(const Key&);
 
     struct ReadOperation {
-        NetworkCacheKey key;
+        Key key;
         RetrieveCompletionHandler completionHandler;
     };
     void dispatchReadOperation(const ReadOperation&);
@@ -127,5 +119,6 @@ private:
 };
 
 }
+}
 #endif
 #endif
index 0966c1a..1ff52f1 100644 (file)
 #endif
 
 namespace WebKit {
+namespace NetworkCache {
 
 static const char networkCacheSubdirectory[] = "WebKitCache";
 static const char versionDirectoryPrefix[] = "Version ";
 
-std::unique_ptr<NetworkCacheStorage> NetworkCacheStorage::open(const String& cachePath)
+std::unique_ptr<Storage> Storage::open(const String& cachePath)
 {
     ASSERT(RunLoop::isMain());
 
     String networkCachePath = WebCore::pathByAppendingComponent(cachePath, networkCacheSubdirectory);
     if (!WebCore::makeAllDirectories(networkCachePath))
         return nullptr;
-    return std::unique_ptr<NetworkCacheStorage>(new NetworkCacheStorage(networkCachePath));
+    return std::unique_ptr<Storage>(new Storage(networkCachePath));
 }
 
 static String makeVersionedDirectoryPath(const String& baseDirectoryPath)
 {
-    String versionSubdirectory = versionDirectoryPrefix + String::number(NetworkCacheStorage::version);
+    String versionSubdirectory = versionDirectoryPrefix + String::number(Storage::version);
     return WebCore::pathByAppendingComponent(baseDirectoryPath, versionSubdirectory);
 }
 
-NetworkCacheStorage::NetworkCacheStorage(const String& baseDirectoryPath)
+Storage::Storage(const String& baseDirectoryPath)
     : m_baseDirectoryPath(baseDirectoryPath)
     , m_directoryPath(makeVersionedDirectoryPath(baseDirectoryPath))
     , m_ioQueue(WorkQueue::create("com.apple.WebKit.Cache.Storage", WorkQueue::Type::Concurrent))
@@ -76,7 +77,7 @@ NetworkCacheStorage::NetworkCacheStorage(const String& baseDirectoryPath)
     initialize();
 }
 
-void NetworkCacheStorage::initialize()
+void Storage::initialize()
 {
     ASSERT(RunLoop::isMain());
 
@@ -85,10 +86,10 @@ void NetworkCacheStorage::initialize()
     backgroundIOQueue().dispatch([this, cachePathCapture] {
         String cachePath = cachePathCapture.string();
         traverseCacheFiles(cachePath, [this](const String& fileName, const String& partitionPath) {
-            NetworkCacheKey::HashType hash;
-            if (!NetworkCacheKey::stringToHash(fileName, hash))
+            Key::HashType hash;
+            if (!Key::stringToHash(fileName, hash))
                 return;
-            unsigned shortHash = NetworkCacheKey::toShortHash(hash);
+            unsigned shortHash = Key::toShortHash(hash);
             RunLoop::main().dispatch([this, shortHash] {
                 m_contentsFilter.add(shortHash);
             });
@@ -100,29 +101,29 @@ void NetworkCacheStorage::initialize()
     });
 }
 
-static String directoryPathForKey(const NetworkCacheKey& key, const String& cachePath)
+static String directoryPathForKey(const Key& key, const String& cachePath)
 {
     ASSERT(!key.partition().isEmpty());
     return WebCore::pathByAppendingComponent(cachePath, key.partition());
 }
 
-static String fileNameForKey(const NetworkCacheKey& key)
+static String fileNameForKey(const Key& key)
 {
     return key.hashAsString();
 }
 
-static String filePathForKey(const NetworkCacheKey& key, const String& cachePath)
+static String filePathForKey(const Key& key, const String& cachePath)
 {
     return WebCore::pathByAppendingComponent(directoryPathForKey(key, cachePath), fileNameForKey(key));
 }
 
-static Ref<NetworkCacheIOChannel> openFileForKey(const NetworkCacheKey& key, NetworkCacheIOChannel::Type type, const String& cachePath)
+static Ref<IOChannel> openFileForKey(const Key& key, IOChannel::Type type, const String& cachePath)
 {
     auto directoryPath = directoryPathForKey(key, cachePath);
     auto filePath = WebCore::pathByAppendingComponent(directoryPath, fileNameForKey(key));
-    if (type == NetworkCacheIOChannel::Type::Create)
+    if (type == IOChannel::Type::Create)
         WebCore::makeAllDirectories(directoryPath);
-    return NetworkCacheIOChannel::open(filePath, type);
+    return IOChannel::open(filePath, type);
 }
 
 static unsigned hashData(dispatch_data_t data)
@@ -139,10 +140,13 @@ static unsigned hashData(dispatch_data_t data)
 
 struct EntryMetaData {
     EntryMetaData() { }
-    explicit EntryMetaData(const NetworkCacheKey& key) : cacheStorageVersion(NetworkCacheStorage::version), key(key) { }
+    explicit EntryMetaData(const Key& key)
+        : cacheStorageVersion(Storage::version)
+        , key(key)
+    { }
 
     unsigned cacheStorageVersion;
-    NetworkCacheKey key;
+    Key key;
     std::chrono::milliseconds timeStamp;
     unsigned headerChecksum;
     uint64_t headerOffset;
@@ -152,11 +156,11 @@ struct EntryMetaData {
     uint64_t bodySize;
 };
 
-static bool decodeEntryMetaData(EntryMetaData& metaData, const NetworkCacheData& fileData)
+static bool decodeEntryMetaData(EntryMetaData& metaData, const Data& fileData)
 {
     bool success = false;
     dispatch_data_apply(fileData.dispatchData(), [&metaData, &success](dispatch_data_t, size_t, const void* data, size_t size) {
-        NetworkCacheDecoder decoder(reinterpret_cast<const uint8_t*>(data), size);
+        Decoder decoder(reinterpret_cast<const uint8_t*>(data), size);
         if (!decoder.decode(metaData.cacheStorageVersion))
             return false;
         if (!decoder.decode(metaData.key))
@@ -192,11 +196,11 @@ static DispatchPtr<dispatch_data_t> mapFile(int fd, size_t offset, size_t size)
     return bodyMap;
 }
 
-static bool decodeEntryHeader(const NetworkCacheData& fileData, EntryMetaData& metaData, NetworkCacheData& data)
+static bool decodeEntryHeader(const Data& fileData, EntryMetaData& metaData, Data& data)
 {
     if (!decodeEntryMetaData(metaData, fileData))
         return false;
-    if (metaData.cacheStorageVersion != NetworkCacheStorage::version)
+    if (metaData.cacheStorageVersion != Storage::version)
         return false;
     if (metaData.headerOffset + metaData.headerSize > metaData.bodyOffset)
         return false;
@@ -210,10 +214,10 @@ static bool decodeEntryHeader(const NetworkCacheData& fileData, EntryMetaData& m
     return true;
 }
 
-static std::unique_ptr<NetworkCacheStorage::Entry> decodeEntry(const NetworkCacheData& fileData, int fd, const NetworkCacheKey& key)
+static std::unique_ptr<Storage::Entry> decodeEntry(const Data& fileData, int fd, const Key& key)
 {
     EntryMetaData metaData;
-    NetworkCacheData headerData;
+    Data headerData;
     if (!decodeEntryHeader(fileData, metaData, headerData))
         return nullptr;
 
@@ -233,17 +237,17 @@ static std::unique_ptr<NetworkCacheStorage::Entry> decodeEntry(const NetworkCach
         return nullptr;
     }
 
-    return std::unique_ptr<NetworkCacheStorage::Entry>(new NetworkCacheStorage::Entry {
+    return std::unique_ptr<Storage::Entry>(new Storage::Entry {
         metaData.key,
         metaData.timeStamp,
         headerData,
-        { bodyData, NetworkCacheData::Backing::Map }
+        { bodyData, Data::Backing::Map }
     });
 }
 
 static DispatchPtr<dispatch_data_t> encodeEntryMetaData(const EntryMetaData& entry)
 {
-    NetworkCacheEncoder encoder;
+    Encoder encoder;
 
     encoder << entry.cacheStorageVersion;
     encoder << entry.key;
@@ -258,7 +262,7 @@ static DispatchPtr<dispatch_data_t> encodeEntryMetaData(const EntryMetaData& ent
     return adoptDispatch(dispatch_data_create(encoder.buffer(), encoder.bufferSize(), nullptr, DISPATCH_DATA_DESTRUCTOR_DEFAULT));
 }
 
-static NetworkCacheData encodeEntryHeader(const NetworkCacheStorage::Entry& entry)
+static Data encodeEntryHeader(const Storage::Entry& entry)
 {
     EntryMetaData metaData(entry.key);
     metaData.timeStamp = entry.timeStamp;
@@ -279,7 +283,7 @@ static NetworkCacheData encodeEntryHeader(const NetworkCacheStorage::Entry& entr
     return { adoptDispatch(dispatch_data_create_concat(headerData.get(), alignmentData.get())) };
 }
 
-void NetworkCacheStorage::removeEntry(const NetworkCacheKey& key)
+void Storage::removeEntry(const Key& key)
 {
     ASSERT(RunLoop::isMain());
 
@@ -295,16 +299,16 @@ void NetworkCacheStorage::removeEntry(const NetworkCacheKey& key)
     });
 }
 
-void NetworkCacheStorage::dispatchReadOperation(const ReadOperation& read)
+void Storage::dispatchReadOperation(const ReadOperation& read)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(m_activeReadOperations.contains(&read));
 
     StringCapture cachePathCapture(m_directoryPath);
     ioQueue().dispatch([this, &read, cachePathCapture] {
-        auto channel = openFileForKey(read.key, NetworkCacheIOChannel::Type::Read, cachePathCapture.string());
+        auto channel = openFileForKey(read.key, IOChannel::Type::Read, cachePathCapture.string());
         int fd = channel->fileDescriptor();
-        channel->read(0, std::numeric_limits<size_t>::max(), [this, &read, fd](NetworkCacheData& fileData, int error) {
+        channel->read(0, std::numeric_limits<size_t>::max(), [this, &read, fd](Data& fileData, int error) {
             if (error) {
                 removeEntry(read.key);
                 read.completionHandler(nullptr);
@@ -324,7 +328,7 @@ void NetworkCacheStorage::dispatchReadOperation(const ReadOperation& read)
     });
 }
 
-void NetworkCacheStorage::dispatchPendingReadOperations()
+void Storage::dispatchPendingReadOperations()
 {
     ASSERT(RunLoop::isMain());
 
@@ -345,14 +349,14 @@ void NetworkCacheStorage::dispatchPendingReadOperations()
     }
 }
 
-template <class T> bool retrieveFromMemory(const T& operations, const NetworkCacheKey& key, NetworkCacheStorage::RetrieveCompletionHandler& completionHandler)
+template <class T> bool retrieveFromMemory(const T& operations, const Key& key, Storage::RetrieveCompletionHandler& completionHandler)
 {
     for (auto& operation : operations) {
         if (operation->entry.key == key) {
             LOG(NetworkCacheStorage, "(NetworkProcess) found write operation in progress");
             auto entry = operation->entry;
             RunLoop::main().dispatch([entry, completionHandler] {
-                completionHandler(std::make_unique<NetworkCacheStorage::Entry>(entry));
+                completionHandler(std::make_unique<Storage::Entry>(entry));
             });
             return true;
         }
@@ -360,7 +364,7 @@ template <class T> bool retrieveFromMemory(const T& operations, const NetworkCac
     return false;
 }
 
-void NetworkCacheStorage::retrieve(const NetworkCacheKey& key, unsigned priority, RetrieveCompletionHandler&& completionHandler)
+void Storage::retrieve(const Key& key, unsigned priority, RetrieveCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(priority <= maximumRetrievePriority);
@@ -385,7 +389,7 @@ void NetworkCacheStorage::retrieve(const NetworkCacheKey& key, unsigned priority
     dispatchPendingReadOperations();
 }
 
-void NetworkCacheStorage::store(const Entry& entry, StoreCompletionHandler&& completionHandler)
+void Storage::store(const Entry& entry, StoreCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(!entry.key.isNull());
@@ -403,7 +407,7 @@ void NetworkCacheStorage::store(const Entry& entry, StoreCompletionHandler&& com
     dispatchPendingWriteOperations();
 }
 
-void NetworkCacheStorage::update(const Entry& updateEntry, const Entry& existingEntry, StoreCompletionHandler&& completionHandler)
+void Storage::update(const Entry& updateEntry, const Entry& existingEntry, StoreCompletionHandler&& completionHandler)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(!existingEntry.key.isNull());
@@ -419,7 +423,7 @@ void NetworkCacheStorage::update(const Entry& updateEntry, const Entry& existing
     dispatchPendingWriteOperations();
 }
 
-void NetworkCacheStorage::traverse(std::function<void (const Entry*)>&& traverseHandler)
+void Storage::traverse(std::function<void (const Entry*)>&& traverseHandler)
 {
     StringCapture cachePathCapture(m_directoryPath);
     ioQueue().dispatch([this, cachePathCapture, traverseHandler] {
@@ -427,11 +431,11 @@ void NetworkCacheStorage::traverse(std::function<void (const Entry*)>&& traverse
         auto semaphore = adoptDispatch(dispatch_semaphore_create(0));
         traverseCacheFiles(cachePath, [this, &semaphore, &traverseHandler](const String& fileName, const String& partitionPath) {
             auto filePath = WebCore::pathByAppendingComponent(partitionPath, fileName);
-            auto channel = NetworkCacheIOChannel::open(filePath, NetworkCacheIOChannel::Type::Read);
+            auto channel = IOChannel::open(filePath, IOChannel::Type::Read);
             const size_t headerReadSize = 16 << 10;
-            channel->read(0, headerReadSize, [this, &semaphore, &traverseHandler](NetworkCacheData& fileData, int) {
+            channel->read(0, headerReadSize, [this, &semaphore, &traverseHandler](Data& fileData, int) {
                 EntryMetaData metaData;
-                NetworkCacheData headerData;
+                Data headerData;
                 if (decodeEntryHeader(fileData, metaData, headerData)) {
                     Entry entry { metaData.key, metaData.timeStamp, headerData, { } };
                     traverseHandler(&entry);
@@ -446,7 +450,7 @@ void NetworkCacheStorage::traverse(std::function<void (const Entry*)>&& traverse
     });
 }
 
-void NetworkCacheStorage::dispatchPendingWriteOperations()
+void Storage::dispatchPendingWriteOperations()
 {
     ASSERT(RunLoop::isMain());
 
@@ -469,7 +473,7 @@ void NetworkCacheStorage::dispatchPendingWriteOperations()
     }
 }
 
-void NetworkCacheStorage::dispatchFullWriteOperation(const WriteOperation& write)
+void Storage::dispatchFullWriteOperation(const WriteOperation& write)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(m_activeWriteOperations.contains(&write));
@@ -482,9 +486,9 @@ void NetworkCacheStorage::dispatchFullWriteOperation(const WriteOperation& write
         auto encodedHeader = encodeEntryHeader(write.entry);
         auto headerAndBodyData = adoptDispatch(dispatch_data_create_concat(encodedHeader.dispatchData(), write.entry.body.dispatchData()));
 
-        NetworkCacheData writeData(headerAndBodyData);
+        Data writeData(headerAndBodyData);
 
-        auto channel = openFileForKey(write.entry.key, NetworkCacheIOChannel::Type::Create, cachePathCapture.string());
+        auto channel = openFileForKey(write.entry.key, IOChannel::Type::Create, cachePathCapture.string());
         int fd = channel->fileDescriptor();
         size_t bodyOffset = encodedHeader.size();
 
@@ -502,7 +506,7 @@ void NetworkCacheStorage::dispatchFullWriteOperation(const WriteOperation& write
             bool shouldMapBody = !error && bodySize >= vm_page_size;
             auto bodyMap = shouldMapBody ? mapFile(fd, bodyOffset, bodySize) : nullptr;
 
-            NetworkCacheData bodyData(bodyMap, NetworkCacheData::Backing::Map);
+            Data bodyData(bodyMap, Data::Backing::Map);
             write.completionHandler(!error, bodyData);
 
             ASSERT(m_activeWriteOperations.contains(&write));
@@ -514,7 +518,7 @@ void NetworkCacheStorage::dispatchFullWriteOperation(const WriteOperation& write
     shrinkIfNeeded();
 }
 
-void NetworkCacheStorage::dispatchHeaderWriteOperation(const WriteOperation& write)
+void Storage::dispatchHeaderWriteOperation(const WriteOperation& write)
 {
     ASSERT(RunLoop::isMain());
     ASSERT(write.existingEntry);
@@ -536,7 +540,7 @@ void NetworkCacheStorage::dispatchHeaderWriteOperation(const WriteOperation& wri
             return;
         }
 
-        auto channel = openFileForKey(write.entry.key, NetworkCacheIOChannel::Type::Write, cachePathCapture.string());
+        auto channel = openFileForKey(write.entry.key, IOChannel::Type::Write, cachePathCapture.string());
         channel->write(0, headerData, [this, &write](int error) {
             LOG(NetworkCacheStorage, "(NetworkProcess) update complete error=%d", error);
 
@@ -552,7 +556,7 @@ void NetworkCacheStorage::dispatchHeaderWriteOperation(const WriteOperation& wri
     });
 }
 
-void NetworkCacheStorage::setMaximumSize(size_t size)
+void Storage::setMaximumSize(size_t size)
 {
     ASSERT(RunLoop::isMain());
     m_maximumSize = size;
@@ -560,7 +564,7 @@ void NetworkCacheStorage::setMaximumSize(size_t size)
     shrinkIfNeeded();
 }
 
-void NetworkCacheStorage::clear()
+void Storage::clear()
 {
     ASSERT(RunLoop::isMain());
     LOG(NetworkCacheStorage, "(NetworkProcess) clearing cache");
@@ -582,7 +586,7 @@ void NetworkCacheStorage::clear()
     });
 }
 
-void NetworkCacheStorage::shrinkIfNeeded()
+void Storage::shrinkIfNeeded()
 {
     ASSERT(RunLoop::isMain());
 
@@ -613,10 +617,10 @@ void NetworkCacheStorage::shrinkIfNeeded()
             }
 
             WebCore::deleteFile(filePath);
-            NetworkCacheKey::HashType hash;
-            if (!NetworkCacheKey::stringToHash(fileName, hash))
+            Key::HashType hash;
+            if (!Key::stringToHash(fileName, hash))
                 return;
-            unsigned shortHash = NetworkCacheKey::toShortHash(hash);
+            unsigned shortHash = Key::toShortHash(hash);
             RunLoop::main().dispatch([this, shortHash] {
                 if (m_contentsFilter.mayContain(shortHash))
                     m_contentsFilter.remove(shortHash);
@@ -635,7 +639,7 @@ void NetworkCacheStorage::shrinkIfNeeded()
     });
 }
 
-void NetworkCacheStorage::deleteOldVersions()
+void Storage::deleteOldVersions()
 {
     // Delete V1 cache.
     StringCapture cachePathCapture(m_baseDirectoryPath);
@@ -654,5 +658,6 @@ void NetworkCacheStorage::deleteOldVersions()
 }
 
 }
+}
 
 #endif