Changeset 191377 in webkit
- Timestamp:
- Oct 20, 2015 11:41:13 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r191368 r191377 1 2015-10-20 Chris Dumez <cdumez@apple.com> 2 3 [WK2] Generalize NetworkCacheStorage API so it can store different types of metadata 4 https://bugs.webkit.org/show_bug.cgi?id=150221 5 <rdar://problem/23149771> 6 7 Reviewed by Darin Adler and Antti Koivisto. 8 9 Generalize NetworkCacheStorage API so it can store different types of 10 metadata alongside the network resources. This is a pre-requirement to 11 making our NetworkCache smarter by storing information about the 12 resources. 13 14 To keep the code simple, the entry type is now part of the entry key and 15 we store records of a specific type in a 'type' subfolder. The cache 16 structure looks like so: 17 - WebKitCache/Version 5/[Partition]/[Type]/[Hash] 18 - WebKitCache/Version 5/[Partition]/[Type]/[Hash]-blob (Optional) 19 20 Existing cache entries now that the 'resource' type as these are network 21 resources. 22 23 * NetworkProcess/cache/NetworkCache.cpp: 24 * NetworkProcess/cache/NetworkCacheKey.cpp: 25 * NetworkProcess/cache/NetworkCacheKey.h: 26 * NetworkProcess/cache/NetworkCacheStatistics.cpp: 27 * NetworkProcess/cache/NetworkCacheStorage.cpp: 28 * NetworkProcess/cache/NetworkCacheStorage.h: 29 1 30 2015-10-20 Hunseop Jeong <hs85.jeong@samsung.com> 2 31 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
r191354 r191377 40 40 #include <WebCore/ResourceResponse.h> 41 41 #include <WebCore/SharedBuffer.h> 42 #include <wtf/MainThread.h> 42 43 #include <wtf/NeverDestroyed.h> 43 44 #include <wtf/RunLoop.h> … … 50 51 namespace WebKit { 51 52 namespace NetworkCache { 53 54 static const AtomicString& resourceType() 55 { 56 ASSERT(WTF::isMainThread()); 57 static NeverDestroyed<const AtomicString> resource("resource", AtomicString::ConstructFromLiteral); 58 return resource; 59 } 52 60 53 61 Cache& singleton() … … 114 122 // ranges so only the same exact range request will be served from the cache. 115 123 String range = request.httpHeaderField(WebCore::HTTPHeaderName::Range); 116 return { partition, r ange, request.url().string() };124 return { partition, resourceType(), range, request.url().string() }; 117 125 } 118 126 … … 473 481 ASSERT(isEnabled()); 474 482 475 m_storage->traverse( 0, [traverseHandler](const Storage::Record* record, const Storage::RecordInfo&) {483 m_storage->traverse(resourceType(), 0, [traverseHandler](const Storage::Record* record, const Storage::RecordInfo&) { 476 484 if (!record) { 477 485 traverseHandler(nullptr); … … 510 518 auto flags = Storage::TraverseFlag::ComputeWorth | Storage::TraverseFlag::ShareCount; 511 519 size_t capacity = m_storage->capacity(); 512 m_storage->traverse( flags, [fd, totals, capacity](const Storage::Record* record, const Storage::RecordInfo& info) mutable {520 m_storage->traverse(resourceType(), flags, [fd, totals, capacity](const Storage::Record* record, const Storage::RecordInfo& info) mutable { 513 521 if (!record) { 514 522 StringBuilder epilogue; … … 568 576 return; 569 577 } 570 m_storage->clear(modifiedSince, WTF::move(completionHandler)); 578 String anyType; 579 m_storage->clear(anyType, modifiedSince, WTF::move(completionHandler)); 571 580 572 581 deleteDumpFile(); -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.cpp
r191354 r191377 39 39 Key::Key(const Key& o) 40 40 : m_partition(o.m_partition.isolatedCopy()) 41 , m_type(o.m_type.isolatedCopy()) 41 42 , m_identifier(o.m_identifier.isolatedCopy()) 42 43 , m_range(o.m_range.isolatedCopy()) … … 45 46 } 46 47 47 Key::Key(const String& partition, const String& range, const String& identifier)48 Key::Key(const String& partition, const String& type, const String& range, const String& identifier) 48 49 : m_partition(partition.isolatedCopy()) 50 , m_type(type.isolatedCopy()) 49 51 , m_identifier(identifier.isolatedCopy()) 50 52 , m_range(range.isolatedCopy()) … … 56 58 { 57 59 m_partition = other.m_partition.isolatedCopy(); 60 m_type = other.m_type.isolatedCopy(); 58 61 m_identifier = other.m_identifier.isolatedCopy(); 59 62 m_range = other.m_range.isolatedCopy(); … … 84 87 SHA1 sha1; 85 88 hashString(sha1, m_partition); 89 hashString(sha1, m_type); 86 90 hashString(sha1, m_identifier); 87 91 hashString(sha1, m_range); … … 125 129 bool Key::operator==(const Key& other) const 126 130 { 127 return m_hash == other.m_hash && m_partition == other.m_partition && m_ identifier == other.m_identifier && m_range == other.m_range;131 return m_hash == other.m_hash && m_partition == other.m_partition && m_type == other.m_type && m_identifier == other.m_identifier && m_range == other.m_range; 128 132 } 129 133 … … 131 135 { 132 136 encoder << m_partition; 137 encoder << m_type; 133 138 encoder << m_identifier; 134 139 encoder << m_range; … … 138 143 bool Key::decode(Decoder& decoder, Key& key) 139 144 { 140 return decoder.decode(key.m_partition) && decoder.decode(key.m_ identifier) && decoder.decode(key.m_range) && decoder.decode(key.m_hash);145 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); 141 146 } 142 147 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheKey.h
r191354 r191377 45 45 Key(const Key&); 46 46 Key(Key&&) = default; 47 Key(const String& partition, const String& range, const String& identifier);47 Key(const String& partition, const String& type, const String& range, const String& identifier); 48 48 49 49 Key& operator=(const Key&); … … 54 54 const String& partition() const { return m_partition; } 55 55 const String& identifier() const { return m_identifier; } 56 const String& type() const { return m_type; } 56 57 57 58 HashType hash() const { return m_hash; } … … 72 73 73 74 String m_partition; 75 String m_type; 74 76 String m_identifier; 75 77 String m_range; -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStatistics.cpp
r191354 r191377 145 145 146 146 Vector<StringCapture> hashes; 147 traverseRecordsFiles(networkCachePath, [&hashes](const String& hashString, const String&) { 147 traverseRecordsFiles(networkCachePath, ASCIILiteral("resource"), [&hashes](const String& fileName, const String& hashString, const String& type, bool isBodyBlob, const String& recordDirectoryPath) { 148 if (isBodyBlob) 149 return; 150 148 151 Key::HashType hash; 149 152 if (!Key::stringToHash(hashString, hash)) -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp
r191354 r191377 47 47 static const char recordsDirectoryName[] = "Records"; 48 48 static const char blobsDirectoryName[] = "Blobs"; 49 static const char b odyPostfix[] = "-body";49 static const char blobSuffix[] = "-blob"; 50 50 51 51 static double computeRecordWorth(FileTimes); … … 114 114 WTF_MAKE_FAST_ALLOCATED; 115 115 public: 116 TraverseOperation(TraverseFlags flags, const TraverseHandler& handler) 117 : flags(flags) 116 TraverseOperation(const String& type, TraverseFlags flags, const TraverseHandler& handler) 117 : type(type) 118 , flags(flags) 118 119 , handler(handler) 119 120 { } 120 121 122 const String type; 121 123 const TraverseFlags flags; 122 124 const TraverseHandler handler; … … 152 154 } 153 155 154 void traverseRecordsFiles(const String& recordsPath, const std::function<void (const String&, const String&)>& function) 155 { 156 traverseDirectory(recordsPath, [&recordsPath, &function](const String& subdirName, DirectoryEntryType type) { 156 void traverseRecordsFiles(const String& recordsPath, const String& expectedType, const std::function<void (const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath)>& function) 157 { 158 traverseDirectory(recordsPath, [&recordsPath, &function, &expectedType](const String& partitionName, DirectoryEntryType entryType) { 159 if (entryType != DirectoryEntryType::Directory) 160 return; 161 String partitionPath = WebCore::pathByAppendingComponent(recordsPath, partitionName); 162 traverseDirectory(partitionPath, [&function, &partitionPath, &expectedType](const String& actualType, DirectoryEntryType entryType) { 163 if (entryType != DirectoryEntryType::Directory) 164 return; 165 if (!expectedType.isEmpty() && expectedType != actualType) 166 return; 167 String recordDirectoryPath = WebCore::pathByAppendingComponent(partitionPath, actualType); 168 traverseDirectory(recordDirectoryPath, [&function, &recordDirectoryPath, &actualType](const String& fileName, DirectoryEntryType entryType) { 169 if (entryType != DirectoryEntryType::File || fileName.length() < Key::hashStringLength()) 170 return; 171 172 String hashString = fileName.substring(0, Key::hashStringLength()); 173 auto isBlob = fileName.length() > Key::hashStringLength() && fileName.endsWith(blobSuffix); 174 function(fileName, hashString, actualType, isBlob, recordDirectoryPath); 175 }); 176 }); 177 }); 178 } 179 180 static void deleteEmptyRecordsDirectories(const String& recordsPath) 181 { 182 traverseDirectory(recordsPath, [&recordsPath](const String& partitionName, DirectoryEntryType type) { 157 183 if (type != DirectoryEntryType::Directory) 158 184 return; 159 String partitionPath = WebCore::pathByAppendingComponent(recordsPath, subdirName); 160 traverseDirectory(partitionPath, [&function, &partitionPath](const String& fileName, DirectoryEntryType type) { 161 if (type != DirectoryEntryType::File) 162 return; 163 function(fileName, partitionPath); 164 }); 165 }); 166 } 167 168 static void deleteEmptyRecordsDirectories(const String& recordsPath) 169 { 170 traverseDirectory(recordsPath, [&recordsPath](const String& subdirName, DirectoryEntryType type) { 171 if (type != DirectoryEntryType::Directory) 172 return; 185 186 // Delete [type] sub-folders. 187 String partitionPath = WebCore::pathByAppendingComponent(recordsPath, partitionName); 188 traverseDirectory(partitionPath, [&partitionPath](const String& subdirName, DirectoryEntryType entryType) { 189 if (entryType != DirectoryEntryType::Directory) 190 return; 191 192 // Let system figure out if it is really empty. 193 WebCore::deleteEmptyDirectory(WebCore::pathByAppendingComponent(partitionPath, subdirName)); 194 }); 195 196 // Delete [Partition] folders. 173 197 // Let system figure out if it is really empty. 174 WebCore::deleteEmptyDirectory(WebCore::pathByAppendingComponent(recordsPath, subdirName));198 WebCore::deleteEmptyDirectory(WebCore::pathByAppendingComponent(recordsPath, partitionName)); 175 199 }); 176 200 } … … 226 250 backgroundIOQueue().dispatch([this] { 227 251 auto recordFilter = std::make_unique<ContentsFilter>(); 228 auto b odyFilter = std::make_unique<ContentsFilter>();252 auto blobFilter = std::make_unique<ContentsFilter>(); 229 253 size_t recordsSize = 0; 230 254 unsigned count = 0; 231 traverseRecordsFiles(recordsPath(), [&recordFilter, &bodyFilter, &recordsSize, &count](const String& fileName, const String& partitionPath) { 232 auto filePath = WebCore::pathByAppendingComponent(partitionPath, fileName); 233 234 bool isBody = fileName.endsWith(bodyPostfix); 235 String hashString = isBody ? fileName.substring(0, Key::hashStringLength()) : fileName; 255 String anyType; 256 traverseRecordsFiles(recordsPath(), anyType, [&recordFilter, &blobFilter, &recordsSize, &count](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) { 257 auto filePath = WebCore::pathByAppendingComponent(recordDirectoryPath, fileName); 258 236 259 Key::HashType hash; 237 260 if (!Key::stringToHash(hashString, hash)) { … … 245 268 return; 246 269 } 247 if (isBody) { 248 bodyFilter->add(hash); 270 271 if (isBlob) { 272 blobFilter->add(hash); 249 273 return; 250 274 } 275 251 276 recordFilter->add(hash); 252 277 recordsSize += fileSize; … … 255 280 256 281 auto* recordFilterPtr = recordFilter.release(); 257 auto* b odyFilterPtr = bodyFilter.release();258 RunLoop::main().dispatch([this, recordFilterPtr, b odyFilterPtr, recordsSize] {282 auto* blobFilterPtr = blobFilter.release(); 283 RunLoop::main().dispatch([this, recordFilterPtr, blobFilterPtr, recordsSize] { 259 284 auto recordFilter = std::unique_ptr<ContentsFilter>(recordFilterPtr); 260 auto b odyFilter = std::unique_ptr<ContentsFilter>(bodyFilterPtr);261 262 for (auto& hash: m_recordFilterHashesAddedDuringSynchronization)263 recordFilter->add( hash);285 auto blobFilter = std::unique_ptr<ContentsFilter>(blobFilterPtr); 286 287 for (auto& recordFilterKey : m_recordFilterHashesAddedDuringSynchronization) 288 recordFilter->add(recordFilterKey); 264 289 m_recordFilterHashesAddedDuringSynchronization.clear(); 265 290 266 for (auto& hash : m_b odyFilterHashesAddedDuringSynchronization)267 b odyFilter->add(hash);268 m_b odyFilterHashesAddedDuringSynchronization.clear();291 for (auto& hash : m_blobFilterHashesAddedDuringSynchronization) 292 blobFilter->add(hash); 293 m_blobFilterHashesAddedDuringSynchronization.clear(); 269 294 270 295 m_recordFilter = WTF::move(recordFilter); 271 m_b odyFilter = WTF::move(bodyFilter);296 m_blobFilter = WTF::move(blobFilter); 272 297 m_approximateRecordsSize = recordsSize; 273 298 m_synchronizationInProgress = false; … … 278 303 deleteEmptyRecordsDirectories(recordsPath()); 279 304 280 LOG(NetworkCacheStorage, "(NetworkProcess) cache synchronization completed size=%zu count=% d", recordsSize, count);305 LOG(NetworkCacheStorage, "(NetworkProcess) cache synchronization completed size=%zu count=%u", recordsSize, count); 281 306 }); 282 307 } … … 300 325 } 301 326 302 String Storage::partitionPathForKey(const Key& key) const 327 bool Storage::mayContainBlob(const Key& key) const 328 { 329 ASSERT(RunLoop::isMain()); 330 return !m_blobFilter || m_blobFilter->mayContain(key.hash()); 331 } 332 333 String Storage::recordDirectoryPathForKey(const Key& key) const 303 334 { 304 335 ASSERT(!key.partition().isEmpty()); 305 return WebCore::pathByAppendingComponent(recordsPath(), key.partition()); 306 } 307 308 static String fileNameForKey(const Key& key) 309 { 310 return key.hashAsString(); 336 ASSERT(!key.type().isEmpty()); 337 return WebCore::pathByAppendingComponent(WebCore::pathByAppendingComponent(recordsPath(), key.partition()), key.type()); 311 338 } 312 339 313 340 String Storage::recordPathForKey(const Key& key) const 314 341 { 315 return WebCore::pathByAppendingComponent( partitionPathForKey(key), fileNameForKey(key));316 } 317 318 static String b odyPathForRecordPath(const String& recordPath)319 { 320 return recordPath + b odyPostfix;321 } 322 323 String Storage::b odyPathForKey(const Key& key) const324 { 325 return b odyPathForRecordPath(recordPathForKey(key));342 return WebCore::pathByAppendingComponent(recordDirectoryPathForKey(key), key.hashAsString()); 343 } 344 345 static String blobPathForRecordPath(const String& recordPath) 346 { 347 return recordPath + blobSuffix; 348 } 349 350 String Storage::blobPathForKey(const Key& key) const 351 { 352 return blobPathForRecordPath(recordPathForKey(key)); 326 353 } 327 354 … … 453 480 Optional<BlobStorage::Blob> Storage::storeBodyAsBlob(WriteOperation& writeOperation) 454 481 { 455 auto b odyPath = bodyPathForKey(writeOperation.record.key);482 auto blobPath = blobPathForKey(writeOperation.record.key); 456 483 457 484 // Store the body. 458 auto blob = m_blobStorage.add(b odyPath, writeOperation.record.body);485 auto blob = m_blobStorage.add(blobPath, writeOperation.record.body); 459 486 if (blob.data.isNull()) 460 487 return { }; … … 463 490 464 491 RunLoop::main().dispatch([this, blob, &writeOperation] { 465 if (m_b odyFilter)466 m_b odyFilter->add(writeOperation.record.key.hash());492 if (m_blobFilter) 493 m_blobFilter->add(writeOperation.record.key.hash()); 467 494 if (m_synchronizationInProgress) 468 m_b odyFilterHashesAddedDuringSynchronization.append(writeOperation.record.key.hash());495 m_blobFilterHashesAddedDuringSynchronization.append(writeOperation.record.key.hash()); 469 496 470 497 if (writeOperation.mappedBodyHandler) … … 524 551 serialBackgroundIOQueue().dispatch([this, key] { 525 552 WebCore::deleteFile(recordPathForKey(key)); 526 m_blobStorage.remove(b odyPathForKey(key));553 m_blobStorage.remove(blobPathForKey(key)); 527 554 }); 528 555 } … … 547 574 m_readOperationTimeoutTimer.startOneShot(readTimeout); 548 575 549 bool shouldGetBodyBlob = !m_bodyFilter || m_bodyFilter->mayContain(readOperation.key.hash());576 bool shouldGetBodyBlob = mayContainBlob(readOperation.key); 550 577 551 578 ioQueue().dispatch([this, &readOperation, shouldGetBodyBlob] { … … 564 591 565 592 if (shouldGetBodyBlob) { 566 // Read the b ody blob in parallel with the record read.567 auto b odyPath = bodyPathForKey(readOperation.key);568 readOperation.resultBodyBlob = m_blobStorage.get(b odyPath);593 // Read the blob in parallel with the record read. 594 auto blobPath = blobPathForKey(readOperation.key); 595 readOperation.resultBodyBlob = m_blobStorage.get(blobPath); 569 596 finishReadOperation(readOperation); 570 597 } … … 575 602 { 576 603 ASSERT(readOperation.activeCount); 577 // Record and b ody blob reads must finish.604 // Record and blob reads must finish. 578 605 if (--readOperation.activeCount) 579 606 return; … … 682 709 683 710 backgroundIOQueue().dispatch([this, &writeOperation] { 684 auto partitionPath = partitionPathForKey(writeOperation.record.key);711 auto recordDirectorPath = recordDirectoryPathForKey(writeOperation.record.key); 685 712 auto recordPath = recordPathForKey(writeOperation.record.key); 686 713 687 WebCore::makeAllDirectories( partitionPath);714 WebCore::makeAllDirectories(recordDirectorPath); 688 715 689 716 ++writeOperation.activeCount; 690 717 691 718 bool shouldStoreAsBlob = shouldStoreBodyAsBlob(writeOperation.record.body); 692 auto b odyBlob = shouldStoreAsBlob ? storeBodyAsBlob(writeOperation) : Nullopt;693 694 auto recordData = encodeRecord(writeOperation.record, b odyBlob);719 auto blob = shouldStoreAsBlob ? storeBodyAsBlob(writeOperation) : Nullopt; 720 721 auto recordData = encodeRecord(writeOperation.record, blob); 695 722 696 723 auto channel = IOChannel::open(recordPath, IOChannel::Type::Create); … … 771 798 } 772 799 773 void Storage::traverse( TraverseFlags flags, TraverseHandler&& traverseHandler)800 void Storage::traverse(const String& type, TraverseFlags flags, TraverseHandler&& traverseHandler) 774 801 { 775 802 ASSERT(RunLoop::isMain()); … … 777 804 // Avoid non-thread safe std::function copies. 778 805 779 auto traverseOperationPtr = std::make_unique<TraverseOperation>( flags, WTF::move(traverseHandler));806 auto traverseOperationPtr = std::make_unique<TraverseOperation>(type, flags, WTF::move(traverseHandler)); 780 807 auto& traverseOperation = *traverseOperationPtr; 781 808 m_activeTraverseOperations.add(WTF::move(traverseOperationPtr)); 782 809 783 810 ioQueue().dispatch([this, &traverseOperation] { 784 traverseRecordsFiles(recordsPath(), [this, &traverseOperation](const String& fileName, const String& partitionPath) { 785 if (fileName.length() != Key::hashStringLength()) 786 return; 787 auto recordPath = WebCore::pathByAppendingComponent(partitionPath, fileName); 811 traverseRecordsFiles(recordsPath(), traverseOperation.type, [this, &traverseOperation](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) { 812 ASSERT(type == traverseOperation.type); 813 if (isBlob) 814 return; 815 816 auto recordPath = WebCore::pathByAppendingComponent(recordDirectoryPath, fileName); 788 817 789 818 double worth = -1; … … 792 821 unsigned bodyShareCount = 0; 793 822 if (traverseOperation.flags & TraverseFlag::ShareCount) 794 bodyShareCount = m_blobStorage.shareCount(b odyPathForRecordPath(recordPath));823 bodyShareCount = m_blobStorage.shareCount(blobPathForRecordPath(recordPath)); 795 824 796 825 std::unique_lock<Lock> lock(traverseOperation.activeMutex); … … 857 886 } 858 887 859 void Storage::clear( std::chrono::system_clock::time_point modifiedSinceTime, std::function<void ()>&& completionHandler)888 void Storage::clear(const String& type, std::chrono::system_clock::time_point modifiedSinceTime, std::function<void ()>&& completionHandler) 860 889 { 861 890 ASSERT(RunLoop::isMain()); … … 864 893 if (m_recordFilter) 865 894 m_recordFilter->clear(); 866 if (m_b odyFilter)867 m_b odyFilter->clear();895 if (m_blobFilter) 896 m_blobFilter->clear(); 868 897 m_approximateRecordsSize = 0; 869 898 870 899 // Avoid non-thread safe std::function copies. 871 900 auto* completionHandlerPtr = completionHandler ? new std::function<void ()>(WTF::move(completionHandler)) : nullptr; 872 873 ioQueue().dispatch([this, modifiedSinceTime, completionHandlerPtr ] {901 StringCapture typeCapture(type); 902 ioQueue().dispatch([this, modifiedSinceTime, completionHandlerPtr, typeCapture] { 874 903 auto recordsPath = this->recordsPath(); 875 traverseRecordsFiles(recordsPath, [modifiedSinceTime](const String& fileName, const String& partitionPath) {876 auto filePath = WebCore::pathByAppendingComponent( partitionPath, fileName);904 traverseRecordsFiles(recordsPath, typeCapture.string(), [modifiedSinceTime](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) { 905 auto filePath = WebCore::pathByAppendingComponent(recordDirectoryPath, fileName); 877 906 if (modifiedSinceTime > std::chrono::system_clock::time_point::min()) { 878 907 auto times = fileTimes(filePath); … … 885 914 deleteEmptyRecordsDirectories(recordsPath); 886 915 887 // This cleans unreference sblobs.916 // This cleans unreferenced blobs. 888 917 m_blobStorage.synchronize(); 889 918 … … 951 980 backgroundIOQueue().dispatch([this] { 952 981 auto recordsPath = this->recordsPath(); 953 traverseRecordsFiles(recordsPath, [this](const String& fileName, const String& partitionPath) { 954 if (fileName.length() != Key::hashStringLength()) 955 return; 956 auto recordPath = WebCore::pathByAppendingComponent(partitionPath, fileName); 957 auto bodyPath = bodyPathForRecordPath(recordPath); 982 String anyType; 983 traverseRecordsFiles(recordsPath, anyType, [this](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) { 984 if (isBlob) 985 return; 986 987 auto recordPath = WebCore::pathByAppendingComponent(recordDirectoryPath, fileName); 988 auto blobPath = blobPathForRecordPath(recordPath); 958 989 959 990 auto times = fileTimes(recordPath); 960 unsigned bodyShareCount = m_blobStorage.shareCount(b odyPath);991 unsigned bodyShareCount = m_blobStorage.shareCount(blobPath); 961 992 auto probability = deletionProbability(times, bodyShareCount); 962 993 … … 967 998 if (shouldDelete) { 968 999 WebCore::deleteFile(recordPath); 969 m_blobStorage.remove(b odyPath);1000 m_blobStorage.remove(blobPath); 970 1001 } 971 1002 }); -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h
r191354 r191377 66 66 67 67 void remove(const Key&); 68 void clear( std::chrono::system_clock::time_point modifiedSinceTime, std::function<void ()>&& completionHandler);68 void clear(const String& type, std::chrono::system_clock::time_point modifiedSinceTime, std::function<void ()>&& completionHandler); 69 69 70 70 struct RecordInfo { … … 81 81 typedef std::function<void (const Record*, const RecordInfo&)> TraverseHandler; 82 82 // Null record signals end. 83 void traverse( TraverseFlags, TraverseHandler&&);83 void traverse(const String& type, TraverseFlags, TraverseHandler&&); 84 84 85 85 void setCapacity(size_t); … … 87 87 size_t approximateSize() const; 88 88 89 static const unsigned version = 4;89 static const unsigned version = 5; 90 90 91 91 String basePath() const; … … 98 98 Storage(const String& directoryPath); 99 99 100 String partitionPathForKey(const Key&) const;100 String recordDirectoryPathForKey(const Key&) const; 101 101 String recordPathForKey(const Key&) const; 102 String b odyPathForKey(const Key&) const;102 String blobPathForKey(const Key&) const; 103 103 104 104 void synchronize(); … … 130 130 131 131 bool mayContain(const Key&) const; 132 bool mayContainBlob(const Key&) const; 132 133 133 134 void addToRecordFilter(const Key&); … … 142 143 using ContentsFilter = BloomFilter<18>; 143 144 std::unique_ptr<ContentsFilter> m_recordFilter; 144 std::unique_ptr<ContentsFilter> m_b odyFilter;145 std::unique_ptr<ContentsFilter> m_blobFilter; 145 146 146 147 bool m_synchronizationInProgress { false }; … … 148 149 149 150 Vector<Key::HashType> m_recordFilterHashesAddedDuringSynchronization; 150 Vector<Key::HashType> m_b odyFilterHashesAddedDuringSynchronization;151 Vector<Key::HashType> m_blobFilterHashesAddedDuringSynchronization; 151 152 152 153 static const int maximumRetrievePriority = 4; … … 170 171 171 172 // FIXME: Remove, used by NetworkCacheStatistics only. 172 void traverseRecordsFiles(const String& recordsPath, const std::function<void (const String&, const String&)>&);173 void traverseRecordsFiles(const String& recordsPath, const String& type, const std::function<void (const String& fileName, const String& hashString, const String& type, bool isBodyBlob, const String& recordDirectoryPath)>&); 173 174 174 175 }
Note: See TracChangeset
for help on using the changeset viewer.