Changeset 194338 in webkit


Ignore:
Timestamp:
Dec 21, 2015 12:01:35 PM (8 years ago)
Author:
Antti Koivisto
Message:

Factor NetworkResourceLoader code for storing a cache entry into a function
https://bugs.webkit.org/show_bug.cgi?id=152467

Reviewed by Andreas Kling.

  • NetworkProcess/NetworkResourceLoader.cpp:

(WebKit::NetworkResourceLoader::didFinishLoading):

Having m_cacheEntryForValidation already implies canUseCache() so remove the test from this path.
Move storing to the end of the function so we don't delay DidFinishResourceLoad message on it.

(WebKit::NetworkResourceLoader::sendBufferMaybeAborting):
(WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):

Factor to a function.
Remove m_response.isHTTP() test as it is covered by NetworkCache::store().
Remove !isPrivateSession test as it is covered by NetworkResourceLoader::canUseCache().

(WebKit::NetworkResourceLoader::didRetrieveCacheEntry):

  • NetworkProcess/NetworkResourceLoader.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r194337 r194338  
     12015-12-21  Antti Koivisto  <antti@apple.com>
     2
     3        Factor NetworkResourceLoader code for storing a cache entry into a function
     4        https://bugs.webkit.org/show_bug.cgi?id=152467
     5
     6        Reviewed by Andreas Kling.
     7
     8        * NetworkProcess/NetworkResourceLoader.cpp:
     9        (WebKit::NetworkResourceLoader::didFinishLoading):
     10
     11            Having m_cacheEntryForValidation already implies canUseCache() so remove the test from this path.
     12            Move storing to the end of the function so we don't delay DidFinishResourceLoad message on it.
     13
     14        (WebKit::NetworkResourceLoader::sendBufferMaybeAborting):
     15        (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):
     16
     17            Factor to a function.
     18            Remove m_response.isHTTP() test as it is covered by NetworkCache::store().
     19            Remove !isPrivateSession test as it is covered by NetworkResourceLoader::canUseCache().
     20
     21        (WebKit::NetworkResourceLoader::didRetrieveCacheEntry):
     22        * NetworkProcess/NetworkResourceLoader.h:
     23
    1242015-12-21  Antti Koivisto  <antti@apple.com>
    225
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp

    r194337 r194338  
    339339{
    340340#if ENABLE(NETWORK_CACHE)
    341     if (canUseCache(m_networkLoad->currentRequest())) {
    342         if (m_cacheEntryForValidation) {
    343             // 304 Not Modified
    344             ASSERT(m_response.httpStatusCode() == 304);
    345             LOG(NetworkCache, "(NetworkProcess) revalidated");
    346             didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation));
    347             return;
    348         }
    349 
    350         bool isPrivateSession = sessionID().isEphemeral();
    351         if (m_bufferedDataForCache && m_response.isHTTP() && !isPrivateSession) {
    352             // Keep the connection alive.
    353             RefPtr<NetworkConnectionToWebProcess> connection(&connectionToWebProcess());
    354             RefPtr<NetworkResourceLoader> loader(this);
    355             NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTF::move(m_bufferedDataForCache), [loader, connection](NetworkCache::MappedBody& mappedBody) {
    356 #if ENABLE(SHAREABLE_RESOURCE)
    357                 if (mappedBody.shareableResourceHandle.isNull())
    358                     return;
    359                 LOG(NetworkCache, "(NetworkProcess) sending DidCacheResource");
    360                 loader->send(Messages::NetworkProcessConnection::DidCacheResource(loader->originalRequest(), mappedBody.shareableResourceHandle, loader->sessionID()));
    361 #endif
    362             });
    363         }
     341    if (m_cacheEntryForValidation) {
     342        // 304 Not Modified
     343        ASSERT(m_response.httpStatusCode() == 304);
     344        LOG(NetworkCache, "(NetworkProcess) revalidated");
     345        didRetrieveCacheEntry(WTF::move(m_cacheEntryForValidation));
     346        return;
    364347    }
    365348#endif
     
    376359        send(Messages::WebResourceLoader::DidFinishResourceLoad(finishTime));
    377360    }
     361
     362#if ENABLE(NETWORK_CACHE)
     363    tryStoreAsCacheEntry();
     364#endif
    378365
    379366    cleanup();
     
    501488
    502489#if ENABLE(NETWORK_CACHE)
     490void NetworkResourceLoader::tryStoreAsCacheEntry()
     491{
     492    if (!canUseCache(m_networkLoad->currentRequest()))
     493        return;
     494    if (!m_bufferedDataForCache)
     495        return;
     496
     497    // Keep the connection alive.
     498    RefPtr<NetworkConnectionToWebProcess> connection(&connectionToWebProcess());
     499    RefPtr<NetworkResourceLoader> loader(this);
     500    NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTF::move(m_bufferedDataForCache), [loader, connection](NetworkCache::MappedBody& mappedBody) {
     501#if ENABLE(SHAREABLE_RESOURCE)
     502        if (mappedBody.shareableResourceHandle.isNull())
     503            return;
     504        LOG(NetworkCache, "(NetworkProcess) sending DidCacheResource");
     505        loader->send(Messages::NetworkProcessConnection::DidCacheResource(loader->originalRequest(), mappedBody.shareableResourceHandle, loader->sessionID()));
     506#endif
     507    });
     508}
     509
    503510void NetworkResourceLoader::didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry> entry)
    504511{
  • trunk/Source/WebKit2/NetworkProcess/NetworkResourceLoader.h

    r194337 r194338  
    116116    bool canUseCachedRedirect(const WebCore::ResourceRequest&) const;
    117117
     118    void tryStoreAsCacheEntry();
    118119    void retrieveCacheEntry(const WebCore::ResourceRequest&);
    119120    void didRetrieveCacheEntry(std::unique_ptr<NetworkCache::Entry>);
Note: See TracChangeset for help on using the changeset viewer.