Unreviewed, rolling out r203064.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2016 20:11:03 +0000 (20:11 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Jul 2016 20:11:03 +0000 (20:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159642

This change causes LayoutTest crashes on WK1 ASan (Requested
by ryanhaddad on #webkit).

Reverted changeset:

"Use refs for ResourceLoaders"
https://bugs.webkit.org/show_bug.cgi?id=159592
http://trac.webkit.org/changeset/203064

Patch by Commit Queue <commit-queue@webkit.org> on 2016-07-11

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

Source/WebCore/ChangeLog
Source/WebCore/loader/LoaderStrategy.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.cpp
Source/WebKit/WebCoreSupport/WebResourceLoadScheduler.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit2/WebProcess/Network/WebLoaderStrategy.h

index 9dbe36c..21e92ad 100644 (file)
@@ -1,3 +1,17 @@
+2016-07-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r203064.
+        https://bugs.webkit.org/show_bug.cgi?id=159642
+
+        This change causes LayoutTest crashes on WK1 ASan (Requested
+        by ryanhaddad on #webkit).
+
+        Reverted changeset:
+
+        "Use refs for ResourceLoaders"
+        https://bugs.webkit.org/show_bug.cgi?id=159592
+        http://trac.webkit.org/changeset/203064
+
 2016-07-11  Brent Fulgham  <bfulgham@apple.com>
 
         [WebGL] Check for existing buffer exists for enabled vertex array attributes before permitting glDrawArrays to execute
index 4c1bd76..621ef0d 100644 (file)
@@ -51,9 +51,9 @@ public:
     virtual RefPtr<SubresourceLoader> loadResource(Frame&, CachedResource&, const ResourceRequest&, const ResourceLoaderOptions&) = 0;
     virtual void loadResourceSynchronously(NetworkingContext*, unsigned long identifier, const ResourceRequest&, StoredCredentials, ClientCredentialPolicy, ResourceError&, ResourceResponse&, Vector<char>& data) = 0;
 
-    virtual void remove(ResourceLoader&) = 0;
-    virtual void setDefersLoading(ResourceLoader&, bool) = 0;
-    virtual void crossOriginRedirectReceived(ResourceLoader&, const URL& redirectURL) = 0;
+    virtual void remove(ResourceLoader*) = 0;
+    virtual void setDefersLoading(ResourceLoader*, bool) = 0;
+    virtual void crossOriginRedirectReceived(ResourceLoader*, const URL& redirectURL) = 0;
 
     virtual void servePendingRequests(ResourceLoadPriority minimumPriority = ResourceLoadPriority::VeryLow) = 0;
     virtual void suspendPendingRequests() = 0;
index 37186ae..3609acf 100644 (file)
@@ -73,7 +73,7 @@ ResourceLoader::~ResourceLoader()
 
 void ResourceLoader::finishNetworkLoad()
 {
-    platformStrategies()->loaderStrategy()->remove(*this);
+    platformStrategies()->loaderStrategy()->remove(this);
 
     if (m_handle) {
         ASSERT(m_handle->client() == this);
@@ -223,7 +223,7 @@ void ResourceLoader::setDefersLoading(bool defers)
         start();
     }
 
-    platformStrategies()->loaderStrategy()->setDefersLoading(*this, defers);
+    platformStrategies()->loaderStrategy()->setDefersLoading(this, defers);
 }
 
 FrameLoader* ResourceLoader::frameLoader() const
@@ -279,7 +279,7 @@ void ResourceLoader::setDataBufferingPolicy(DataBufferingPolicy dataBufferingPol
 void ResourceLoader::willSwitchToSubstituteResource()
 {
     ASSERT(!m_documentLoader->isSubstituteLoadPending(this));
-    platformStrategies()->loaderStrategy()->remove(*this);
+    platformStrategies()->loaderStrategy()->remove(this);
     if (m_handle)
         m_handle->cancel();
 }
@@ -367,7 +367,7 @@ void ResourceLoader::willSendRequestInternal(ResourceRequest& request, const Res
 
     bool isRedirect = !redirectResponse.isNull();
     if (isRedirect)
-        platformStrategies()->loaderStrategy()->crossOriginRedirectReceived(*this, request.url());
+        platformStrategies()->loaderStrategy()->crossOriginRedirectReceived(this, request.url());
 
     m_request = request;
 
index fe811ba..79485a7 100644 (file)
@@ -1,3 +1,17 @@
+2016-07-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r203064.
+        https://bugs.webkit.org/show_bug.cgi?id=159642
+
+        This change causes LayoutTest crashes on WK1 ASan (Requested
+        by ryanhaddad on #webkit).
+
+        Reverted changeset:
+
+        "Use refs for ResourceLoaders"
+        https://bugs.webkit.org/show_bug.cgi?id=159592
+        http://trac.webkit.org/changeset/203064
+
 2016-07-08  Alex Christensen  <achristensen@webkit.org>
 
         Use refs for ResourceLoaders
index 5a8fca8..b82accf 100644 (file)
@@ -67,21 +67,20 @@ WebResourceLoadScheduler& webResourceLoadScheduler()
 WebResourceLoadScheduler::HostInformation* WebResourceLoadScheduler::hostForURL(const URL& url, CreateHostPolicy createHostPolicy)
 {
     if (!url.protocolIsInHTTPFamily())
-        return &m_nonHTTPProtocolHost;
+        return m_nonHTTPProtocolHost;
 
     m_hosts.checkConsistency();
     String hostName = url.host();
     HostInformation* host = m_hosts.get(hostName);
     if (!host && createHostPolicy == CreateIfNotFound) {
-        auto newHost = std::make_unique<HostInformation>(hostName, maxRequestsInFlightPerHost);
-        host = newHost.get();
-        m_hosts.add(hostName, WTFMove(newHost));
+        host = new HostInformation(hostName, maxRequestsInFlightPerHost);
+        m_hosts.add(hostName, host);
     }
     return host;
 }
 
 WebResourceLoadScheduler::WebResourceLoadScheduler()
-    : m_nonHTTPProtocolHost(String(), maxRequestsInFlightForNonHTTPProtocols)
+    : m_nonHTTPProtocolHost(new HostInformation(String(), maxRequestsInFlightForNonHTTPProtocols))
     , m_requestTimer(*this, &WebResourceLoadScheduler::requestTimerFired)
     , m_suspendPendingRequestsCount(0)
     , m_isSerialLoadingEnabled(false)
@@ -97,7 +96,7 @@ RefPtr<SubresourceLoader> WebResourceLoadScheduler::loadResource(Frame& frame, C
 {
     RefPtr<SubresourceLoader> loader = SubresourceLoader::create(frame, resource, request, options);
     if (loader)
-        scheduleLoad(*loader);
+        scheduleLoad(loader.get());
 #if PLATFORM(IOS)
     // Since we defer loader initialization until scheduling on iOS, the frame
     // load delegate that would be called in SubresourceLoader::create() on
@@ -119,35 +118,36 @@ RefPtr<NetscapePlugInStreamLoader> WebResourceLoadScheduler::schedulePluginStrea
 {
     RefPtr<NetscapePlugInStreamLoader> loader = NetscapePlugInStreamLoader::create(frame, client, request);
     if (loader)
-        scheduleLoad(*loader);
+        scheduleLoad(loader.get());
     return loader;
 }
 
-void WebResourceLoadScheduler::scheduleLoad(ResourceLoader& resourceLoader)
+void WebResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader)
 {
-    LOG(ResourceLoading, "WebResourceLoadScheduler::load resource %p '%s'", &resourceLoader, resourceLoader.url().string().latin1().data());
+    ASSERT(resourceLoader);
+
+    LOG(ResourceLoading, "WebResourceLoadScheduler::load resource %p '%s'", resourceLoader, resourceLoader->url().string().latin1().data());
 
 #if PLATFORM(IOS)
     // If there's a web archive resource for this URL, we don't need to schedule the load since it will never touch the network.
-    if (!isSuspendingPendingRequests() && resourceLoader.documentLoader()->archiveResourceForURL(resourceLoader.iOSOriginalRequest().url())) {
-        resourceLoader.startLoading();
+    if (!isSuspendingPendingRequests() && resourceLoader->documentLoader()->archiveResourceForURL(resourceLoader->iOSOriginalRequest().url())) {
+        resourceLoader->startLoading();
         return;
     }
 #else
-    if (resourceLoader.documentLoader()->archiveResourceForURL(resourceLoader.request().url())) {
-        resourceLoader.start();
+    if (resourceLoader->documentLoader()->archiveResourceForURL(resourceLoader->request().url())) {
+        resourceLoader->start();
         return;
     }
 #endif
 
 #if PLATFORM(IOS)
-    HostInformation* host = hostForURL(resourceLoader.iOSOriginalRequest().url(), CreateIfNotFound);
+    HostInformation* host = hostForURL(resourceLoader->iOSOriginalRequest().url(), CreateIfNotFound);
 #else
-    HostInformation* host = hostForURL(resourceLoader.url(), CreateIfNotFound);
+    HostInformation* host = hostForURL(resourceLoader->url(), CreateIfNotFound);
 #endif
-    ASSERT(host);
 
-    ResourceLoadPriority priority = resourceLoader.request().priority();
+    ResourceLoadPriority priority = resourceLoader->request().priority();
 
     bool hadRequests = host->hasRequests();
     host->schedule(resourceLoader, priority);
@@ -156,21 +156,21 @@ void WebResourceLoadScheduler::scheduleLoad(ResourceLoader& resourceLoader)
     if (ResourceRequest::resourcePrioritiesEnabled() && !isSuspendingPendingRequests()) {
         // Serve all requests at once to keep the pipeline full at the network layer.
         // FIXME: Does this code do anything useful, given that we also set maxRequestsInFlightPerHost to effectively unlimited on these platforms?
-        servePendingRequests(*host, ResourceLoadPriority::VeryLow);
+        servePendingRequests(host, ResourceLoadPriority::VeryLow);
         return;
     }
 #endif
 
 #if PLATFORM(IOS)
-    if ((priority > ResourceLoadPriority::Low || !resourceLoader.iOSOriginalRequest().url().protocolIsInHTTPFamily() || (priority == ResourceLoadPriority::Low && !hadRequests)) && !isSuspendingPendingRequests()) {
+    if ((priority > ResourceLoadPriority::Low || !resourceLoader->iOSOriginalRequest().url().protocolIsInHTTPFamily() || (priority == ResourceLoadPriority::Low && !hadRequests)) && !isSuspendingPendingRequests()) {
         // Try to request important resources immediately.
-        servePendingRequests(*host, priority);
+        servePendingRequests(host, priority);
         return;
     }
 #else
-    if (priority > ResourceLoadPriority::Low || !resourceLoader.url().protocolIsInHTTPFamily() || (priority == ResourceLoadPriority::Low && !hadRequests)) {
+    if (priority > ResourceLoadPriority::Low || !resourceLoader->url().protocolIsInHTTPFamily() || (priority == ResourceLoadPriority::Low && !hadRequests)) {
         // Try to request important resources immediately.
-        servePendingRequests(*host, priority);
+        servePendingRequests(host, priority);
         return;
     }
 #endif
@@ -180,16 +180,18 @@ void WebResourceLoadScheduler::scheduleLoad(ResourceLoader& resourceLoader)
     scheduleServePendingRequests();
 }
 
-void WebResourceLoadScheduler::remove(ResourceLoader& resourceLoader)
+void WebResourceLoadScheduler::remove(ResourceLoader* resourceLoader)
 {
-    HostInformation* host = hostForURL(resourceLoader.url());
+    ASSERT(resourceLoader);
+
+    HostInformation* host = hostForURL(resourceLoader->url());
     if (host)
         host->remove(resourceLoader);
 #if PLATFORM(IOS)
     // ResourceLoader::url() doesn't start returning the correct value until the load starts. If we get canceled before that, we need to look for originalRequest url instead.
     // FIXME: ResourceLoader::url() should be made to return a sensible value at all times.
-    if (!resourceLoader.iOSOriginalRequest().isNull()) {
-        HostInformation* originalHost = hostForURL(resourceLoader.iOSOriginalRequest().url());
+    if (!resourceLoader->iOSOriginalRequest().isNull()) {
+        HostInformation* originalHost = hostForURL(resourceLoader->iOSOriginalRequest().url());
         if (originalHost && originalHost != host)
             originalHost->remove(resourceLoader);
     }
@@ -197,19 +199,18 @@ void WebResourceLoadScheduler::remove(ResourceLoader& resourceLoader)
     scheduleServePendingRequests();
 }
 
-void WebResourceLoadScheduler::setDefersLoading(ResourceLoader&, bool)
+void WebResourceLoadScheduler::setDefersLoading(ResourceLoader*, bool)
 {
 }
 
-void WebResourceLoadScheduler::crossOriginRedirectReceived(ResourceLoader& resourceLoader, const URL& redirectURL)
+void WebResourceLoadScheduler::crossOriginRedirectReceived(ResourceLoader* resourceLoader, const URL& redirectURL)
 {
-    HostInformation* oldHost = hostForURL(resourceLoader.url());
+    HostInformation* oldHost = hostForURL(resourceLoader->url());
     ASSERT(oldHost);
     if (!oldHost)
         return;
 
     HostInformation* newHost = hostForURL(redirectURL, CreateIfNotFound);
-    ASSERT(newHost);
 
     if (oldHost->name() == newHost->name())
         return;
@@ -229,38 +230,36 @@ void WebResourceLoadScheduler::servePendingRequests(ResourceLoadPriority minimum
     servePendingRequests(m_nonHTTPProtocolHost, minimumPriority);
 
     Vector<HostInformation*> hostsToServe;
-    hostsToServe.reserveInitialCapacity(m_hosts.size());
-    for (const auto& host : m_hosts.values())
-        hostsToServe.uncheckedAppend(host.get());
+    copyValuesToVector(m_hosts, hostsToServe);
 
     for (auto* host : hostsToServe) {
         if (host->hasRequests())
-            servePendingRequests(*host, minimumPriority);
+            servePendingRequests(host, minimumPriority);
         else
-            m_hosts.remove(host->name());
+            delete m_hosts.take(host->name());
     }
 }
 
-void WebResourceLoadScheduler::servePendingRequests(HostInformation& host, ResourceLoadPriority minimumPriority)
+void WebResourceLoadScheduler::servePendingRequests(HostInformation* host, ResourceLoadPriority minimumPriority)
 {
-    LOG(ResourceLoading, "WebResourceLoadScheduler::servePendingRequests HostInformation.m_name='%s'", host.name().latin1().data());
+    LOG(ResourceLoading, "WebResourceLoadScheduler::servePendingRequests HostInformation.m_name='%s'", host->name().latin1().data());
 
     auto priority = ResourceLoadPriority::Highest;
     while (true) {
-        auto& requestsPending = host.requestsPending(priority);
+        auto& requestsPending = host->requestsPending(priority);
         while (!requestsPending.isEmpty()) {
-            Ref<ResourceLoader> resourceLoader = requestsPending.first().copyRef();
+            RefPtr<ResourceLoader> resourceLoader = requestsPending.first();
 
             // For named hosts - which are only http(s) hosts - we should always enforce the connection limit.
             // For non-named hosts - everything but http(s) - we should only enforce the limit if the document isn't done parsing 
             // and we don't know all stylesheets yet.
             Document* document = resourceLoader->frameLoader() ? resourceLoader->frameLoader()->frame().document() : 0;
-            bool shouldLimitRequests = !host.name().isNull() || (document && (document->parsing() || !document->haveStylesheetsLoaded()));
-            if (shouldLimitRequests && host.limitRequests(priority))
+            bool shouldLimitRequests = !host->name().isNull() || (document && (document->parsing() || !document->haveStylesheetsLoaded()));
+            if (shouldLimitRequests && host->limitRequests(priority))
                 return;
 
             requestsPending.removeFirst();
-            host.addLoadInProgress(resourceLoader.get());
+            host->addLoadInProgress(resourceLoader.get());
 #if PLATFORM(IOS)
             if (!IOSApplication::isWebProcess()) {
                 resourceLoader->startLoading();
@@ -286,7 +285,7 @@ void WebResourceLoadScheduler::resumePendingRequests()
     --m_suspendPendingRequestsCount;
     if (m_suspendPendingRequestsCount)
         return;
-    if (!m_hosts.isEmpty() || m_nonHTTPProtocolHost.hasRequests())
+    if (!m_hosts.isEmpty() || m_nonHTTPProtocolHost->hasRequests())
         scheduleServePendingRequests();
 }
     
@@ -332,25 +331,25 @@ unsigned WebResourceLoadScheduler::HostInformation::priorityToIndex(ResourceLoad
     return 0;
 }
 
-void WebResourceLoadScheduler::HostInformation::schedule(ResourceLoader& resourceLoader, ResourceLoadPriority priority)
+void WebResourceLoadScheduler::HostInformation::schedule(ResourceLoader* resourceLoader, ResourceLoadPriority priority)
 {
     m_requestsPending[priorityToIndex(priority)].append(resourceLoader);
 }
     
-void WebResourceLoadScheduler::HostInformation::addLoadInProgress(ResourceLoader& resourceLoader)
+void WebResourceLoadScheduler::HostInformation::addLoadInProgress(ResourceLoader* resourceLoader)
 {
-    LOG(ResourceLoading, "HostInformation '%s' loading '%s'. Current count %d", m_name.latin1().data(), resourceLoader.url().string().latin1().data(), m_requestsLoading.size());
+    LOG(ResourceLoading, "HostInformation '%s' loading '%s'. Current count %d", m_name.latin1().data(), resourceLoader->url().string().latin1().data(), m_requestsLoading.size());
     m_requestsLoading.add(resourceLoader);
 }
     
-void WebResourceLoadScheduler::HostInformation::remove(ResourceLoader& resourceLoader)
+void WebResourceLoadScheduler::HostInformation::remove(ResourceLoader* resourceLoader)
 {
     if (m_requestsLoading.remove(resourceLoader))
         return;
     
     for (auto& requestQueue : m_requestsPending) {
         for (auto it = requestQueue.begin(), end = requestQueue.end(); it != end; ++it) {
-            if (it->ptr() == &resourceLoader) {
+            if (*it == resourceLoader) {
                 requestQueue.remove(it);
                 return;
             }
index 9869a2f..3a593b3 100644 (file)
@@ -20,7 +20,8 @@
     Boston, MA 02110-1301, USA.
  */
 
-#pragma once
+#ifndef WebResourceLoadScheduler_h
+#define WebResourceLoadScheduler_h
 
 #include <WebCore/FrameLoaderTypes.h>
 #include <WebCore/LoaderStrategy.h>
@@ -46,9 +47,9 @@ public:
 
     RefPtr<WebCore::SubresourceLoader> loadResource(WebCore::Frame&, WebCore::CachedResource&, const WebCore::ResourceRequest&, const WebCore::ResourceLoaderOptions&) override;
     void loadResourceSynchronously(WebCore::NetworkingContext*, unsigned long, const WebCore::ResourceRequest&, WebCore::StoredCredentials, WebCore::ClientCredentialPolicy, WebCore::ResourceError&, WebCore::ResourceResponse&, Vector<char>&) override;
-    void remove(WebCore::ResourceLoader&) override;
-    void setDefersLoading(WebCore::ResourceLoader&, bool) override;
-    void crossOriginRedirectReceived(WebCore::ResourceLoader&, const WebCore::URL& redirectURL) override;
+    void remove(WebCore::ResourceLoader*) override;
+    void setDefersLoading(WebCore::ResourceLoader*, bool) override;
+    void crossOriginRedirectReceived(WebCore::ResourceLoader*, const WebCore::URL& redirectURL) override;
     
     void servePendingRequests(WebCore::ResourceLoadPriority minimumPriority = WebCore::ResourceLoadPriority::VeryLow) override;
     void suspendPendingRequests() override;
@@ -65,7 +66,7 @@ protected:
     virtual ~WebResourceLoadScheduler();
 
 private:
-    void scheduleLoad(WebCore::ResourceLoader&);
+    void scheduleLoad(WebCore::ResourceLoader*);
     void scheduleServePendingRequests();
     void requestTimerFired();
 
@@ -78,20 +79,20 @@ private:
         ~HostInformation();
         
         const String& name() const { return m_name; }
-        void schedule(WebCore::ResourceLoader&, WebCore::ResourceLoadPriority = WebCore::ResourceLoadPriority::VeryLow);
-        void addLoadInProgress(WebCore::ResourceLoader&);
-        void remove(WebCore::ResourceLoader&);
+        void schedule(WebCore::ResourceLoader*, WebCore::ResourceLoadPriority = WebCore::ResourceLoadPriority::VeryLow);
+        void addLoadInProgress(WebCore::ResourceLoader*);
+        void remove(WebCore::ResourceLoader*);
         bool hasRequests() const;
         bool limitRequests(WebCore::ResourceLoadPriority) const;
 
-        typedef Deque<Ref<WebCore::ResourceLoader>> RequestQueue;
+        typedef Deque<RefPtr<WebCore::ResourceLoader>> RequestQueue;
         RequestQueue& requestsPending(WebCore::ResourceLoadPriority priority) { return m_requestsPending[priorityToIndex(priority)]; }
 
     private:
         static unsigned priorityToIndex(WebCore::ResourceLoadPriority);
 
         std::array<RequestQueue, WebCore::resourceLoadPriorityCount> m_requestsPending;
-        typedef HashSet<Ref<WebCore::ResourceLoader>> RequestMap;
+        typedef HashSet<RefPtr<WebCore::ResourceLoader>> RequestMap;
         RequestMap m_requestsLoading;
         const String m_name;
         const unsigned m_maxRequestsInFlight;
@@ -103,13 +104,16 @@ private:
     };
     
     HostInformation* hostForURL(const WebCore::URL&, CreateHostPolicy = FindOnly);
-    void servePendingRequests(HostInformation&, WebCore::ResourceLoadPriority);
+    WEBCORE_EXPORT void servePendingRequests(HostInformation*, WebCore::ResourceLoadPriority);
 
-    HashMap<String, std::unique_ptr<HostInformation>> m_hosts;
-    HostInformation m_nonHTTPProtocolHost;
+    typedef HashMap<String, HostInformation*, StringHash> HostMap;
+    HostMap m_hosts;
+    HostInformation* m_nonHTTPProtocolHost;
         
     WebCore::Timer m_requestTimer;
 
     unsigned m_suspendPendingRequestsCount;
     bool m_isSerialLoadingEnabled;
 };
+
+#endif
index f107563..3a9a33d 100644 (file)
@@ -1,3 +1,17 @@
+2016-07-11  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r203064.
+        https://bugs.webkit.org/show_bug.cgi?id=159642
+
+        This change causes LayoutTest crashes on WK1 ASan (Requested
+        by ryanhaddad on #webkit).
+
+        Reverted changeset:
+
+        "Use refs for ResourceLoaders"
+        https://bugs.webkit.org/show_bug.cgi?id=159592
+        http://trac.webkit.org/changeset/203064
+
 2016-07-11  Nan Wang  <n_wang@apple.com>
 
         AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
index a248600..fea2e75 100644 (file)
@@ -217,19 +217,17 @@ void WebLoaderStrategy::scheduleLoad(ResourceLoader& resourceLoader, CachedResou
 
 void WebLoaderStrategy::scheduleInternallyFailedLoad(WebCore::ResourceLoader& resourceLoader)
 {
-    m_internallyFailedResourceLoaders.add(resourceLoader);
+    m_internallyFailedResourceLoaders.add(&resourceLoader);
     m_internallyFailedLoadTimer.startOneShot(0);
 }
 
 void WebLoaderStrategy::internallyFailedLoadTimerFired()
 {
-    Vector<Ref<ResourceLoader>> internallyFailedResourceLoaders;
-    internallyFailedResourceLoaders.reserveInitialCapacity(m_internallyFailedResourceLoaders.size());
-    for (auto& loader : m_internallyFailedResourceLoaders)
-        internallyFailedResourceLoaders.uncheckedAppend(loader.copyRef());
+    Vector<RefPtr<ResourceLoader>> internallyFailedResourceLoaders;
+    copyToVector(m_internallyFailedResourceLoaders, internallyFailedResourceLoaders);
     
-    for (auto& loader : internallyFailedResourceLoaders)
-        loader->didFail(internalError(loader->url()));
+    for (size_t i = 0; i < internallyFailedResourceLoaders.size(); ++i)
+        internallyFailedResourceLoaders[i]->didFail(internalError(internallyFailedResourceLoaders[i]->url()));
 }
 
 void WebLoaderStrategy::startLocalLoad(WebCore::ResourceLoader& resourceLoader)
@@ -238,16 +236,17 @@ void WebLoaderStrategy::startLocalLoad(WebCore::ResourceLoader& resourceLoader)
     m_webResourceLoaders.set(resourceLoader.identifier(), WebResourceLoader::create(resourceLoader));
 }
 
-void WebLoaderStrategy::remove(ResourceLoader& resourceLoader)
+void WebLoaderStrategy::remove(ResourceLoader* resourceLoader)
 {
-    LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::remove, url '%s'", resourceLoader.url().string().utf8().data());
+    ASSERT(resourceLoader);
+    LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::remove, url '%s'", resourceLoader->url().string().utf8().data());
 
     if (m_internallyFailedResourceLoaders.contains(resourceLoader)) {
         m_internallyFailedResourceLoaders.remove(resourceLoader);
         return;
     }
     
-    ResourceLoadIdentifier identifier = resourceLoader.identifier();
+    ResourceLoadIdentifier identifier = resourceLoader->identifier();
     if (!identifier) {
         LOG_ERROR("WebLoaderStrategy removing a ResourceLoader that has no identifier.");
         return;
@@ -265,13 +264,13 @@ void WebLoaderStrategy::remove(ResourceLoader& resourceLoader)
     loader->detachFromCoreLoader();
 }
 
-void WebLoaderStrategy::setDefersLoading(ResourceLoader& resourceLoader, bool defers)
+void WebLoaderStrategy::setDefersLoading(ResourceLoader* resourceLoader, bool defers)
 {
-    ResourceLoadIdentifier identifier = resourceLoader.identifier();
+    ResourceLoadIdentifier identifier = resourceLoader->identifier();
     WebProcess::singleton().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::SetDefersLoading(identifier, defers), 0);
 }
 
-void WebLoaderStrategy::crossOriginRedirectReceived(ResourceLoader&, const URL&)
+void WebLoaderStrategy::crossOriginRedirectReceived(ResourceLoader*, const URL&)
 {
     // We handle cross origin redirects entirely within the NetworkProcess.
     // We override this call in the WebProcess to make it a no-op.
index 46b2f21..c94bac2 100644 (file)
@@ -46,9 +46,9 @@ public:
     RefPtr<WebCore::SubresourceLoader> loadResource(WebCore::Frame&, WebCore::CachedResource&, const WebCore::ResourceRequest&, const WebCore::ResourceLoaderOptions&) override;
     void loadResourceSynchronously(WebCore::NetworkingContext*, unsigned long resourceLoadIdentifier, const WebCore::ResourceRequest&, WebCore::StoredCredentials, WebCore::ClientCredentialPolicy, WebCore::ResourceError&, WebCore::ResourceResponse&, Vector<char>& data) override;
 
-    void remove(WebCore::ResourceLoader&) override;
-    void setDefersLoading(WebCore::ResourceLoader&, bool) override;
-    void crossOriginRedirectReceived(WebCore::ResourceLoader&, const WebCore::URL& redirectURL) override;
+    void remove(WebCore::ResourceLoader*) override;
+    void setDefersLoading(WebCore::ResourceLoader*, bool) override;
+    void crossOriginRedirectReceived(WebCore::ResourceLoader*, const WebCore::URL& redirectURL) override;
     
     void servePendingRequests(WebCore::ResourceLoadPriority minimumPriority) override;
 
@@ -68,7 +68,7 @@ private:
     void internallyFailedLoadTimerFired();
     void startLocalLoad(WebCore::ResourceLoader&);
 
-    HashSet<Ref<WebCore::ResourceLoader>> m_internallyFailedResourceLoaders;
+    HashSet<RefPtr<WebCore::ResourceLoader>> m_internallyFailedResourceLoaders;
     RunLoop::Timer<WebLoaderStrategy> m_internallyFailedLoadTimer;
     
     HashMap<unsigned long, RefPtr<WebResourceLoader>> m_webResourceLoaders;