Title: [183263] trunk/Source/WebKit2
Revision
183263
Author
[email protected]
Date
2015-04-24 07:39:05 -0700 (Fri, 24 Apr 2015)

Log Message

Network Cache: Make path functions members
https://bugs.webkit.org/show_bug.cgi?id=144146

Reviewed by Carlos Garcia Campos.

This simplifies the code.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::partitionPathForKey):
(WebKit::NetworkCache::Storage::recordPathForKey):
(WebKit::NetworkCache::Storage::bodyPathForKey):
(WebKit::NetworkCache::Storage::storeBodyAsBlob):
(WebKit::NetworkCache::Storage::remove):
(WebKit::NetworkCache::Storage::dispatchReadOperation):
(WebKit::NetworkCache::Storage::finishReadOperation):
(WebKit::NetworkCache::Storage::dispatchWriteOperation):
(WebKit::NetworkCache::partitionPathForKey): Deleted.
(WebKit::NetworkCache::recordPathForKey): Deleted.
(WebKit::NetworkCache::bodyPathForKey): Deleted.
* NetworkProcess/cache/NetworkCacheStorage.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (183262 => 183263)


--- trunk/Source/WebKit2/ChangeLog	2015-04-24 11:42:43 UTC (rev 183262)
+++ trunk/Source/WebKit2/ChangeLog	2015-04-24 14:39:05 UTC (rev 183263)
@@ -1,3 +1,26 @@
+2015-04-24  Antti Koivisto  <[email protected]>
+
+        Network Cache: Make path functions members
+        https://bugs.webkit.org/show_bug.cgi?id=144146
+
+        Reviewed by Carlos Garcia Campos.
+
+        This simplifies the code.
+
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::Storage::partitionPathForKey):
+        (WebKit::NetworkCache::Storage::recordPathForKey):
+        (WebKit::NetworkCache::Storage::bodyPathForKey):
+        (WebKit::NetworkCache::Storage::storeBodyAsBlob):
+        (WebKit::NetworkCache::Storage::remove):
+        (WebKit::NetworkCache::Storage::dispatchReadOperation):
+        (WebKit::NetworkCache::Storage::finishReadOperation):
+        (WebKit::NetworkCache::Storage::dispatchWriteOperation):
+        (WebKit::NetworkCache::partitionPathForKey): Deleted.
+        (WebKit::NetworkCache::recordPathForKey): Deleted.
+        (WebKit::NetworkCache::bodyPathForKey): Deleted.
+        * NetworkProcess/cache/NetworkCacheStorage.h:
+
 2015-04-24  Carlos Garcia Campos  <[email protected]>
 
         Unreviewed. Remove incorrect assert after r183189.

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (183262 => 183263)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp	2015-04-24 11:42:43 UTC (rev 183262)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp	2015-04-24 14:39:05 UTC (rev 183263)
@@ -192,10 +192,10 @@
     return !m_recordFilter || m_recordFilter->mayContain(key.hash());
 }
 
-static String partitionPathForKey(const Key& key, const String& cachePath)
+String Storage::partitionPathForKey(const Key& key) const
 {
     ASSERT(!key.partition().isEmpty());
-    return WebCore::pathByAppendingComponent(cachePath, key.partition());
+    return WebCore::pathByAppendingComponent(recordsPath(), key.partition());
 }
 
 static String fileNameForKey(const Key& key)
@@ -203,9 +203,9 @@
     return key.hashAsString();
 }
 
-static String recordPathForKey(const Key& key, const String& cachePath)
+String Storage::recordPathForKey(const Key& key) const
 {
-    return WebCore::pathByAppendingComponent(partitionPathForKey(key, cachePath), fileNameForKey(key));
+    return WebCore::pathByAppendingComponent(partitionPathForKey(key), fileNameForKey(key));
 }
 
 static String bodyPathForRecordPath(const String& recordPath)
@@ -213,9 +213,9 @@
     return recordPath + bodyPostfix;
 }
 
-static String bodyPathForKey(const Key& key, const String& cachePath)
+String Storage::bodyPathForKey(const Key& key) const
 {
-    return bodyPathForRecordPath(recordPathForKey(key, cachePath));
+    return bodyPathForRecordPath(recordPathForKey(key));
 }
 
 static unsigned hashData(const Data& data)
@@ -353,7 +353,7 @@
 
 Optional<BlobStorage::Blob> Storage::storeBodyAsBlob(const Record& record, const MappedBodyHandler& mappedBodyHandler)
 {
-    auto bodyPath = bodyPathForKey(record.key, recordsPath());
+    auto bodyPath = bodyPathForKey(record.key);
 
     // Store the body.
     auto blob = m_blobStorage.add(bodyPath, record.body);
@@ -404,9 +404,8 @@
     // The next synchronization will update everything.
 
     serialBackgroundIOQueue().dispatch([this, key] {
-        auto recordsPath = this->recordsPath();
-        WebCore::deleteFile(recordPathForKey(key, recordsPath));
-        m_blobStorage.remove(bodyPathForKey(key, recordsPath));
+        WebCore::deleteFile(recordPathForKey(key));
+        m_blobStorage.remove(bodyPathForKey(key));
     });
 }
 
@@ -423,7 +422,7 @@
     ASSERT(RunLoop::isMain());
     ASSERT(m_activeReadOperations.contains(&readOperation));
 
-    auto recordPath = recordPathForKey(readOperation.key, recordsPath());
+    auto recordPath = recordPathForKey(readOperation.key);
 
     RefPtr<IOChannel> channel = IOChannel::open(recordPath, IOChannel::Type::Read);
     channel->read(0, std::numeric_limits<size_t>::max(), &ioQueue(), [this, &readOperation](const Data& fileData, int error) {
@@ -440,7 +439,7 @@
 
     // Read the body blob in parallel with the record read.
     ioQueue().dispatch([this, &readOperation] {
-        auto bodyPath = bodyPathForKey(readOperation.key, this->recordsPath());
+        auto bodyPath = bodyPathForKey(readOperation.key);
         readOperation.resultBodyBlob = m_blobStorage.get(bodyPath);
         finishReadOperation(readOperation);
     });
@@ -463,7 +462,7 @@
 
         bool success = readOperation.completionHandler(WTF::move(readOperation.resultRecord));
         if (success)
-            updateFileModificationTime(recordPathForKey(readOperation.key, recordsPath()));
+            updateFileModificationTime(recordPathForKey(readOperation.key));
         else
             remove(readOperation.key);
         ASSERT(m_activeReadOperations.contains(&readOperation));
@@ -544,9 +543,8 @@
     addToRecordFilter(writeOperation.record.key);
 
     backgroundIOQueue().dispatch([this, &writeOperation] {
-        auto recordsPath = this->recordsPath();
-        auto partitionPath = partitionPathForKey(writeOperation.record.key, recordsPath);
-        auto recordPath = recordPathForKey(writeOperation.record.key, recordsPath);
+        auto partitionPath = partitionPathForKey(writeOperation.record.key);
+        auto recordPath = recordPathForKey(writeOperation.record.key);
 
         WebCore::makeAllDirectories(partitionPath);
 

Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h (183262 => 183263)


--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h	2015-04-24 11:42:43 UTC (rev 183262)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h	2015-04-24 14:39:05 UTC (rev 183263)
@@ -90,6 +90,10 @@
 private:
     Storage(const String& directoryPath);
 
+    String partitionPathForKey(const Key&) const;
+    String recordPathForKey(const Key&) const;
+    String bodyPathForKey(const Key&) const;
+
     void synchronize();
     void deleteOldVersions();
     void shrinkIfNeeded();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to