- Revision
- 221426
- Author
- commit-qu...@webkit.org
- Date
- 2017-08-31 11:19:54 -0700 (Thu, 31 Aug 2017)
Log Message
Do not create a salt if the CacheStorage engine should not persist
https://bugs.webkit.org/show_bug.cgi?id=176138
Patch by Youenn Fablet <you...@apple.com> on 2017-08-31
Reviewed by Alex Christensen.
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::~Engine): Ensuring that Caches will not try using the engine if it goes away.
(WebKit::CacheStorage::Engine::initialize): Removing making a salt if engine data is not persistent.
* NetworkProcess/cache/CacheStorageEngine.h: Check persistency according the root path. If it is null, caches should not try to do persistency.
* NetworkProcess/cache/CacheStorageEngineCaches.cpp:
(WebKit::CacheStorage::cachesRootPath):
(WebKit::CacheStorage::Caches::initialize):
(WebKit::CacheStorage::Caches::detach):
(WebKit::CacheStorage::Caches::readCachesFromDisk):
(WebKit::CacheStorage::Caches::writeCachesToDisk):
* NetworkProcess/cache/CacheStorageEngineCaches.h:
(WebKit::CacheStorage::Caches::shouldPersist const):
* NetworkProcess/cache/NetworkCacheData.cpp: Making makeSalt private again.
(WebKit::NetworkCache::makeSalt):
* NetworkProcess/cache/NetworkCacheData.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (221425 => 221426)
--- trunk/Source/WebKit/ChangeLog 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/ChangeLog 2017-08-31 18:19:54 UTC (rev 221426)
@@ -1,3 +1,27 @@
+2017-08-31 Youenn Fablet <you...@apple.com>
+
+ Do not create a salt if the CacheStorage engine should not persist
+ https://bugs.webkit.org/show_bug.cgi?id=176138
+
+ Reviewed by Alex Christensen.
+
+ * NetworkProcess/cache/CacheStorageEngine.cpp:
+ (WebKit::CacheStorage::Engine::~Engine): Ensuring that Caches will not try using the engine if it goes away.
+ (WebKit::CacheStorage::Engine::initialize): Removing making a salt if engine data is not persistent.
+ * NetworkProcess/cache/CacheStorageEngine.h: Check persistency according the root path. If it is null, caches should not try to do persistency.
+ * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
+ (WebKit::CacheStorage::cachesRootPath):
+ (WebKit::CacheStorage::Caches::initialize):
+ (WebKit::CacheStorage::Caches::detach):
+ (WebKit::CacheStorage::Caches::readCachesFromDisk):
+ (WebKit::CacheStorage::Caches::writeCachesToDisk):
+ * NetworkProcess/cache/CacheStorageEngineCaches.h:
+ (WebKit::CacheStorage::Caches::shouldPersist const):
+ * NetworkProcess/cache/NetworkCacheData.cpp: Making makeSalt private again.
+ (WebKit::NetworkCache::makeSalt):
+ * NetworkProcess/cache/NetworkCacheData.h:
+
+
2017-08-31 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Several InputMethodFilter tests are failing and crashing
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (221425 => 221426)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2017-08-31 18:19:54 UTC (rev 221426)
@@ -48,6 +48,12 @@
return map;
}
+Engine::~Engine()
+{
+ for (auto& caches : m_caches.values())
+ caches->detach();
+}
+
Engine& Engine::from(PAL::SessionID sessionID)
{
auto addResult = globalEngineMap().add(sessionID, nullptr);
@@ -238,7 +244,6 @@
}
if (!shouldPersist()) {
- m_salt = makeSalt();
callback(std::nullopt);
return;
}
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h (221425 => 221426)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h 2017-08-31 18:19:54 UTC (rev 221426)
@@ -45,6 +45,8 @@
class Engine : public ThreadSafeRefCounted<Engine> {
public:
+ ~Engine();
+
static Engine& from(PAL::SessionID);
static void destroyEngine(PAL::SessionID);
static Ref<Engine> create(String&& rootPath) { return adoptRef(*new Engine(WTFMove(rootPath))); }
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp (221425 => 221426)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp 2017-08-31 18:19:54 UTC (rev 221426)
@@ -38,6 +38,9 @@
static inline String cachesRootPath(Engine& engine, const String& origin)
{
+ if (!engine.shouldPersist())
+ return { };
+
Key key(engine.rootPath(), { }, { }, origin, engine.salt());
return WebCore::pathByAppendingComponent(engine.rootPath(), key.partitionHashAsString());
}
@@ -55,7 +58,7 @@
void Caches::initialize(WebCore::DOMCache::CompletionCallback&& callback)
{
- if (m_isInitialized || !m_engine || !m_engine->shouldPersist()) {
+ if (m_isInitialized || m_rootPath.isNull()) {
callback(std::nullopt);
return;
}
@@ -90,6 +93,12 @@
});
}
+void Caches::detach()
+{
+ m_engine = nullptr;
+ m_rootPath = { };
+}
+
Cache* Caches::find(const String& name)
{
auto position = m_caches.findMatching([&](const auto& item) { return item.name == name; });
@@ -176,7 +185,7 @@
ASSERT(!m_isInitialized);
ASSERT(m_caches.isEmpty());
- if (!m_engine->shouldPersist()) {
+ if (!shouldPersist()) {
callback(Vector<Cache> { });
return;
}
@@ -209,7 +218,7 @@
void Caches::writeCachesToDisk(CompletionCallback&& callback)
{
- if (!m_engine->shouldPersist()) {
+ if (!shouldPersist()) {
callback(std::nullopt);
return;
}
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h (221425 => 221426)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h 2017-08-31 18:19:54 UTC (rev 221426)
@@ -51,7 +51,7 @@
Vector<WebCore::DOMCache::CacheInfo> cacheInfos() const;
void clearMemoryRepresentation();
- void detach() { m_engine = nullptr; }
+ void detach();
private:
Caches(Engine&, const String& rootPath);
@@ -59,6 +59,8 @@
void readCachesFromDisk(WTF::Function<void(Expected<Vector<Cache>, WebCore::DOMCache::Error>&&)>&&);
void writeCachesToDisk(WebCore::DOMCache::CompletionCallback&&);
+ bool shouldPersist() const { return !m_rootPath.isNull(); }
+
bool m_isInitialized { false };
Engine* m_engine { nullptr };
String m_rootPath;
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp (221425 => 221426)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp 2017-08-31 18:19:54 UTC (rev 221426)
@@ -128,7 +128,7 @@
return !memcmp(a.data(), b.data(), a.size());
}
-Salt makeSalt()
+static Salt makeSalt()
{
Salt salt;
static_assert(salt.size() == 8, "Salt size");
Modified: trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h (221425 => 221426)
--- trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h 2017-08-31 18:15:48 UTC (rev 221425)
+++ trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h 2017-08-31 18:19:54 UTC (rev 221426)
@@ -105,7 +105,6 @@
using Salt = std::array<uint8_t, 8>;
-Salt makeSalt();
std::optional<Salt> readOrMakeSalt(const String& path);
SHA1::Digest computeSHA1(const Data&, const Salt&);