Changeset 221426 in webkit


Ignore:
Timestamp:
Aug 31, 2017 11:19:54 AM (7 years ago)
Author:
commit-queue@webkit.org
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 <youenn@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:
Location:
trunk/Source/WebKit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r221420 r221426  
     12017-08-31  Youenn Fablet  <youenn@apple.com>
     2
     3        Do not create a salt if the CacheStorage engine should not persist
     4        https://bugs.webkit.org/show_bug.cgi?id=176138
     5
     6        Reviewed by Alex Christensen.
     7
     8        * NetworkProcess/cache/CacheStorageEngine.cpp:
     9        (WebKit::CacheStorage::Engine::~Engine): Ensuring that Caches will not try using the engine if it goes away.
     10        (WebKit::CacheStorage::Engine::initialize): Removing making a salt if engine data is not persistent.
     11        * NetworkProcess/cache/CacheStorageEngine.h: Check persistency according the root path. If it is null, caches should not try to do persistency.
     12        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
     13        (WebKit::CacheStorage::cachesRootPath):
     14        (WebKit::CacheStorage::Caches::initialize):
     15        (WebKit::CacheStorage::Caches::detach):
     16        (WebKit::CacheStorage::Caches::readCachesFromDisk):
     17        (WebKit::CacheStorage::Caches::writeCachesToDisk):
     18        * NetworkProcess/cache/CacheStorageEngineCaches.h:
     19        (WebKit::CacheStorage::Caches::shouldPersist const):
     20        * NetworkProcess/cache/NetworkCacheData.cpp: Making makeSalt private again.
     21        (WebKit::NetworkCache::makeSalt):
     22        * NetworkProcess/cache/NetworkCacheData.h:
     23
     24
    1252017-08-31  Carlos Garcia Campos  <cgarcia@igalia.com>
    226
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp

    r221410 r221426  
    4949}
    5050
     51Engine::~Engine()
     52{
     53    for (auto& caches : m_caches.values())
     54        caches->detach();
     55}
     56
    5157Engine& Engine::from(PAL::SessionID sessionID)
    5258{
     
    239245
    240246    if (!shouldPersist()) {
    241         m_salt = makeSalt();
    242247        callback(std::nullopt);
    243248        return;
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h

    r221410 r221426  
    4646class Engine : public ThreadSafeRefCounted<Engine> {
    4747public:
     48    ~Engine();
     49
    4850    static Engine& from(PAL::SessionID);
    4951    static void destroyEngine(PAL::SessionID);
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp

    r221403 r221426  
    3939static inline String cachesRootPath(Engine& engine, const String& origin)
    4040{
     41    if (!engine.shouldPersist())
     42        return { };
     43
    4144    Key key(engine.rootPath(), { }, { }, origin, engine.salt());
    4245    return WebCore::pathByAppendingComponent(engine.rootPath(), key.partitionHashAsString());
     
    5659void Caches::initialize(WebCore::DOMCache::CompletionCallback&& callback)
    5760{
    58     if (m_isInitialized || !m_engine || !m_engine->shouldPersist()) {
     61    if (m_isInitialized || m_rootPath.isNull()) {
    5962        callback(std::nullopt);
    6063        return;
     
    8992            callback(std::nullopt);
    9093    });
     94}
     95
     96void Caches::detach()
     97{
     98    m_engine = nullptr;
     99    m_rootPath = { };
    91100}
    92101
     
    177186    ASSERT(m_caches.isEmpty());
    178187
    179     if (!m_engine->shouldPersist()) {
     188    if (!shouldPersist()) {
    180189        callback(Vector<Cache> { });
    181190        return;
     
    210219void Caches::writeCachesToDisk(CompletionCallback&& callback)
    211220{
    212     if (!m_engine->shouldPersist()) {
     221    if (!shouldPersist()) {
    213222        callback(std::nullopt);
    214223        return;
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h

    r221403 r221426  
    5252
    5353    void clearMemoryRepresentation();
    54     void detach() { m_engine = nullptr; }
     54    void detach();
    5555
    5656private:
     
    5959    void readCachesFromDisk(WTF::Function<void(Expected<Vector<Cache>, WebCore::DOMCache::Error>&&)>&&);
    6060    void writeCachesToDisk(WebCore::DOMCache::CompletionCallback&&);
     61
     62    bool shouldPersist() const { return !m_rootPath.isNull(); }
    6163
    6264    bool m_isInitialized { false };
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.cpp

    r221403 r221426  
    129129}
    130130
    131 Salt makeSalt()
     131static Salt makeSalt()
    132132{
    133133    Salt salt;
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheData.h

    r221403 r221426  
    106106using Salt = std::array<uint8_t, 8>;
    107107
    108 Salt makeSalt();
    109108std::optional<Salt> readOrMakeSalt(const String& path);
    110109SHA1::Digest computeSHA1(const Data&, const Salt&);
Note: See TracChangeset for help on using the changeset viewer.