changeset 9668:b75591ee263b

8153501: Crash in ResourceLoader::releaseResources() Reviewed-by: kcr, ghb, mbilla, azvegint
author arajkumar
date Fri, 08 Apr 2016 07:27:08 -0700
parents 84e09aadadf1
children e6f091c88d83
files modules/web/src/main/native/Source/WebCore/loader/DocumentLoader.cpp modules/web/src/main/native/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp modules/web/src/main/native/Source/WebCore/loader/NetscapePlugInStreamLoader.h modules/web/src/main/native/Source/WebCore/loader/ResourceLoadScheduler.cpp modules/web/src/main/native/Source/WebCore/loader/ResourceLoadScheduler.h modules/web/src/main/native/Source/WebCore/loader/ResourceLoader.cpp modules/web/src/main/native/Source/WebCore/loader/ResourceLoader.h modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.cpp modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.h modules/web/src/main/native/Source/WebCore/loader/cache/CachedResource.cpp modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.h modules/web/src/main/native/Source/WebCore/plugins/PluginStream.cpp
diffstat 12 files changed, 31 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/modules/web/src/main/native/Source/WebCore/loader/DocumentLoader.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/DocumentLoader.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -914,7 +914,7 @@
     if (!m_frame || isLoading())
         return;
 
-    ASSERT(this == frameLoader()->activeDocumentLoader());
+    // ASSERT(this == frameLoader()->activeDocumentLoader());
     m_frame->document()->domWindow()->finishedLoading();
 }
 
--- a/modules/web/src/main/native/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/NetscapePlugInStreamLoader.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -36,8 +36,8 @@
 
 namespace WebCore {
 
-NetscapePlugInStreamLoader::NetscapePlugInStreamLoader(Frame* frame, NetscapePlugInStreamLoaderClient* client)
-    : ResourceLoader(frame, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, AskClientForAllCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType))
+NetscapePlugInStreamLoader::NetscapePlugInStreamLoader(DocumentLoader* documentLoader, NetscapePlugInStreamLoaderClient* client)
+    : ResourceLoader(documentLoader, ResourceLoaderOptions(SendCallbacks, SniffContent, DoNotBufferData, AllowStoredCredentials, AskClientForAllCredentials, SkipSecurityCheck, UseDefaultOriginRestrictionsForType))
     , m_client(client)
 {
 }
@@ -46,9 +46,9 @@
 {
 }
 
