Changeset 210502 in webkit


Ignore:
Timestamp:
Jan 9, 2017, 4:43:49 AM (8 years ago)
Author:
Antti Koivisto
Message:

Move cache coders to WTF
https://bugs.webkit.org/show_bug.cgi?id=166825

Rubber-stamped by Sam Weinig.

Source/WebKit2:

  • NetworkProcess/cache/NetworkCache.h:
  • NetworkProcess/cache/NetworkCacheCoder.h: Removed.
  • NetworkProcess/cache/NetworkCacheCoders.cpp:

(WebKit::NetworkCache::Coder<AtomicString>::encode): Deleted.
(WebKit::NetworkCache::Coder<AtomicString>::decode): Deleted.
(WebKit::NetworkCache::Coder<CString>::encode): Deleted.
(WebKit::NetworkCache::Coder<CString>::decode): Deleted.
(WebKit::NetworkCache::Coder<String>::encode): Deleted.
(WebKit::NetworkCache::decodeStringText): Deleted.
(WebKit::NetworkCache::Coder<String>::decode): Deleted.
(WebKit::NetworkCache::Coder<SHA1::Digest>::encode): Deleted.
(WebKit::NetworkCache::Coder<SHA1::Digest>::decode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::encode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::decode): Deleted.

  • NetworkProcess/cache/NetworkCacheCoders.h:

(): Deleted.
(WebKit::NetworkCache::Coder<std::optional<T>>::encode): Deleted.
(WebKit::NetworkCache::Coder<std::optional<T>>::decode): Deleted.

  • NetworkProcess/cache/NetworkCacheCodersCocoa.cpp:

(WebKit::NetworkCache::encodeCFData): Deleted.
(WebKit::NetworkCache::decodeCFData): Deleted.
(WebKit::NetworkCache::encodeSecTrustRef): Deleted.
(WebKit::NetworkCache::decodeSecTrustRef): Deleted.
(WebKit::NetworkCache::encodeCertificateChain): Deleted.
(WebKit::NetworkCache::decodeCertificateChain): Deleted.
(WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::encode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::decode): Deleted.

  • NetworkProcess/cache/NetworkCacheDecoder.cpp: Removed.
  • NetworkProcess/cache/NetworkCacheDecoder.h: Removed.
  • NetworkProcess/cache/NetworkCacheEncoder.cpp: Removed.
  • NetworkProcess/cache/NetworkCacheEncoder.h: Removed.
  • NetworkProcess/cache/NetworkCacheEntry.cpp:

(WebKit::NetworkCache::Entry::encodeAsStorageRecord):
(WebKit::NetworkCache::Entry::decodeStorageRecord):

  • NetworkProcess/cache/NetworkCacheKey.cpp:

(WebKit::NetworkCache::Key::encode):
(WebKit::NetworkCache::Key::decode):

  • NetworkProcess/cache/NetworkCacheKey.h:
  • NetworkProcess/cache/NetworkCacheStorage.cpp:

(WebKit::NetworkCache::decodeRecordMetaData):
(WebKit::NetworkCache::encodeRecordMetaData):

  • NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:

(WebKit::NetworkCache::SubresourceInfo::encode):
(WebKit::NetworkCache::SubresourceInfo::decode):
(WebKit::NetworkCache::SubresourcesEntry::encodeAsStorageRecord):
(WebKit::NetworkCache::SubresourcesEntry::decodeStorageRecord):

  • NetworkProcess/cache/NetworkCacheSubresourcesEntry.h:
  • UIProcess/API/APIUserContentExtensionStore.cpp:

(API::encodeContentExtensionMetaData):
(API::decodeContentExtensionMetaData):

  • WebKit2.xcodeproj/project.pbxproj:

Source/WTF:

Make it possible to use robust serialization of WTF types on the lower levels of the stack.

  • WTF.xcodeproj/project.pbxproj:
  • wtf/persistence: Added.
  • wtf/persistence/Coder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoder.h.

(WebKit::NetworkCache::Coder::encode): Deleted.
(WebKit::NetworkCache::Coder::decode): Deleted.

  • wtf/persistence/Coders.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp.

(WebKit::NetworkCache::Coder<AtomicString>::encode): Deleted.
(WebKit::NetworkCache::Coder<AtomicString>::decode): Deleted.
(WebKit::NetworkCache::Coder<CString>::encode): Deleted.
(WebKit::NetworkCache::Coder<CString>::decode): Deleted.
(WebKit::NetworkCache::Coder<String>::encode): Deleted.
(WebKit::NetworkCache::decodeStringText): Deleted.
(WebKit::NetworkCache::Coder<String>::decode): Deleted.
(WebKit::NetworkCache::Coder<SHA1::Digest>::encode): Deleted.
(WebKit::NetworkCache::Coder<SHA1::Digest>::decode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::encode): Deleted.
(WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::decode): Deleted.

  • wtf/persistence/Coders.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h.

(WebKit::NetworkCache::Coder<std::optional<T>>::encode): Deleted.
(WebKit::NetworkCache::Coder<std::optional<T>>::decode): Deleted.

  • wtf/persistence/Decoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.cpp.

