DocumentLoader::cachedResourceLoader() should return a reference.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Oct 2013 01:35:45 +0000 (01:35 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Oct 2013 01:35:45 +0000 (01:35 +0000)
<https://webkit.org/b/123303>

..and while we're at it, make DocumentLoader::m_cachedResourceLoader
a Ref, and have CachedResourceLoader::create return a PassRef.

Reviewed by Sam Weinig.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157979 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.cpp
Source/WebCore/loader/DocumentLoader.h
Source/WebCore/loader/SubresourceLoader.cpp
Source/WebCore/loader/cache/CachedResourceLoader.h

index 522dc78..d3b1726 100644 (file)
@@ -1,3 +1,13 @@
+2013-10-24  Andreas Kling  <akling@apple.com>
+
+        DocumentLoader::cachedResourceLoader() should return a reference.
+        <https://webkit.org/b/123303>
+
+        ..and while we're at it, make DocumentLoader::m_cachedResourceLoader
+        a Ref, and have CachedResourceLoader::create return a PassRef.
+
+        Reviewed by Sam Weinig.
+
 2013-10-24  Anders Carlsson  <andersca@apple.com>
 
         Stop bringing in the std namespace
index edc8a25..d39698b 100644 (file)
@@ -504,7 +504,7 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses)
         setURL(url);
 
     if (m_frame)
-        m_cachedResourceLoader = m_frame->loader().activeDocumentLoader()->cachedResourceLoader();
+        m_cachedResourceLoader = &m_frame->loader().activeDocumentLoader()->cachedResourceLoader();
     if (!m_cachedResourceLoader)
         m_cachedResourceLoader = CachedResourceLoader::create(nullptr);
     m_cachedResourceLoader->setDocument(this);
index 01b393b..77dcf13 100644 (file)
@@ -104,7 +104,7 @@ namespace WebCore {
         const ResourceRequest& request() const;
         ResourceRequest& request();
 
-        CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader.get(); }
+        CachedResourceLoader& cachedResourceLoader() { return m_cachedResourceLoader.get(); }
 
         const SubstituteData& substituteData() const { return m_substituteData; }
 
@@ -312,7 +312,7 @@ namespace WebCore {
         void clearMainResource();
 
         Frame* m_frame;
-        RefPtr<CachedResourceLoader> m_cachedResourceLoader;
+        Ref<CachedResourceLoader> m_cachedResourceLoader;
 
         CachedResourceHandle<CachedRawResource> m_mainResource;
         ResourceLoaderSet m_subresourceLoaders;
index 2da000a..1b8a1e5 100644 (file)
@@ -137,11 +137,11 @@ void SubresourceLoader::willSendRequest(ResourceRequest& newRequest, const Resou
             memoryCache()->revalidationFailed(m_resource);
         }
         
-        if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url(), options())) {
+        if (!m_documentLoader->cachedResourceLoader().canRequest(m_resource->type(), newRequest.url(), options())) {
             cancel();
             return;
         }
-        if (m_resource->type() == CachedResource::ImageResource && m_documentLoader->cachedResourceLoader()->shouldDeferImageLoad(newRequest.url())) {
+        if (m_resource->type() == CachedResource::ImageResource && m_documentLoader->cachedResourceLoader().shouldDeferImageLoad(newRequest.url())) {
             cancel();
             return;
         }
@@ -348,7 +348,7 @@ void SubresourceLoader::notifyDone()
         return;
 
     m_requestCountTracker.clear();
-    m_documentLoader->cachedResourceLoader()->loadDone(m_resource);
+    m_documentLoader->cachedResourceLoader().loadDone(m_resource);
     if (reachedTerminalState())
         return;
     m_documentLoader->removeSubresourceLoader(this);
index 9db9b59..19c970a 100644 (file)
@@ -69,7 +69,7 @@ friend class ImageLoader;
 friend class ResourceCacheValidationSuppressor;
 
 public:
-    static PassRefPtr<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(new CachedResourceLoader(documentLoader)); }
+    static PassRef<CachedResourceLoader> create(DocumentLoader* documentLoader) { return adoptRef(*new CachedResourceLoader(documentLoader)); }
     ~CachedResourceLoader();
 
     CachedResourceHandle<CachedImage> requestImage(CachedResourceRequest&);