-PassRefPtr<NetscapePlugInStreamLoader> NetscapePlugInStreamLoader::create(Frame* frame, NetscapePlugInStreamLoaderClient* client, const ResourceRequest& request)
+PassRefPtr<NetscapePlugInStreamLoader> NetscapePlugInStreamLoader::create(DocumentLoader* documentLoader, NetscapePlugInStreamLoaderClient* client, const ResourceRequest& request)
 {
-    RefPtr<NetscapePlugInStreamLoader> loader(adoptRef(new NetscapePlugInStreamLoader(frame, client)));
+    RefPtr<NetscapePlugInStreamLoader> loader(adoptRef(new NetscapePlugInStreamLoader(documentLoader, client)));
     loader->documentLoader()->addPlugInStreamLoader(loader.get());
     if (!loader->init(request))
         return 0;
--- a/modules/web/src/main/native/Source/WebCore/loader/NetscapePlugInStreamLoader.h	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/NetscapePlugInStreamLoader.h	Fri Apr 08 07:27:08 2016 -0700
@@ -50,7 +50,7 @@
 
 class NetscapePlugInStreamLoader : public ResourceLoader {
 public:
-    static PassRefPtr<NetscapePlugInStreamLoader> create(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
+    static PassRefPtr<NetscapePlugInStreamLoader> create(DocumentLoader*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
     virtual ~NetscapePlugInStreamLoader();
 
     bool isDone() const;
@@ -64,7 +64,7 @@
 
     virtual void releaseResources() override;
 
-    NetscapePlugInStreamLoader(Frame*, NetscapePlugInStreamLoaderClient*);
+    NetscapePlugInStreamLoader(DocumentLoader*, NetscapePlugInStreamLoaderClient*);
 
     virtual void willCancel(const ResourceError&) override;
     virtual void didCancel(const ResourceError&) override;
--- a/modules/web/src/main/native/Source/WebCore/loader/ResourceLoadScheduler.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/ResourceLoadScheduler.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -108,9 +108,9 @@
 {
 }
 
-PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(Frame* frame, CachedResource* resource, const ResourceRequest& request, ResourceLoadPriority priority, const ResourceLoaderOptions& options)
+PassRefPtr<SubresourceLoader> ResourceLoadScheduler::scheduleSubresourceLoad(DocumentLoader* documentLoader, CachedResource* resource, const ResourceRequest& request, ResourceLoadPriority priority, const ResourceLoaderOptions& options)
 {
-    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, resource, request, options);
+    RefPtr<SubresourceLoader> loader = SubresourceLoader::create(documentLoader, resource, request, options);
     if (loader)
         scheduleLoad(loader.get(), priority);
 #if PLATFORM(IOS)
@@ -125,9 +125,9 @@
     return loader.release();
 }
 
-PassRefPtr<NetscapePlugInStreamLoader> ResourceLoadScheduler::schedulePluginStreamLoad(Frame* frame, NetscapePlugInStreamLoaderClient* client, const ResourceRequest& request)
+PassRefPtr<NetscapePlugInStreamLoader> ResourceLoadScheduler::schedulePluginStreamLoad(DocumentLoader* documentLoader, NetscapePlugInStreamLoaderClient* client, const ResourceRequest& request)
 {
-    PassRefPtr<NetscapePlugInStreamLoader> loader = NetscapePlugInStreamLoader::create(frame, client, request);
+    PassRefPtr<NetscapePlugInStreamLoader> loader = NetscapePlugInStreamLoader::create(documentLoader, client, request);
     if (loader)
         scheduleLoad(loader.get(), ResourceLoadPriorityLow);
     return loader;
--- a/modules/web/src/main/native/Source/WebCore/loader/ResourceLoadScheduler.h	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/ResourceLoadScheduler.h	Fri Apr 08 07:27:08 2016 -0700
@@ -44,14 +44,15 @@
 class ResourceLoader;
 class ResourceRequest;
 class SubresourceLoader;
+class DocumentLoader;
 
 class ResourceLoadScheduler {
     WTF_MAKE_NONCOPYABLE(ResourceLoadScheduler); WTF_MAKE_FAST_ALLOCATED;
 public:
     friend ResourceLoadScheduler* resourceLoadScheduler();
 
-    virtual PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(Frame*, CachedResource*, const ResourceRequest&, ResourceLoadPriority, const ResourceLoaderOptions&);
-    virtual PassRefPtr<NetscapePlugInStreamLoader> schedulePluginStreamLoad(Frame*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
+    virtual PassRefPtr<SubresourceLoader> scheduleSubresourceLoad(DocumentLoader*, CachedResource*, const ResourceRequest&, ResourceLoadPriority, const ResourceLoaderOptions&);
+    virtual PassRefPtr<NetscapePlugInStreamLoader> schedulePluginStreamLoad(DocumentLoader*, NetscapePlugInStreamLoaderClient*, const ResourceRequest&);
     virtual void remove(ResourceLoader*);
     virtual void crossOriginRedirectReceived(ResourceLoader*, const URL& redirectURL);
 
--- a/modules/web/src/main/native/Source/WebCore/loader/ResourceLoader.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/ResourceLoader.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -53,14 +53,14 @@
 
 namespace WebCore {
 
-ResourceLoader::ResourceLoader(Frame* frame, ResourceLoaderOptions options)
-    : m_frame(frame)
-    , m_documentLoader(frame->loader().activeDocumentLoader())
+ResourceLoader::ResourceLoader(DocumentLoader* documentLoader, ResourceLoaderOptions options)
+    : m_frame(documentLoader->frame())
+    , m_documentLoader(documentLoader)
     , m_identifier(0)
     , m_reachedTerminalState(false)
     , m_notifiedLoadComplete(false)
     , m_cancellationStatus(NotCancelled)
-    , m_defersLoading(frame->page()->defersLoading())
+    , m_defersLoading(m_frame->page()->defersLoading())
     , m_options(options)
 {
 }
--- a/modules/web/src/main/native/Source/WebCore/loader/ResourceLoader.h	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/ResourceLoader.h	Fri Apr 08 07:27:08 2016 -0700
@@ -155,7 +155,7 @@
     void setDataBufferingPolicy(DataBufferingPolicy);
 
 protected:
-    ResourceLoader(Frame*, ResourceLoaderOptions);
+    ResourceLoader(DocumentLoader*, ResourceLoaderOptions);
 
     friend class ResourceLoadScheduler; // for access to start()
     // start() actually sends the load to the network (unless the load is being
--- a/modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -64,12 +64,12 @@
     m_cachedResourceLoader->decrementRequestCount(m_resource);
 }
 
-SubresourceLoader::SubresourceLoader(Frame* frame, CachedResource* resource, const ResourceLoaderOptions& options)
-    : ResourceLoader(frame, options)
+SubresourceLoader::SubresourceLoader(DocumentLoader* documentLoader, CachedResource* resource, const ResourceLoaderOptions& options)
+    : ResourceLoader(documentLoader, options)
     , m_resource(resource)
     , m_loadingMultipartContent(false)
     , m_state(Uninitialized)
-    , m_requestCountTracker(adoptPtr(new RequestCountTracker(frame->document()->cachedResourceLoader(), resource)))
+    , m_requestCountTracker(adoptPtr(new RequestCountTracker(&documentLoader->cachedResourceLoader(), resource)))
 {
 #ifndef NDEBUG
     subresourceLoaderCounter.increment();
@@ -85,9 +85,9 @@
 #endif
 }
 
-PassRefPtr<SubresourceLoader> SubresourceLoader::create(Frame* frame, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
+PassRefPtr<SubresourceLoader> SubresourceLoader::create(DocumentLoader* documentLoader, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
 {
-    RefPtr<SubresourceLoader> subloader(adoptRef(new SubresourceLoader(frame, resource, options)));
+    RefPtr<SubresourceLoader> subloader(adoptRef(new SubresourceLoader(documentLoader, resource, options)));
 #if PLATFORM(IOS)
     if (!applicationIsWebProcess()) {
         // On iOS, do not invoke synchronous resource load delegates while resource load scheduling
--- a/modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.h	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/SubresourceLoader.h	Fri Apr 08 07:27:08 2016 -0700
@@ -39,12 +39,13 @@
 class CachedResource;
 class CachedResourceLoader;
 class Document;
+class DocumentLoader;
 class PageActivityAssertionToken;
 class ResourceRequest;
 
 class SubresourceLoader : public ResourceLoader {
 public:
-    static PassRefPtr<SubresourceLoader> create(Frame*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
+    static PassRefPtr<SubresourceLoader> create(DocumentLoader*, CachedResource*, const ResourceRequest&, const ResourceLoaderOptions&);
 
     virtual ~SubresourceLoader();
 
@@ -60,7 +61,7 @@
 #endif
 
 private:
-    SubresourceLoader(Frame*, CachedResource*, const ResourceLoaderOptions&);
+    SubresourceLoader(DocumentLoader*, CachedResource*, const ResourceLoaderOptions&);
 
     virtual bool init(const ResourceRequest&) override;
 
--- a/modules/web/src/main/native/Source/WebCore/loader/cache/CachedResource.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/cache/CachedResource.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -311,7 +311,7 @@
         m_fragmentIdentifierForRequest = String();
     }
 
-    m_loader = platformStrategies()->loaderStrategy()->resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->frame(), this, request, request.priority(), options);
+    m_loader = platformStrategies()->loaderStrategy()->resourceLoadScheduler()->scheduleSubresourceLoad(cachedResourceLoader->documentLoader(), this, request, request.priority(), options);
     if (!m_loader) {
         failBeforeStarting();
         return;
--- a/modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.h	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/loader/cache/CachedResourceLoader.h	Fri Apr 08 07:27:08 2016 -0700
@@ -110,6 +110,8 @@
     Frame* frame() const; // Can be null
     Document* document() const { return m_document; } // Can be null
     void setDocument(Document* document) { m_document = document; }
+
+    DocumentLoader* documentLoader() const { return m_documentLoader; }
     void clearDocumentLoader() { m_documentLoader = 0; }
 
     void removeCachedResource(CachedResource*) const;
--- a/modules/web/src/main/native/Source/WebCore/plugins/PluginStream.cpp	Thu Apr 07 13:41:18 2016 -0700
+++ b/modules/web/src/main/native/Source/WebCore/plugins/PluginStream.cpp	Fri Apr 08 07:27:08 2016 -0700
@@ -95,7 +95,7 @@
 void PluginStream::start()
 {
     ASSERT(!m_loadManually);
-    m_loader = resourceLoadScheduler()->schedulePluginStreamLoad(m_frame, this, m_resourceRequest);
+    m_loader = resourceLoadScheduler()->schedulePluginStreamLoad(m_frame->loader().activeDocumentLoader(), this, m_resourceRequest);
 }
 
 void PluginStream::stop()