Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (236661 => 236662)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp 2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp 2018-10-01 16:17:29 UTC (rev 236662)
@@ -26,6 +26,7 @@
#include "config.h"
#include "CacheStorageEngine.h"
+#include "Logging.h"
#include "NetworkCacheCoders.h"
#include "NetworkCacheIOChannel.h"
#include <WebCore/SecurityOrigin.h>
@@ -68,6 +69,7 @@
channel->read(0, std::numeric_limits<size_t>::max(), nullptr, [completionHandler = WTFMove(completionHandler)](const Data& data, int error) mutable {
ASSERT(RunLoop::isMain());
if (error) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::retrieveOriginFromDirectory failed reading channel with error %d", error);
completionHandler(std::nullopt);
return;
}
@@ -138,8 +140,9 @@
return;
}
- auto storage = Storage::open(m_rootPath, Storage::Mode::Normal);
+ auto storage = Storage::open(m_rootPath, Storage::Mode::AvoidRandomness);
if (!storage) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::initialize failed opening storage");
callback(Error::WriteDisk);
return;
}
@@ -150,6 +153,8 @@
storeOrigin([this] (std::optional<Error>&& error) mutable {
if (error) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::initialize failed storing origin with error %d", *error);
+
auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
for (auto& callback : pendingCallbacks)
callback(Error::WriteDisk);
@@ -162,6 +167,8 @@
makeDirty();
if (!result.has_value()) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::initialize failed reading caches from disk with error %d", result.error());
+
auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
for (auto& callback : pendingCallbacks)
callback(result.error());
@@ -367,11 +374,8 @@
return Data { encoder.buffer(), encoder.bufferSize() };
}
-static inline Expected<Vector<std::pair<String, String>>, Error> decodeCachesNames(const Data& data, int error)
+static inline Expected<Vector<std::pair<String, String>>, Error> decodeCachesNames(const Data& data)
{
- if (error)
- return makeUnexpected(Error::ReadDisk);
-
WTF::Persistence::Decoder decoder(data.data(), data.size());
uint64_t count;
if (!decoder.decode(count))
@@ -415,8 +419,15 @@
return;
}
- auto result = decodeCachesNames(data, error);
+ if (error) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::readCachesFromDisk failed reading caches from disk with error %d", error);
+ callback(makeUnexpected(Error::ReadDisk));
+ return;
+ }
+
+ auto result = decodeCachesNames(data);
if (!result.has_value()) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::decodeCachesNames failed decoding caches with error %d", result.error());
callback(makeUnexpected(result.error()));
return;
}
@@ -446,6 +457,9 @@
m_isWritingCachesToDisk = true;
m_engine->writeFile(cachesListFilename(m_rootPath), encodeCacheNames(m_caches), [this, protectedThis = makeRef(*this), callback = WTFMove(callback)](std::optional<Error>&& error) mutable {
m_isWritingCachesToDisk = false;
+ if (error)
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::writeCachesToDisk failed writing caches to disk with error %d", *error);
+
callback(WTFMove(error));
while (!m_pendingWritingCachesToDiskCallbacks.isEmpty() && !m_isWritingCachesToDisk)
m_pendingWritingCachesToDiskCallbacks.takeFirst()(std::nullopt);
@@ -509,6 +523,7 @@
m_storage->retrieve(key, 4, [protectedStorage = makeRef(*m_storage), callback = WTFMove(callback)](std::unique_ptr<Storage::Record> storage, const Storage::Timings&) mutable {
if (!storage) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::readRecord failed reading record from disk");
callback(makeUnexpected(Error::ReadDisk));
return false;
}
@@ -515,6 +530,7 @@
auto record = Cache::decode(*storage);
if (!record) {
+ RELEASE_LOG_ERROR(CacheStorage, "Caches::readRecord failed decoding record from disk");
callback(makeUnexpected(Error::ReadDisk));
return false;
}
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp (236661 => 236662)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp 2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCache.cpp 2018-10-01 16:17:29 UTC (rev 236662)
@@ -61,7 +61,7 @@
RefPtr<Cache> Cache::open(const String& cachePath, OptionSet<Option> options)
{
- auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::Testing : Storage::Mode::Normal);
+ auto storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::AvoidRandomness : Storage::Mode::Normal);
LOG(NetworkCache, "(NetworkProcess) opened cache storage, success %d", !!storage);
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp (236661 => 236662)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp 2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp 2018-10-01 16:17:29 UTC (rev 236662)
@@ -657,7 +657,7 @@
++m_readOperationDispatchCount;
// Avoid randomness during testing.
- if (m_mode != Mode::Testing) {
+ if (m_mode != Mode::AvoidRandomness) {
// I/O pressure may make disk operations slow. If they start taking very long time we rather go to network.
const Seconds readTimeout = 1500_ms;
m_readOperationTimeoutTimer.startOneShot(readTimeout);
@@ -1070,7 +1070,7 @@
ASSERT(RunLoop::isMain());
// Avoid randomness caused by cache shrinks.
- if (m_mode == Mode::Testing)
+ if (m_mode == Mode::AvoidRandomness)
return;
if (approximateSize() > m_capacity)
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h (236661 => 236662)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h 2018-10-01 16:10:52 UTC (rev 236661)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.h 2018-10-01 16:17:29 UTC (rev 236662)
@@ -47,7 +47,7 @@
class Storage : public ThreadSafeRefCounted<Storage> {
public:
- enum class Mode { Normal, Testing };
+ enum class Mode { Normal, AvoidRandomness };
static RefPtr<Storage> open(const String& cachePath, Mode);
struct Record {