(WebKit::NetworkCache::Decoder::Decoder): Deleted.
(WebKit::NetworkCache::Decoder::~Decoder): Deleted.
(WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
(WebKit::NetworkCache::Decoder::decodeFixedLengthData): Deleted.
(WebKit::NetworkCache::Decoder::decodeNumber): Deleted.
(WebKit::NetworkCache::Decoder::decode): Deleted.
(WebKit::NetworkCache::Decoder::verifyChecksum): Deleted.

  • wtf/persistence/Decoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.h.

(WebKit::NetworkCache::Decoder::length): Deleted.
(WebKit::NetworkCache::Decoder::currentOffset): Deleted.
(WebKit::NetworkCache::Decoder::decodeEnum): Deleted.
(WebKit::NetworkCache::Decoder::decode): Deleted.
(WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.

  • wtf/persistence/Encoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.cpp.

(WebKit::NetworkCache::Encoder::Encoder): Deleted.
(WebKit::NetworkCache::Encoder::~Encoder): Deleted.
(WebKit::NetworkCache::Encoder::grow): Deleted.
(WebKit::NetworkCache::Encoder::updateChecksumForData): Deleted.
(WebKit::NetworkCache::Encoder::encodeFixedLengthData): Deleted.
(WebKit::NetworkCache::Encoder::encodeNumber): Deleted.
(WebKit::NetworkCache::Encoder::encode): Deleted.
(WebKit::NetworkCache::Encoder::encodeChecksum): Deleted.

  • wtf/persistence/Encoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.h.

(WebKit::NetworkCache::Encoder::encodeEnum): Deleted.
(WebKit::NetworkCache::Encoder::encode): Deleted.
(WebKit::NetworkCache::Encoder::operator<<): Deleted.
(WebKit::NetworkCache::Encoder::buffer): Deleted.
(WebKit::NetworkCache::Encoder::bufferSize): Deleted.
(WebKit::NetworkCache::Encoder::updateChecksumForNumber): Deleted.

Location:
trunk/Source
Files:
1 added
17 edited
2 copied
5 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r210496 r210502  
     12017-01-08  Antti Koivisto  <antti@apple.com>
     2
     3        Move cache coders to WTF
     4        https://bugs.webkit.org/show_bug.cgi?id=166825
     5
     6        Rubber-stamped by Sam Weinig.
     7
     8        Make it possible to use robust serialization of WTF types on the lower levels of the stack.
     9
     10        * WTF.xcodeproj/project.pbxproj:
     11        * wtf/persistence: Added.
     12        * wtf/persistence/Coder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoder.h.
     13        (WebKit::NetworkCache::Coder::encode): Deleted.
     14        (WebKit::NetworkCache::Coder::decode): Deleted.
     15        * wtf/persistence/Coders.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp.
     16        (WebKit::NetworkCache::Coder<AtomicString>::encode): Deleted.
     17        (WebKit::NetworkCache::Coder<AtomicString>::decode): Deleted.
     18        (WebKit::NetworkCache::Coder<CString>::encode): Deleted.
     19        (WebKit::NetworkCache::Coder<CString>::decode): Deleted.
     20        (WebKit::NetworkCache::Coder<String>::encode): Deleted.
     21        (WebKit::NetworkCache::decodeStringText): Deleted.
     22        (WebKit::NetworkCache::Coder<String>::decode): Deleted.
     23        (WebKit::NetworkCache::Coder<SHA1::Digest>::encode): Deleted.
     24        (WebKit::NetworkCache::Coder<SHA1::Digest>::decode): Deleted.
     25        (WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::encode): Deleted.
     26        (WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::decode): Deleted.
     27        * wtf/persistence/Coders.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h.
     28        (WebKit::NetworkCache::Coder<std::optional<T>>::encode): Deleted.
     29        (WebKit::NetworkCache::Coder<std::optional<T>>::decode): Deleted.
     30        * wtf/persistence/Decoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.cpp.
     31        (WebKit::NetworkCache::Decoder::Decoder): Deleted.
     32        (WebKit::NetworkCache::Decoder::~Decoder): Deleted.
     33        (WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
     34        (WebKit::NetworkCache::Decoder::decodeFixedLengthData): Deleted.
     35        (WebKit::NetworkCache::Decoder::decodeNumber): Deleted.
     36        (WebKit::NetworkCache::Decoder::decode): Deleted.
     37        (WebKit::NetworkCache::Decoder::verifyChecksum): Deleted.
     38        * wtf/persistence/Decoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheDecoder.h.
     39        (WebKit::NetworkCache::Decoder::length): Deleted.
     40        (WebKit::NetworkCache::Decoder::currentOffset): Deleted.
     41        (WebKit::NetworkCache::Decoder::decodeEnum): Deleted.
     42        (WebKit::NetworkCache::Decoder::decode): Deleted.
     43        (WebKit::NetworkCache::Decoder::bufferIsLargeEnoughToContain): Deleted.
     44        * wtf/persistence/Encoder.cpp: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.cpp.
     45        (WebKit::NetworkCache::Encoder::Encoder): Deleted.
     46        (WebKit::NetworkCache::Encoder::~Encoder): Deleted.
     47        (WebKit::NetworkCache::Encoder::grow): Deleted.
     48        (WebKit::NetworkCache::Encoder::updateChecksumForData): Deleted.
     49        (WebKit::NetworkCache::Encoder::encodeFixedLengthData): Deleted.
     50        (WebKit::NetworkCache::Encoder::encodeNumber): Deleted.
     51        (WebKit::NetworkCache::Encoder::encode): Deleted.
     52        (WebKit::NetworkCache::Encoder::encodeChecksum): Deleted.
     53        * wtf/persistence/Encoder.h: Copied from Source/WebKit2/NetworkProcess/cache/NetworkCacheEncoder.h.
     54        (WebKit::NetworkCache::Encoder::encodeEnum): Deleted.
     55        (WebKit::NetworkCache::Encoder::encode): Deleted.
     56        (WebKit::NetworkCache::Encoder::operator<<): Deleted.
     57        (WebKit::NetworkCache::Encoder::buffer): Deleted.
     58        (WebKit::NetworkCache::Encoder::bufferSize): Deleted.
     59        (WebKit::NetworkCache::Encoder::updateChecksumForNumber): Deleted.
     60
    1612017-01-08  Konstantin Tokarev  <annulen@yandex.ru>
    262
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r209896 r210502  
    354354                E15556F518A0CC18006F48FB /* CryptographicUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */; };
    355355                E15556F618A0CC18006F48FB /* CryptographicUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = E15556F418A0CC18006F48FB /* CryptographicUtilities.h */; };
     356                E43A46951E228B9100276B05 /* Decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E43A46901E228B9100276B05 /* Decoder.h */; };
     357                E43A46961E228B9100276B05 /* Encoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E43A46911E228B9100276B05 /* Encoder.h */; };
     358                E43A46971E228B9100276B05 /* Decoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43A46921E228B9100276B05 /* Decoder.cpp */; };
     359                E43A46981E228B9100276B05 /* Encoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43A46931E228B9100276B05 /* Encoder.cpp */; };
     360                E43A46991E228B9100276B05 /* Coder.h in Headers */ = {isa = PBXBuildFile; fileRef = E43A46941E228B9100276B05 /* Coder.h */; };
     361                E43A469B1E228FB200276B05 /* Coders.h in Headers */ = {isa = PBXBuildFile; fileRef = E43A469A1E228FB200276B05 /* Coders.h */; };
     362                E43A469D1E228FD500276B05 /* Coders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E43A469C1E228FD500276B05 /* Coders.cpp */; };
    356363                E4A0AD391A96245500536DF6 /* WorkQueue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4A0AD371A96245500536DF6 /* WorkQueue.cpp */; };
    357364                E4A0AD3A1A96245500536DF6 /* WorkQueue.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A0AD381A96245500536DF6 /* WorkQueue.h */; };
     
    726733                E15556F318A0CC18006F48FB /* CryptographicUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptographicUtilities.cpp; sourceTree = "<group>"; };
    727734                E15556F418A0CC18006F48FB /* CryptographicUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptographicUtilities.h; sourceTree = "<group>"; };
     735                E43A46901E228B9100276B05 /* Decoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Decoder.h; sourceTree = "<group>"; };
     736                E43A46911E228B9100276B05 /* Encoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Encoder.h; sourceTree = "<group>"; };
     737                E43A46921E228B9100276B05 /* Decoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Decoder.cpp; sourceTree = "<group>"; };
     738                E43A46931E228B9100276B05 /* Encoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Encoder.cpp; sourceTree = "<group>"; };
     739                E43A46941E228B9100276B05 /* Coder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Coder.h; sourceTree = "<group>"; };
     740                E43A469A1E228FB200276B05 /* Coders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Coders.h; sourceTree = "<group>"; };
     741                E43A469C1E228FD500276B05 /* Coders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Coders.cpp; sourceTree = "<group>"; };
    728742                E4A0AD371A96245500536DF6 /* WorkQueue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueue.cpp; sourceTree = "<group>"; };
    729743                E4A0AD381A96245500536DF6 /* WorkQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueue.h; sourceTree = "<group>"; };
     
    870884                                1FA47C87152502DA00568D1B /* ios */,
    871885                                A8A472C4151A825A004123FF /* mac */,
     886                                E43A46851E228B5700276B05 /* persistence */,
    872887                                CEF4820C19DA347600CC04B8 /* spi */,
    873888                                A8A4731B151A825B004123FF /* text */,
     
    12781293                        sourceTree = "<group>";
    12791294                };
     1295                E43A46851E228B5700276B05 /* persistence */ = {
     1296                        isa = PBXGroup;
     1297                        children = (
     1298                                E43A46941E228B9100276B05 /* Coder.h */,
     1299                                E43A469A1E228FB200276B05 /* Coders.h */,
     1300                                E43A469C1E228FD500276B05 /* Coders.cpp */,
     1301                                E43A46921E228B9100276B05 /* Decoder.cpp */,
     1302                                E43A46901E228B9100276B05 /* Decoder.h */,
     1303                                E43A46931E228B9100276B05 /* Encoder.cpp */,
     1304                                E43A46911E228B9100276B05 /* Encoder.h */,
     1305                        );
     1306                        path = persistence;
     1307                        sourceTree = "<group>";
     1308                };
    12801309                E4A0AD3B1A96251900536DF6 /* cocoa */ = {
    12811310                        isa = PBXGroup;
     
    13301359                                EB95E1F0161A72410089A2F5 /* ByteOrder.h in Headers */,
    13311360                                A8A473AD151A825B004123FF /* cached-powers.h in Headers */,
     1361                                E43A469B1E228FB200276B05 /* Coders.h in Headers */,
    13321362                                DCEE21FB1CEA7538000C2396 /* CFBundleSPI.h in Headers */,
    13331363                                A8A4745E151A825B004123FF /* CharacterNames.h in Headers */,
     
    13631393                                A8A473A7151A825B004123FF /* DoublyLinkedList.h in Headers */,
    13641394                                A8A473BB151A825B004123FF /* dtoa.h in Headers */,
     1395                                E43A46961E228B9100276B05 /* Encoder.h in Headers */,
    13651396                                93DDE9321CDC052D00FD3491 /* dyldSPI.h in Headers */,
    13661397                                1AEA88E21D6BBCF400E5AD64 /* EnumTraits.h in Headers */,
     
    15091540                                A8A47455151A825B004123FF /* ThreadSpecific.h in Headers */,
    15101541                                0F66B2911DC97BAB004A1D3F /* TimeWithDynamicClockType.h in Headers */,
     1542                                E43A46951E228B9100276B05 /* Decoder.h in Headers */,
    15111543                                553071CA1C40427200384898 /* TinyLRUCache.h in Headers */,
    15121544                                0FED67B61B22D4D80066CE15 /* TinyPtrSet.h in Headers */,
     
    15361568                                A8A47487151A825B004123FF /* WTFThreadData.h in Headers */,
    15371569                                CE73E02519DCB7AB00580D5C /* XPCSPI.h in Headers */,
     1570                                E43A46991E228B9100276B05 /* Coder.h in Headers */,
    15381571                        );
    15391572                        runOnlyForDeploymentPostprocessing = 0;
     
    16941727                                A8A4741A151A825B004123FF /* RefCountedLeakCounter.cpp in Sources */,
    16951728                                2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */,
     1729                                E43A46981E228B9100276B05 /* Encoder.cpp in Sources */,
    16961730                                2CDED0EF18115C38004DBA70 /* RunLoopCF.cpp in Sources */,
    16971731                                1469419316EAAF6D0024E146 /* RunLoopTimerCF.cpp in Sources */,
     1732                                E43A469D1E228FD500276B05 /* Coders.cpp in Sources */,
    16981733                                1469419916EAB0410024E146 /* SchedulePairCF.cpp in Sources */,
    16991734                                1469419716EAAFF80024E146 /* SchedulePairMac.mm in Sources */,
     
    17101745                                A5BA15F51824348000A82E69 /* StringImplMac.mm in Sources */,
    17111746                                A5BA15F3182433A900A82E69 /* StringMac.mm in Sources */,
     1747                                E43A46971E228B9100276B05 /* Decoder.cpp in Sources */,
    17121748                                0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */,
    17131749                                A8A47443151A825B004123FF /* StringStatics.cpp in Sources */,
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r209808 r210502  
    241241    dtoa/strtod.cc
    242242
     243    persistence/Coders.cpp
     244    persistence/Decoder.cpp
     245    persistence/Encoder.cpp
     246
    243247    text/AtomicString.cpp
    244248    text/AtomicStringImpl.cpp
     
    269273    "${WTF_DIR}/wtf"
    270274    "${WTF_DIR}/wtf/dtoa"
     275    "${WTF_DIR}/wtf/persistence"
    271276    "${WTF_DIR}/wtf/text"
    272277    "${WTF_DIR}/wtf/text/icu"
  • trunk/Source/WTF/wtf/persistence/Coder.h

    r210330 r210502  
    2424 */
    2525
    26 #ifndef NetworkCacheCoder_h
    27 #define NetworkCacheCoder_h
     26#pragma once
    2827
    29 #if ENABLE(NETWORK_CACHE)
    30 
    31 namespace WebKit {
    32 namespace NetworkCache {
     28namespace WTF {
     29namespace Persistence {
    3330
    3431class Decoder;
     
    4946}
    5047}
    51 
    52 #endif
    53 #endif
  • trunk/Source/WTF/wtf/persistence/Coders.cpp

    r210330 r210502  
    2525
    2626#include "config.h"
    27 #include "NetworkCacheCoders.h"
    28 
    29 #if ENABLE(NETWORK_CACHE)
     27#include "Coders.h"
    3028
    3129#include <wtf/text/CString.h>
    3230#include <wtf/text/WTFString.h>
    3331
    34 namespace WebKit {
    35 namespace NetworkCache {
     32namespace WTF {
     33namespace Persistence {
    3634
    3735void Coder<AtomicString>::encode(Encoder& encoder, const AtomicString& atomicString)
     
    145143}
    146144
    147 
    148145void Coder<SHA1::Digest>::encode(Encoder& encoder, const SHA1::Digest& digest)
    149146{
     
    156153}
    157154
    158 // Store common HTTP headers as strings instead of using their value in the HTTPHeaderName enumeration
    159 // so that the headers stored in the cache stays valid even after HTTPHeaderName.in gets updated.
    160 void Coder<WebCore::HTTPHeaderMap>::encode(Encoder& encoder, const WebCore::HTTPHeaderMap& headers)
    161 {
    162     encoder << static_cast<uint64_t>(headers.size());
    163     for (auto& keyValue : headers) {
    164         encoder << keyValue.key;
    165         encoder << keyValue.value;
    166     }
    167 }
    168 
    169 bool Coder<WebCore::HTTPHeaderMap>::decode(Decoder& decoder, WebCore::HTTPHeaderMap& headers)
    170 {
    171     uint64_t headersSize;
    172     if (!decoder.decode(headersSize))
    173         return false;
    174     for (uint64_t i = 0; i < headersSize; ++i) {
    175         String name;
    176         if (!decoder.decode(name))
    177             return false;
    178         String value;
    179         if (!decoder.decode(value))
    180             return false;
    181         headers.add(name, value);
    182     }
    183     return true;
    184 }
    185 
    186155}
    187156}
    188 
    189 #endif
  • trunk/Source/WTF/wtf/persistence/Coders.h

    r210330 r210502  
    2626#pragma once
    2727
    28 #if ENABLE(NETWORK_CACHE)
    29 
    30 #include "NetworkCacheDecoder.h"
    31 #include "NetworkCacheEncoder.h"
    32 #include <WebCore/CertificateInfo.h>
    33 #include <WebCore/HTTPHeaderMap.h>
    3428#include <utility>
    3529#include <wtf/Forward.h>
     
    3832#include <wtf/SHA1.h>
    3933#include <wtf/Vector.h>
    40 
    41 namespace WebKit {
    42 namespace NetworkCache {
     34#include <wtf/persistence/Decoder.h>
     35#include <wtf/persistence/Encoder.h>
     36
     37namespace WTF {
     38namespace Persistence {
    4339
    4440template<typename T, typename U> struct Coder<std::pair<T, U>> {
     
    267263
    268264template<> struct Coder<AtomicString> {
    269     static void encode(Encoder&, const AtomicString&);
    270     static bool decode(Decoder&, AtomicString&);
     265    WTF_EXPORT_PRIVATE static void encode(Encoder&, const AtomicString&);
     266    WTF_EXPORT_PRIVATE static bool decode(Decoder&, AtomicString&);
    271267};
    272268
    273269template<> struct Coder<CString> {
    274     static void encode(Encoder&, const CString&);
    275     static bool decode(Decoder&, CString&);
     270    WTF_EXPORT_PRIVATE static void encode(Encoder&, const CString&);
     271    WTF_EXPORT_PRIVATE static bool decode(Decoder&, CString&);
    276272};
    277273
    278274template<> struct Coder<String> {
    279     static void encode(Encoder&, const String&);
    280     static bool decode(Decoder&, String&);
    281 };
    282 
    283 template<> struct Coder<WebCore::CertificateInfo> {
    284     static void encode(Encoder&, const WebCore::CertificateInfo&);
    285     static bool decode(Decoder&, WebCore::CertificateInfo&);
     275    WTF_EXPORT_PRIVATE static void encode(Encoder&, const String&);
     276    WTF_EXPORT_PRIVATE static bool decode(Decoder&, String&);
    286277};
    287278
    288279template<> struct Coder<SHA1::Digest> {
    289     static void encode(Encoder&, const SHA1::Digest&);
    290     static bool decode(Decoder&, SHA1::Digest&);
    291 };
    292 
    293 template<> struct Coder<WebCore::HTTPHeaderMap> {
    294     static void encode(Encoder&, const WebCore::HTTPHeaderMap&);
    295     static bool decode(Decoder&, WebCore::HTTPHeaderMap&);
     280    WTF_EXPORT_PRIVATE static void encode(Encoder&, const SHA1::Digest&);
     281    WTF_EXPORT_PRIVATE static bool decode(Decoder&, SHA1::Digest&);
    296282};
    297283
    298284}
    299285}
    300 #endif
  • trunk/Source/WTF/wtf/persistence/Decoder.cpp

    r210330 r210502  
    2525
    2626#include "config.h"
    27 #include "NetworkCacheDecoder.h"
     27#include "Decoder.h"
    2828
    29 #if ENABLE(NETWORK_CACHE)
     29#include <wtf/persistence/Encoder.h>
    3030
    31 #include "NetworkCacheEncoder.h"
    32 
    33 namespace WebKit {
    34 namespace NetworkCache {
     31namespace WTF {
     32namespace Persistence {
    3533
    3634Decoder::Decoder(const uint8_t* buffer, size_t bufferSize)
     
    134132}
    135133}
    136 
    137 #endif
  • trunk/Source/WTF/wtf/persistence/Decoder.h

    r210330 r210502  
    2424 */
    2525
    26 #ifndef NetworkCacheDecoder_h
    27 #define NetworkCacheDecoder_h
     26#pragma once
    2827
    29 #if ENABLE(NETWORK_CACHE)
     28#include <wtf/SHA1.h>
     29#include <wtf/persistence/Coder.h>
    3030
    31 #include "NetworkCacheCoder.h"
    32 #include <wtf/SHA1.h>
    33 
    34 namespace WebKit {
    35 namespace NetworkCache {
     31namespace WTF {
     32namespace Persistence {
    3633
    3734class Decoder {
    3835    WTF_MAKE_FAST_ALLOCATED;
    3936public:
    40     Decoder(const uint8_t* buffer, size_t bufferSize);
    41     virtual ~Decoder();
     37    WTF_EXPORT_PRIVATE Decoder(const uint8_t* buffer, size_t bufferSize);
     38    WTF_EXPORT_PRIVATE ~Decoder();
    4239
    4340    size_t length() const { return m_bufferEnd - m_buffer; }
    4441    size_t currentOffset() const { return m_bufferPosition - m_buffer; }
    4542
    46     bool verifyChecksum();
     43    WTF_EXPORT_PRIVATE bool verifyChecksum();
    4744
    48     bool decodeFixedLengthData(uint8_t*, size_t);
     45    WTF_EXPORT_PRIVATE bool decodeFixedLengthData(uint8_t*, size_t);
    4946
    50     bool decode(bool&);
    51     bool decode(uint8_t&);
    52     bool decode(uint16_t&);
    53     bool decode(uint32_t&);
    54     bool decode(uint64_t&);
    55     bool decode(int32_t&);
    56     bool decode(int64_t&);
    57     bool decode(float&);
    58     bool decode(double&);
     47    WTF_EXPORT_PRIVATE bool decode(bool&);
     48    WTF_EXPORT_PRIVATE bool decode(uint8_t&);
     49    WTF_EXPORT_PRIVATE bool decode(uint16_t&);
     50    WTF_EXPORT_PRIVATE bool decode(uint32_t&);
     51    WTF_EXPORT_PRIVATE bool decode(uint64_t&);
     52    WTF_EXPORT_PRIVATE bool decode(int32_t&);
     53    WTF_EXPORT_PRIVATE bool decode(int64_t&);
     54    WTF_EXPORT_PRIVATE bool decode(float&);
     55    WTF_EXPORT_PRIVATE bool decode(double&);
    5956
    6057    template<typename T> bool decodeEnum(T& result)
     
    8986
    9087private:
    91     bool bufferIsLargeEnoughToContain(size_t) const;
     88    WTF_EXPORT_PRIVATE bool bufferIsLargeEnoughToContain(size_t) const;
    9289    template<typename Type> bool decodeNumber(Type&);
    9390
     
    10299}
    103100
    104 #endif
    105 #endif
  • trunk/Source/WTF/wtf/persistence/Encoder.cpp

    r210330 r210502  
    2525
    2626#include "config.h"
    27 #include "NetworkCacheEncoder.h"
     27#include "Encoder.h"
    2828
    29 #if ENABLE(NETWORK_CACHE)
     29#include "SHA1.h"
    3030
    31 namespace WebKit {
    32 namespace NetworkCache {
     31namespace WTF {
     32namespace Persistence {
    3333
    3434Encoder::Encoder()
     
    125125}
    126126}
    127 
    128 #endif
  • trunk/Source/WTF/wtf/persistence/Encoder.h

    r210330 r210502  
    2424 */
    2525
    26 #ifndef NetworkCacheEncoder_h
    27 #define NetworkCacheEncoder_h
     26#pragma once
    2827
    29 #if ENABLE(NETWORK_CACHE)
    30 
    31 #include "NetworkCacheCoder.h"
    3228#include <wtf/SHA1.h>
    3329#include <wtf/Vector.h>
     30#include <wtf/persistence/Coder.h>
    3431
    35 namespace WebKit {
    36 namespace NetworkCache {
     32namespace WTF {
     33namespace Persistence {
    3734
    3835class Encoder;
     
    4239    WTF_MAKE_FAST_ALLOCATED;
    4340public:
    44     Encoder();
    45     virtual ~Encoder();
     41    WTF_EXPORT_PRIVATE Encoder();
     42    WTF_EXPORT_PRIVATE ~Encoder();
    4643
    47     void encodeChecksum();
    48     void encodeFixedLengthData(const uint8_t*, size_t);
     44    WTF_EXPORT_PRIVATE void encodeChecksum();
     45    WTF_EXPORT_PRIVATE void encodeFixedLengthData(const uint8_t*, size_t);
    4946
    5047    template<typename T> void encodeEnum(T t)
     
    6966    size_t bufferSize() const { return m_buffer.size(); }
    7067
    71     static void updateChecksumForData(SHA1&, const uint8_t*, size_t);
     68    WTF_EXPORT_PRIVATE static void updateChecksumForData(SHA1&, const uint8_t*, size_t);
    7269    template <typename Type> static void updateChecksumForNumber(SHA1&, Type);
    7370
     
    7572
    7673private:
    77     void encode(bool);
    78     void encode(uint8_t);
    79     void encode(uint16_t);
    80     void encode(uint32_t);
    81     void encode(uint64_t);
    82     void encode(int32_t);
    83     void encode(int64_t);
    84     void encode(float);
    85     void encode(double);
     74    WTF_EXPORT_PRIVATE void encode(bool);
     75    WTF_EXPORT_PRIVATE void encode(uint8_t);
     76    WTF_EXPORT_PRIVATE void encode(uint16_t);
     77    WTF_EXPORT_PRIVATE void encode(uint32_t);
     78    WTF_EXPORT_PRIVATE void encode(uint64_t);
     79    WTF_EXPORT_PRIVATE void encode(int32_t);
     80    WTF_EXPORT_PRIVATE void encode(int64_t);
     81    WTF_EXPORT_PRIVATE void encode(float);
     82    WTF_EXPORT_PRIVATE void encode(double);
    8683
    8784    template<typename Type> void encodeNumber(Type);
     
    116113}
    117114}
    118 
    119 #endif
    120 #endif
  • trunk/Source/WebKit2/CMakeLists.txt

    r210374 r210502  
    111111    NetworkProcess/cache/NetworkCacheCoders.cpp
    112112    NetworkProcess/cache/NetworkCacheData.cpp
    113     NetworkProcess/cache/NetworkCacheDecoder.cpp
    114     NetworkProcess/cache/NetworkCacheEncoder.cpp
    115113    NetworkProcess/cache/NetworkCacheEntry.cpp
    116114    NetworkProcess/cache/NetworkCacheFileSystem.cpp
  • trunk/Source/WebKit2/ChangeLog

    r210500 r210502  
     12017-01-08  Antti Koivisto  <antti@apple.com>
     2
     3        Move cache coders to WTF
     4        https://bugs.webkit.org/show_bug.cgi?id=166825
     5
     6        Rubber-stamped by Sam Weinig.
     7
     8        * NetworkProcess/cache/NetworkCache.h:
     9        * NetworkProcess/cache/NetworkCacheCoder.h: Removed.
     10        * NetworkProcess/cache/NetworkCacheCoders.cpp:
     11        (WebKit::NetworkCache::Coder<AtomicString>::encode): Deleted.
     12        (WebKit::NetworkCache::Coder<AtomicString>::decode): Deleted.
     13        (WebKit::NetworkCache::Coder<CString>::encode): Deleted.
     14        (WebKit::NetworkCache::Coder<CString>::decode): Deleted.
     15        (WebKit::NetworkCache::Coder<String>::encode): Deleted.
     16        (WebKit::NetworkCache::decodeStringText): Deleted.
     17        (WebKit::NetworkCache::Coder<String>::decode): Deleted.
     18        (WebKit::NetworkCache::Coder<SHA1::Digest>::encode): Deleted.
     19        (WebKit::NetworkCache::Coder<SHA1::Digest>::decode): Deleted.
     20        (WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::encode): Deleted.
     21        (WebKit::NetworkCache::Coder<WebCore::HTTPHeaderMap>::decode): Deleted.
     22        * NetworkProcess/cache/NetworkCacheCoders.h:
     23        (): Deleted.
     24        (WebKit::NetworkCache::Coder<std::optional<T>>::encode): Deleted.
     25        (WebKit::NetworkCache::Coder<std::optional<T>>::decode): Deleted.
     26        * NetworkProcess/cache/NetworkCacheCodersCocoa.cpp:
     27        (WebKit::NetworkCache::encodeCFData): Deleted.
     28        (WebKit::NetworkCache::decodeCFData): Deleted.
     29        (WebKit::NetworkCache::encodeSecTrustRef): Deleted.
     30        (WebKit::NetworkCache::decodeSecTrustRef): Deleted.
     31        (WebKit::NetworkCache::encodeCertificateChain): Deleted.
     32        (WebKit::NetworkCache::decodeCertificateChain): Deleted.
     33        (WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::encode): Deleted.
     34        (WebKit::NetworkCache::Coder<WebCore::CertificateInfo>::decode): Deleted.
     35        * NetworkProcess/cache/NetworkCacheDecoder.cpp: Removed.
     36        * NetworkProcess/cache/NetworkCacheDecoder.h: Removed.
     37        * NetworkProcess/cache/NetworkCacheEncoder.cpp: Removed.
     38        * NetworkProcess/cache/NetworkCacheEncoder.h: Removed.
     39        * NetworkProcess/cache/NetworkCacheEntry.cpp:
     40        (WebKit::NetworkCache::Entry::encodeAsStorageRecord):
     41        (WebKit::NetworkCache::Entry::decodeStorageRecord):
     42        * NetworkProcess/cache/NetworkCacheKey.cpp:
     43        (WebKit::NetworkCache::Key::encode):
     44        (WebKit::NetworkCache::Key::decode):
     45        * NetworkProcess/cache/NetworkCacheKey.h:
     46        * NetworkProcess/cache/NetworkCacheStorage.cpp:
     47        (WebKit::NetworkCache::decodeRecordMetaData):
     48        (WebKit::NetworkCache::encodeRecordMetaData):
     49        * NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp:
     50        (WebKit::NetworkCache::SubresourceInfo::encode):
     51        (WebKit::NetworkCache::SubresourceInfo::decode):
     52        (WebKit::NetworkCache::SubresourcesEntry::encodeAsStorageRecord):
     53        (WebKit::NetworkCache::SubresourcesEntry::decodeStorageRecord):
     54        * NetworkProcess/cache/NetworkCacheSubresourcesEntry.h:
     55        * UIProcess/API/APIUserContentExtensionStore.cpp:
     56        (API::encodeContentExtensionMetaData):
     57        (API::decodeContentExtensionMetaData):
     58        * WebKit2.xcodeproj/project.pbxproj:
     59
    1602017-01-09  Tomas Popela  <tpopela@redhat.com>
    261
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.cpp

    r203691 r210502  
    2929#if ENABLE(NETWORK_CACHE)
    3030
    31 #include <wtf/text/CString.h>
    32 #include <wtf/text/WTFString.h>
    33 
    34 namespace WebKit {
    35 namespace NetworkCache {
    36 
    37 void Coder<AtomicString>::encode(Encoder& encoder, const AtomicString& atomicString)
    38 {
    39     encoder << atomicString.string();
    40 }
    41 
    42 bool Coder<AtomicString>::decode(Decoder& decoder, AtomicString& atomicString)
    43 {
    44     String string;
    45     if (!decoder.decode(string))
    46         return false;
    47 
    48     atomicString = string;
    49     return true;
    50 }
    51 
    52 void Coder<CString>::encode(Encoder& encoder, const CString& string)
    53 {
    54     // Special case the null string.
    55     if (string.isNull()) {
    56         encoder << std::numeric_limits<uint32_t>::max();
    57         return;
    58     }
    59 
    60     uint32_t length = string.length();
    61     encoder << length;
    62     encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length);
    63 }
    64 
    65 bool Coder<CString>::decode(Decoder& decoder, CString& result)
    66 {
    67     uint32_t length;
    68     if (!decoder.decode(length))
    69         return false;
    70 
    71     if (length == std::numeric_limits<uint32_t>::max()) {
    72         // This is the null string.
    73         result = CString();
    74         return true;
    75     }
    76 
    77     // Before allocating the string, make sure that the decoder buffer is big enough.
    78     if (!decoder.bufferIsLargeEnoughToContain<char>(length))
    79         return false;
    80 
    81     char* buffer;
    82     CString string = CString::newUninitialized(length, buffer);
    83     if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length))
    84         return false;
    85 
    86     result = string;
    87     return true;
    88 }
    89 
    90 
    91 void Coder<String>::encode(Encoder& encoder, const String& string)
    92 {
    93     // Special case the null string.
    94     if (string.isNull()) {
    95         encoder << std::numeric_limits<uint32_t>::max();
    96         return;
    97     }
    98 
    99     uint32_t length = string.length();
    100     bool is8Bit = string.is8Bit();
    101 
    102     encoder << length << is8Bit;
    103 
    104     if (is8Bit)
    105         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters8()), length * sizeof(LChar));
    106     else
    107         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters16()), length * sizeof(UChar));
    108 }
    109 
    110 template <typename CharacterType>
    111 static inline bool decodeStringText(Decoder& decoder, uint32_t length, String& result)
    112 {
    113     // Before allocating the string, make sure that the decoder buffer is big enough.
    114     if (!decoder.bufferIsLargeEnoughToContain<CharacterType>(length))
    115         return false;
    116 
    117     CharacterType* buffer;
    118     String string = String::createUninitialized(length, buffer);
    119     if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer), length * sizeof(CharacterType)))
    120         return false;
    121    
    122     result = string;
    123     return true;   
    124 }
    125 
    126 bool Coder<String>::decode(Decoder& decoder, String& result)
    127 {
    128     uint32_t length;
    129     if (!decoder.decode(length))
    130         return false;
    131 
    132     if (length == std::numeric_limits<uint32_t>::max()) {
    133         // This is the null string.
    134         result = String();
    135         return true;
    136     }
    137 
    138     bool is8Bit;
    139     if (!decoder.decode(is8Bit))
    140         return false;
    141 
    142     if (is8Bit)
    143         return decodeStringText<LChar>(decoder, length, result);
    144     return decodeStringText<UChar>(decoder, length, result);
    145 }
    146 
    147 
    148 void Coder<SHA1::Digest>::encode(Encoder& encoder, const SHA1::Digest& digest)
    149 {
    150     encoder.encodeFixedLengthData(digest.data(), sizeof(digest));
    151 }
    152 
    153 bool Coder<SHA1::Digest>::decode(Decoder& decoder, SHA1::Digest& digest)
    154 {
    155     return decoder.decodeFixedLengthData(digest.data(), sizeof(digest));
    156 }
     31namespace WTF {
     32namespace Persistence {
    15733
    15834// Store common HTTP headers as strings instead of using their value in the HTTPHeaderName enumeration
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCoders.h

    r208985 r210502  
    2828#if ENABLE(NETWORK_CACHE)
    2929
    30 #include "NetworkCacheDecoder.h"
    31 #include "NetworkCacheEncoder.h"
    3230#include <WebCore/CertificateInfo.h>
    3331#include <WebCore/HTTPHeaderMap.h>
     
    3836#include <wtf/SHA1.h>
    3937#include <wtf/Vector.h>
     38#include <wtf/persistence/Coders.h>
     39#include <wtf/persistence/Decoder.h>
     40#include <wtf/persistence/Encoder.h>
    4041
    41 namespace WebKit {
    42 namespace NetworkCache {
    43 
    44 template<typename T, typename U> struct Coder<std::pair<T, U>> {
    45     static void encode(Encoder& encoder, const std::pair<T, U>& pair)
    46     {
    47         encoder << pair.first << pair.second;
    48     }
    49 
    50     static bool decode(Decoder& decoder, std::pair<T, U>& pair)
    51     {
    52         T first;
    53         if (!decoder.decode(first))
    54             return false;
    55 
    56         U second;
    57         if (!decoder.decode(second))
    58             return false;
    59 
    60         pair.first = first;
    61         pair.second = second;
    62         return true;
    63     }
    64 };
    65 
    66 template<typename Rep, typename Period> struct Coder<std::chrono::duration<Rep, Period>> {
    67     static void encode(Encoder& encoder, const std::chrono::duration<Rep, Period>& duration)
    68     {
    69         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.");
    70         encoder << static_cast<int64_t>(duration.count());
    71     }
    72 
    73     static bool decode(Decoder& decoder, std::chrono::duration<Rep, Period>& result)
    74     {
    75         int64_t count;
    76         if (!decoder.decode(count))
    77             return false;
    78         result = std::chrono::duration<Rep, Period>(static_cast<Rep>(count));
    79         return true;
    80     }
    81 };
    82 
    83 template<typename T> struct Coder<std::optional<T>> {
    84     static void encode(Encoder& encoder, const std::optional<T>& optional)
    85     {
    86         if (!optional) {
    87             encoder << false;
    88             return;
    89         }
    90        
    91         encoder << true;
    92         encoder << optional.value();
    93     }
    94    
    95     static bool decode(Decoder& decoder, std::optional<T>& optional)
    96     {
    97         bool isEngaged;
    98         if (!decoder.decode(isEngaged))
    99             return false;
    100        
    101         if (!isEngaged) {
    102             optional = std::nullopt;
    103             return true;
    104         }
    105        
    106         T value;
    107         if (!decoder.decode(value))
    108             return false;
    109        
    110         optional = WTFMove(value);
    111         return true;
    112     }
    113 };
    114 
    115 template<typename KeyType, typename ValueType> struct Coder<WTF::KeyValuePair<KeyType, ValueType>> {
    116     static void encode(Encoder& encoder, const WTF::KeyValuePair<KeyType, ValueType>& pair)
    117     {
    118         encoder << pair.key << pair.value;
    119     }
    120 
    121     static bool decode(Decoder& decoder, WTF::KeyValuePair<KeyType, ValueType>& pair)
    122     {
    123         KeyType key;
    124         if (!decoder.decode(key))
    125             return false;
    126 
    127         ValueType value;
    128         if (!decoder.decode(value))
    129             return false;
    130 
    131         pair.key = key;
    132         pair.value = value;
    133         return true;
    134     }
    135 };
    136 
    137 template<bool fixedSizeElements, typename T, size_t inlineCapacity> struct VectorCoder;
    138 
    139 template<typename T, size_t inlineCapacity> struct VectorCoder<false, T, inlineCapacity> {
    140     static void encode(Encoder& encoder, const Vector<T, inlineCapacity>& vector)
    141     {
    142         encoder << static_cast<uint64_t>(vector.size());
    143         for (size_t i = 0; i < vector.size(); ++i)
    144             encoder << vector[i];
    145     }
    146 
    147     static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
    148     {
    149         uint64_t size;
    150         if (!decoder.decode(size))
    151             return false;
    152 
    153         Vector<T, inlineCapacity> tmp;
    154         for (size_t i = 0; i < size; ++i) {
    155             T element;
    156             if (!decoder.decode(element))
    157                 return false;
    158            
    159             tmp.append(WTFMove(element));
    160         }
    161 
    162         tmp.shrinkToFit();
    163         vector.swap(tmp);
    164         return true;
    165     }
    166 };
    167 
    168 template<typename T, size_t inlineCapacity> struct VectorCoder<true, T, inlineCapacity> {
    169     static void encode(Encoder& encoder, const Vector<T, inlineCapacity>& vector)
    170     {
    171         encoder << static_cast<uint64_t>(vector.size());
    172         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(vector.data()), vector.size() * sizeof(T), alignof(T));
    173     }
    174    
    175     static bool decode(Decoder& decoder, Vector<T, inlineCapacity>& vector)
    176     {
    177         uint64_t size;
    178         if (!decoder.decode(size))
    179             return false;
    180 
    181         // Since we know the total size of the elements, we can allocate the vector in
    182         // one fell swoop. Before allocating we must however make sure that the decoder buffer
    183         // is big enough.
    184         if (!decoder.bufferIsLargeEnoughToContain<T>(size))
    185             return false;
    186 
    187         Vector<T, inlineCapacity> temp;
    188         temp.resize(size);
    189 
    190         decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(temp.data()), size * sizeof(T));
    191 
    192         vector.swap(temp);
    193         return true;
    194     }
    195 };
    196 
    197 template<typename T, size_t inlineCapacity> struct Coder<Vector<T, inlineCapacity>> : VectorCoder<std::is_arithmetic<T>::value, T, inlineCapacity> { };
    198 
    199 template<typename KeyArg, typename MappedArg, typename HashArg, typename KeyTraitsArg, typename MappedTraitsArg> struct Coder<HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg>> {
    200     typedef HashMap<KeyArg, MappedArg, HashArg, KeyTraitsArg, MappedTraitsArg> HashMapType;
    201 
    202     static void encode(Encoder& encoder, const HashMapType& hashMap)
    203     {
    204         encoder << static_cast<uint64_t>(hashMap.size());
    205         for (typename HashMapType::const_iterator it = hashMap.begin(), end = hashMap.end(); it != end; ++it)
    206             encoder << *it;
    207     }
    208 
    209     static bool decode(Decoder& decoder, HashMapType& hashMap)
    210     {
    211         uint64_t hashMapSize;
    212         if (!decoder.decode(hashMapSize))
    213             return false;
    214 
    215         HashMapType tempHashMap;
    216         for (uint64_t i = 0; i < hashMapSize; ++i) {
    217             KeyArg key;
    218             MappedArg value;
    219             if (!decoder.decode(key))
    220                 return false;
    221             if (!decoder.decode(value))
    222                 return false;
    223 
    224             if (!tempHashMap.add(key, value).isNewEntry) {
    225                 // The hash map already has the specified key, bail.
    226                 return false;
    227             }
    228         }
    229 
    230         hashMap.swap(tempHashMap);
    231         return true;
    232     }
    233 };
    234 
    235 template<typename KeyArg, typename HashArg, typename KeyTraitsArg> struct Coder<HashSet<KeyArg, HashArg, KeyTraitsArg>> {
    236     typedef HashSet<KeyArg, HashArg, KeyTraitsArg> HashSetType;
    237 
    238     static void encode(Encoder& encoder, const HashSetType& hashSet)
    239     {
    240         encoder << static_cast<uint64_t>(hashSet.size());
    241         for (typename HashSetType::const_iterator it = hashSet.begin(), end = hashSet.end(); it != end; ++it)
    242             encoder << *it;
    243     }
    244 
    245     static bool decode(Decoder& decoder, HashSetType& hashSet)
    246     {
    247         uint64_t hashSetSize;
    248         if (!decoder.decode(hashSetSize))
    249             return false;
    250 
    251         HashSetType tempHashSet;
    252         for (uint64_t i = 0; i < hashSetSize; ++i) {
    253             KeyArg key;
    254             if (!decoder.decode(key))
    255                 return false;
    256 
    257             if (!tempHashSet.add(key).isNewEntry) {
    258                 // The hash map already has the specified key, bail.
    259                 return false;
    260             }
    261         }
    262 
    263         hashSet.swap(tempHashSet);
    264         return true;
    265     }
    266 };
    267 
    268 template<> struct Coder<AtomicString> {
    269     static void encode(Encoder&, const AtomicString&);
    270     static bool decode(Decoder&, AtomicString&);
    271 };
    272 
    273 template<> struct Coder<CString> {
    274     static void encode(Encoder&, const CString&);
    275     static bool decode(Decoder&, CString&);
    276 };
    277 
    278 template<> struct Coder<String> {
    279     static void encode(Encoder&, const String&);
    280     static bool decode(Decoder&, String&);
    281 };
     42namespace WTF {
     43namespace Persistence {
    28244
    28345template<> struct Coder<WebCore::CertificateInfo> {
    28446    static void encode(Encoder&, const WebCore::CertificateInfo&);
    28547    static bool decode(Decoder&, WebCore::CertificateInfo&);
    286 };
    287 
    288 template<> struct Coder<SHA1::Digest> {
    289     static void encode(Encoder&, const SHA1::Digest&);
    290     static bool decode(Decoder&, SHA1::Digest&);
    29148};
    29249
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCodersCocoa.cpp

    r203692 r210502  
    3535#endif
    3636
    37 namespace WebKit {
    38 namespace NetworkCache {
     37namespace WTF {
     38namespace Persistence {
    3939
    4040static void encodeCFData(Encoder& encoder, CFDataRef data)
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheCodersSoup.cpp

    r203691 r210502  
    2929#if ENABLE(NETWORK_CACHE)
    3030
    31 namespace WebKit {
    32 namespace NetworkCache {
     31namespace WTF {
     32namespace Persistence {
    3333
    3434void Coder<WebCore::CertificateInfo>::encode(Encoder& encoder, const WebCore::CertificateInfo& certificateInfo)
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheEntry.cpp

    r202357 r210502  
    2929#include "Logging.h"
    3030#include "NetworkCacheCoders.h"
    31 #include "NetworkCacheDecoder.h"
    32 #include "NetworkCacheEncoder.h"
    3331#include <WebCore/ResourceRequest.h>
    3432#include <WebCore/SharedBuffer.h>
     
    8482Storage::Record Entry::encodeAsStorageRecord() const
    8583{
    86     Encoder encoder;
     84    WTF::Persistence::Encoder encoder;
    8785    encoder << m_response;
    8886
     
    111109    auto entry = std::make_unique<Entry>(storageEntry);
    112110
    113     Decoder decoder(storageEntry.header.data(), storageEntry.header.size());
     111    WTF::Persistence::Decoder decoder(storageEntry.header.data(), storageEntry.header.size());
    114112    if (!decoder.decode(entry->m_response))
    115113        return nullptr;
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp

    r209554 r210502  
    3232#include <wtf/ASCIICType.h>
    3333#include <wtf/NeverDestroyed.h>
     34#include <wtf/persistence/Decoder.h>
     35#include <wtf/persistence/Encoder.h>
    3436#include <wtf/text/CString.h>
    3537#include <wtf/text/StringBuilder.h>
     
    156158}
    157159
    158 void Key::encode(Encoder& encoder) const
     160void Key::encode(WTF::Persistence::Encoder& encoder) const
    159161{
    160162    encoder << m_partition;
     
    166168}
    167169
    168 bool Key::decode(Decoder& decoder, Key& key)
     170bool Key::decode(WTF::Persistence::Decoder& decoder, Key& key)
    169171{
    170172    return decoder.decode(key.m_partition) && decoder.decode(key.m_type) && decoder.decode(key.m_identifier) && decoder.decode(key.m_range) && decoder.decode(key.m_hash) && decoder.decode(key.m_partitionHash);
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h

    r209554 r210502  
    3131#include "NetworkCacheData.h"
    3232#include <wtf/SHA1.h>
     33#include <wtf/persistence/Coder.h>
    3334#include <wtf/text/WTFString.h>
    3435
    3536namespace WebKit {
    3637namespace NetworkCache {
    37 
    38 class Encoder;
    39 class Decoder;
    4038
    4139class Key {
     
    7068    String partitionHashAsString() const { return hashAsString(m_partitionHash); }
    7169
    72     void encode(Encoder&) const;
    73     static bool decode(Decoder&, Key&);
     70    void encode(WTF::Persistence::Encoder&) const;
     71    static bool decode(WTF::Persistence::Decoder&, Key&);
    7472
    7573    bool operator==(const Key&) const;
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp

    r210364 r210502  
    381381    bool success = false;
    382382    fileData.apply([&metaData, &success](const uint8_t* data, size_t size) {
    383         Decoder decoder(data, size);
     383        WTF::Persistence::Decoder decoder(data, size);
    384384        if (!decoder.decode(metaData.cacheStorageVersion))
    385385            return false;
     
    465465static Data encodeRecordMetaData(const RecordMetaData& metaData)
    466466{
    467     Encoder encoder;
     467    WTF::Persistence::Encoder encoder;
    468468
    469469    encoder << metaData.cacheStorageVersion;
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.cpp

    r202148 r210502  
    3131#include "Logging.h"
    3232#include "NetworkCacheCoders.h"
    33 #include "NetworkCacheDecoder.h"
    34 #include "NetworkCacheEncoder.h"
    3533
    3634namespace WebKit {
    3735namespace NetworkCache {
    3836
    39 void SubresourceInfo::encode(Encoder& encoder) const
     37void SubresourceInfo::encode(WTF::Persistence::Encoder& encoder) const
    4038{
    4139    encoder << m_isTransient;
     
    4947}
    5048
    51 bool SubresourceInfo::decode(Decoder& decoder, SubresourceInfo& info)
     49bool SubresourceInfo::decode(WTF::Persistence::Decoder& decoder, SubresourceInfo& info)
    5250{
    5351    if (!decoder.decode(info.m_isTransient))
     
    6866Storage::Record SubresourcesEntry::encodeAsStorageRecord() const
    6967{
    70     Encoder encoder;
     68    WTF::Persistence::Encoder encoder;
    7169    encoder << m_subresources;
    7270
     
    8078    auto entry = std::make_unique<SubresourcesEntry>(storageEntry);
    8179
    82     Decoder decoder(storageEntry.header.data(), storageEntry.header.size());
     80    WTF::Persistence::Decoder decoder(storageEntry.header.data(), storageEntry.header.size());
    8381    if (!decoder.decode(entry->m_subresources))
    8482        return nullptr;
  • trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheSubresourcesEntry.h

    r202148 r210502  
    2929#if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
    3030
    31 #include "NetworkCacheDecoder.h"
    32 #include "NetworkCacheEncoder.h"
    3331#include "NetworkCacheStorage.h"
    3432#include <WebCore/ResourceRequest.h>
     
    4240    WTF_MAKE_FAST_ALLOCATED;
    4341public:
    44     void encode(Encoder&) const;
    45     static bool decode(Decoder&, SubresourceInfo&);
     42    void encode(WTF::Persistence::Encoder&) const;
     43    static bool decode(WTF::Persistence::Decoder&, SubresourceInfo&);
    4644
    4745    SubresourceInfo() = default;
  • trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp

    r203303 r210502  
    3131#include "APIUserContentExtension.h"
    3232#include "NetworkCacheData.h"
    33 #include "NetworkCacheDecoder.h"
    34 #include "NetworkCacheEncoder.h"
    3533#include "NetworkCacheFileSystem.h"
    3634#include "SharedMemory.h"
     
    4240#include <wtf/RunLoop.h>
    4341#include <wtf/WorkQueue.h>
     42#include <wtf/persistence/Decoder.h>
     43#include <wtf/persistence/Encoder.h>
    4444
    4545using namespace WebKit::NetworkCache;
     
    100100static Data encodeContentExtensionMetaData(const ContentExtensionMetaData& metaData)
    101101{
    102     WebKit::NetworkCache::Encoder encoder;
     102    WTF::Persistence::Encoder encoder;
    103103
    104104    encoder << metaData.version;
     
    121121            return false;
    122122
    123         WebKit::NetworkCache::Decoder decoder(data, size);
     123        WTF::Persistence::Decoder decoder(data, size);
    124124        if (!decoder.decode(metaData.version))
    125125            return false;
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r210374 r210502  
    18941894                E4697CCD1B25EB8F001B0A6C /* NetworkCacheFileSystem.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E4697CCC1B25EB8F001B0A6C /* NetworkCacheFileSystem.cpp */; };
    18951895                E47D1E981B0649FB002676A8 /* NetworkCacheData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E47D1E961B062B66002676A8 /* NetworkCacheData.cpp */; };
    1896                 E489D28A1A0A2DB80078C06A /* NetworkCacheCoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E489D2831A0A2DB80078C06A /* NetworkCacheCoder.h */; };
    18971896                E489D28B1A0A2DB80078C06A /* NetworkCacheCoders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E489D2841A0A2DB80078C06A /* NetworkCacheCoders.cpp */; };
    18981897                E489D28C1A0A2DB80078C06A /* NetworkCacheCoders.h in Headers */ = {isa = PBXBuildFile; fileRef = E489D2851A0A2DB80078C06A /* NetworkCacheCoders.h */; };
    1899                 E489D28D1A0A2DB80078C06A /* NetworkCacheDecoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E489D2861A0A2DB80078C06A /* NetworkCacheDecoder.cpp */; };
    1900                 E489D28E1A0A2DB80078C06A /* NetworkCacheDecoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E489D2871A0A2DB80078C06A /* NetworkCacheDecoder.h */; };
    1901                 E489D28F1A0A2DB80078C06A /* NetworkCacheEncoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E489D2881A0A2DB80078C06A /* NetworkCacheEncoder.cpp */; };
    1902                 E489D2901A0A2DB80078C06A /* NetworkCacheEncoder.h in Headers */ = {isa = PBXBuildFile; fileRef = E489D2891A0A2DB80078C06A /* NetworkCacheEncoder.h */; };
    19031898                E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = E49D40D61AD3FB170066B7B9 /* NetworkCacheBlobStorage.h */; };
    19041899                E49D40D91AD3FB210066B7B9 /* NetworkCacheBlobStorage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E49D40D81AD3FB210066B7B9 /* NetworkCacheBlobStorage.cpp */; };
     
    41014096                E4697CCC1B25EB8F001B0A6C /* NetworkCacheFileSystem.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheFileSystem.cpp; sourceTree = "<group>"; };
    41024097                E47D1E961B062B66002676A8 /* NetworkCacheData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheData.cpp; sourceTree = "<group>"; };
    4103                 E489D2831A0A2DB80078C06A /* NetworkCacheCoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheCoder.h; sourceTree = "<group>"; };
    41044098                E489D2841A0A2DB80078C06A /* NetworkCacheCoders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheCoders.cpp; sourceTree = "<group>"; };
    41054099                E489D2851A0A2DB80078C06A /* NetworkCacheCoders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheCoders.h; sourceTree = "<group>"; };
    4106                 E489D2861A0A2DB80078C06A /* NetworkCacheDecoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheDecoder.cpp; sourceTree = "<group>"; };
    4107                 E489D2871A0A2DB80078C06A /* NetworkCacheDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheDecoder.h; sourceTree = "<group>"; };
    4108                 E489D2881A0A2DB80078C06A /* NetworkCacheEncoder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheEncoder.cpp; sourceTree = "<group>"; };
    4109                 E489D2891A0A2DB80078C06A /* NetworkCacheEncoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheEncoder.h; sourceTree = "<group>"; };
    41104100                E49D40D61AD3FB170066B7B9 /* NetworkCacheBlobStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkCacheBlobStorage.h; sourceTree = "<group>"; };
    41114101                E49D40D81AD3FB210066B7B9 /* NetworkCacheBlobStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkCacheBlobStorage.cpp; sourceTree = "<group>"; };
     
    75707560                                E49D40D81AD3FB210066B7B9 /* NetworkCacheBlobStorage.cpp */,
    75717561                                E49D40D61AD3FB170066B7B9 /* NetworkCacheBlobStorage.h */,
    7572                                 E489D2831A0A2DB80078C06A /* NetworkCacheCoder.h */,
    75737562                                E489D2841A0A2DB80078C06A /* NetworkCacheCoders.cpp */,
    75747563                                E489D2851A0A2DB80078C06A /* NetworkCacheCoders.h */,
     
    75777566                                E42E06111AA75ABD00B11699 /* NetworkCacheData.h */,
    75787567                                E42E06131AA75B7000B11699 /* NetworkCacheDataCocoa.mm */,
    7579                                 E489D2861A0A2DB80078C06A /* NetworkCacheDecoder.cpp */,
    7580                                 E489D2871A0A2DB80078C06A /* NetworkCacheDecoder.h */,
    7581                                 E489D2881A0A2DB80078C06A /* NetworkCacheEncoder.cpp */,
    7582                                 E489D2891A0A2DB80078C06A /* NetworkCacheEncoder.h */,
    75837568                                E413F59E1AC1AF9D00345360 /* NetworkCacheEntry.cpp */,
    75847569                                E413F59B1AC1ADB600345360 /* NetworkCacheEntry.h */,
     
    79047889                                E4436ECC1A0D040B00EAD204 /* NetworkCache.h in Headers */,
    79057890                                E49D40D71AD3FB170066B7B9 /* NetworkCacheBlobStorage.h in Headers */,
    7906                                 E489D28A1A0A2DB80078C06A /* NetworkCacheCoder.h in Headers */,
    79077891                                E489D28C1A0A2DB80078C06A /* NetworkCacheCoders.h in Headers */,
    79087892                                E42E06121AA75ABD00B11699 /* NetworkCacheData.h in Headers */,
    7909                                 E489D28E1A0A2DB80078C06A /* NetworkCacheDecoder.h in Headers */,
    7910                                 E489D2901A0A2DB80078C06A /* NetworkCacheEncoder.h in Headers */,
    79117893                                E413F59D1AC1ADC400345360 /* NetworkCacheEntry.h in Headers */,
    79127894                                834B250F1A831A8D00CFB150 /* NetworkCacheFileSystem.h in Headers */,
     
    94089390                                E47D1E981B0649FB002676A8 /* NetworkCacheData.cpp in Sources */,
    94099391                                E42E06141AA75B7000B11699 /* NetworkCacheDataCocoa.mm in Sources */,
    9410                                 E489D28D1A0A2DB80078C06A /* NetworkCacheDecoder.cpp in Sources */,
    9411                                 E489D28F1A0A2DB80078C06A /* NetworkCacheEncoder.cpp in Sources */,
    94129392                                E413F59F1AC1AF9D00345360 /* NetworkCacheEntry.cpp in Sources */,
    94139393                                E4697CCD1B25EB8F001B0A6C /* NetworkCacheFileSystem.cpp in Sources */,
Note: See TracChangeset for help on using the changeset viewer.