Remove load scheduling code from network process
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Aug 2014 18:04:39 +0000 (18:04 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 25 Aug 2014 18:04:39 +0000 (18:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136199

Reviewed by Darin Adler.

Most platforms just flush resource loads directly to the networking layer by
making the parallel load count large. Also we always pass ResourceLoadPriorityHighest
to the scheduler so no actual scheduling happens. This is effectively dead code.

Keep basic support for serializing loads. This is only used for testing.

* NetworkProcess/HostRecord.cpp: Removed.
* NetworkProcess/HostRecord.h: Removed.
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::servePendingRequests):
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::getNetworkProcessStatistics):
* NetworkProcess/NetworkResourceLoadScheduler.cpp:
(WebKit::NetworkResourceLoadScheduler::NetworkResourceLoadScheduler):
(WebKit::NetworkResourceLoadScheduler::scheduleLoader):
(WebKit::NetworkResourceLoadScheduler::removeLoader):
(WebKit::NetworkResourceLoadScheduler::loadsPendingCount):
(WebKit::NetworkResourceLoadScheduler::loadsActiveCount):
(WebKit::NetworkResourceLoadScheduler::scheduleServePendingRequests): Deleted.
(WebKit::NetworkResourceLoadScheduler::requestTimerFired): Deleted.
(WebKit::NetworkResourceLoadScheduler::hostForURL): Deleted.
(WebKit::NetworkResourceLoadScheduler::receivedRedirect): Deleted.
(WebKit::NetworkResourceLoadScheduler::servePendingRequests): Deleted.
(WebKit::NetworkResourceLoadScheduler::removeScheduledLoaders): Deleted.
(WebKit::NetworkResourceLoadScheduler::scheduleRemoveLoader): Deleted.
(WebKit::NetworkResourceLoadScheduler::hostsPendingCount): Deleted.
(WebKit::NetworkResourceLoadScheduler::hostsActiveCount): Deleted.
* NetworkProcess/NetworkResourceLoadScheduler.h:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::~NetworkResourceLoader):
(WebKit::NetworkResourceLoader::cleanup):
(WebKit::NetworkResourceLoader::continueWillSendRequest):
* NetworkProcess/NetworkResourceLoader.h:
(WebKit::NetworkResourceLoader::isLoadingMainResource):
(WebKit::NetworkResourceLoader::setHostRecord): Deleted.
(WebKit::NetworkResourceLoader::hostRecord): Deleted.
* NetworkProcess/mac/NetworkResourceLoadSchedulerMac.mm:
(WebKit::NetworkResourceLoadScheduler::platformInitializeNetworkSettings):
(WebKit::NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountPerHost): Deleted.
* NetworkProcess/soup/NetworkResourceLoadSchedulerSoup.cpp:
(WebKit::NetworkResourceLoadScheduler::platformInitializeNetworkSettings):
(WebKit::NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountPerHost): Deleted.
* WebKit2.xcodeproj/project.pbxproj:

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

13 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/HostRecord.cpp [deleted file]
Source/WebKit2/NetworkProcess/HostRecord.h [deleted file]
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoadScheduler.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoadScheduler.h
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
Source/WebKit2/NetworkProcess/mac/NetworkResourceLoadSchedulerMac.mm
Source/WebKit2/NetworkProcess/soup/NetworkResourceLoadSchedulerSoup.cpp
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

index d058eb1..5fb1c90 100644 (file)
@@ -146,7 +146,6 @@ endif ()
 
 set(WebKit2_SOURCES
     NetworkProcess/AsynchronousNetworkLoaderClient.cpp
-    NetworkProcess/HostRecord.cpp
     NetworkProcess/NetworkConnectionToWebProcess.cpp
     NetworkProcess/NetworkProcess.cpp
     NetworkProcess/NetworkProcessPlatformStrategies.cpp
index d38b48c..d972f15 100644 (file)
@@ -1,3 +1,54 @@
+2014-08-25  Antti Koivisto  <antti@apple.com>
+
+        Remove load scheduling code from network process
+        https://bugs.webkit.org/show_bug.cgi?id=136199
+
+        Reviewed by Darin Adler.
+
+        Most platforms just flush resource loads directly to the networking layer by
+        making the parallel load count large. Also we always pass ResourceLoadPriorityHighest
+        to the scheduler so no actual scheduling happens. This is effectively dead code.
+
+        Keep basic support for serializing loads. This is only used for testing.
+
+        * NetworkProcess/HostRecord.cpp: Removed.
+        * NetworkProcess/HostRecord.h: Removed.
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::servePendingRequests):
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::getNetworkProcessStatistics):
+        * NetworkProcess/NetworkResourceLoadScheduler.cpp:
+        (WebKit::NetworkResourceLoadScheduler::NetworkResourceLoadScheduler):
+        (WebKit::NetworkResourceLoadScheduler::scheduleLoader):
+        (WebKit::NetworkResourceLoadScheduler::removeLoader):
+        (WebKit::NetworkResourceLoadScheduler::loadsPendingCount):
+        (WebKit::NetworkResourceLoadScheduler::loadsActiveCount):
+        (WebKit::NetworkResourceLoadScheduler::scheduleServePendingRequests): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::requestTimerFired): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::hostForURL): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::receivedRedirect): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::servePendingRequests): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::removeScheduledLoaders): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::scheduleRemoveLoader): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::hostsPendingCount): Deleted.
+        (WebKit::NetworkResourceLoadScheduler::hostsActiveCount): Deleted.
+        * NetworkProcess/NetworkResourceLoadScheduler.h:
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::~NetworkResourceLoader):
+        (WebKit::NetworkResourceLoader::cleanup):
+        (WebKit::NetworkResourceLoader::continueWillSendRequest):
+        * NetworkProcess/NetworkResourceLoader.h:
+        (WebKit::NetworkResourceLoader::isLoadingMainResource):
+        (WebKit::NetworkResourceLoader::setHostRecord): Deleted.
+        (WebKit::NetworkResourceLoader::hostRecord): Deleted.
+        * NetworkProcess/mac/NetworkResourceLoadSchedulerMac.mm:
+        (WebKit::NetworkResourceLoadScheduler::platformInitializeNetworkSettings):
+        (WebKit::NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountPerHost): Deleted.
+        * NetworkProcess/soup/NetworkResourceLoadSchedulerSoup.cpp:
+        (WebKit::NetworkResourceLoadScheduler::platformInitializeNetworkSettings):
+        (WebKit::NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountPerHost): Deleted.
+        * WebKit2.xcodeproj/project.pbxproj:
+
 2014-08-25  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Older versions of WebKit should use the plugins cache in read only mode
diff --git a/Source/WebKit2/NetworkProcess/HostRecord.cpp b/Source/WebKit2/NetworkProcess/HostRecord.cpp
deleted file mode 100644 (file)
index f3ba81f..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "HostRecord.h"
-
-#include "Logging.h"
-#include "NetworkConnectionToWebProcess.h"
-#include "NetworkProcess.h"
-#include "NetworkResourceLoadParameters.h"
-#include "NetworkResourceLoadScheduler.h"
-#include "NetworkResourceLoader.h"
-#include <wtf/MainThread.h>
-
-#if ENABLE(NETWORK_PROCESS)
-
-using namespace WebCore;
-
-namespace WebKit {
-
-HostRecord::HostRecord(const String& name, int maxRequestsInFlight)
-    : m_name(name)
-    , m_maxRequestsInFlight(maxRequestsInFlight)
-{
-}
-
-HostRecord::~HostRecord()
-{
-#ifndef NDEBUG
-    ASSERT(m_loadersInProgress.isEmpty());
-    for (unsigned p = 0; p <= ResourceLoadPriorityHighest; p++)
-        ASSERT(m_loadersPending[p].isEmpty());
-#endif
-}
-
-void HostRecord::scheduleResourceLoader(PassRefPtr<NetworkResourceLoader> loader)
-{
-    ASSERT(RunLoop::isMain());
-
-    loader->setHostRecord(this);
-    
-    if (loader->isSynchronous())
-        m_syncLoadersPending.append(loader);
-    else
-        m_loadersPending[loader->priority()].append(loader);
-}
-
-void HostRecord::addLoaderInProgress(NetworkResourceLoader* loader)
-{
-    ASSERT(RunLoop::isMain());
-
-    m_loadersInProgress.add(loader);
-    loader->setHostRecord(this);
-}
-
-inline bool removeLoaderFromQueue(NetworkResourceLoader* loader, LoaderQueue& queue)
-{
-    LoaderQueue::iterator end = queue.end();
-    for (LoaderQueue::iterator it = queue.begin(); it != end; ++it) {
-        if (it->get() == loader) {
-            loader->setHostRecord(0);
-            queue.remove(it);
-            return true;
-        }
-    }
-    return false;
-}
-
-void HostRecord::removeLoader(NetworkResourceLoader* loader)
-{
-    ASSERT(RunLoop::isMain());
-
-    // FIXME (NetworkProcess): Due to IPC race conditions, it's possible this HostRecord will be asked to remove the same loader twice.
-    // It would be nice to know the loader has already been removed and treat it as a no-op.
-
-    NetworkResourceLoaderSet::iterator i = m_loadersInProgress.find(loader);
-    if (i != m_loadersInProgress.end()) {
-        i->get()->setHostRecord(0);
-        m_loadersInProgress.remove(i);
-        return;
-    }
-
-    if (removeLoaderFromQueue(loader, m_syncLoadersPending))
-        return;
-    
-    for (int priority = ResourceLoadPriorityHighest; priority >= ResourceLoadPriorityLowest; --priority) {
-        if (removeLoaderFromQueue(loader, m_loadersPending[priority]))
-            return;
-    }
-}
-
-bool HostRecord::hasRequests() const
-{
-    if (!m_loadersInProgress.isEmpty())
-        return true;
-
-    for (unsigned p = 0; p <= ResourceLoadPriorityHighest; p++) {
-        if (!m_loadersPending[p].isEmpty())
-            return true;
-    }
-
-    return false;
-}
-
-uint64_t HostRecord::pendingRequestCount() const
-{
-    uint64_t count = 0;
-
-    for (unsigned p = 0; p <= ResourceLoadPriorityHighest; p++)
-        count += m_loadersPending[p].size();
-
-    return count;
-}
-
-uint64_t HostRecord::activeLoadCount() const
-{
-    return m_loadersInProgress.size();
-}
-
-void HostRecord::servePendingRequestsForQueue(LoaderQueue& queue, ResourceLoadPriority priority)
-{
-    // We only enforce the connection limit for http(s) hosts, which are the only ones with names.
-    bool shouldLimitRequests = !name().isNull();
-
-    // 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.
-
-    // FIXME (NetworkProcess): The above comment about document parsing and stylesheets is a holdover
-    // from the WebCore::ResourceLoadScheduler.
-    // The behavior described was at one time important for WebCore's single threadedness.
-    // It's possible that we don't care about it with the NetworkProcess.
-    // We should either decide it's not important and change the above comment, or decide it is
-    // still important and somehow account for it.
-    
-    // Very low priority loaders are only handled when no other loaders are in progress.
-    if (shouldLimitRequests && priority == ResourceLoadPriorityVeryLow && !m_loadersInProgress.isEmpty())
-        return;
-    
-    while (!queue.isEmpty()) {
-        RefPtr<NetworkResourceLoader> loader = queue.first();
-        ASSERT(loader->hostRecord() == this);
-
-        // This request might be from WebProcess we've lost our connection to.
-        // If so we should just skip it.
-        if (!loader->connectionToWebProcess()) {
-            removeLoader(loader.get());
-            continue;
-        }
-
-        if (shouldLimitRequests && limitsRequests(priority, loader.get()))
-            return;
-
-        m_loadersInProgress.add(loader);
-        queue.removeFirst();
-
-        LOG(NetworkScheduling, "(NetworkProcess) HostRecord::servePendingRequestsForQueue - Starting load of %s\n", loader->request().url().string().utf8().data());
-        loader->start();
-    }
-}
-
-void HostRecord::servePendingRequests(ResourceLoadPriority minimumPriority)
-{
-    LOG(NetworkScheduling, "(NetworkProcess) HostRecord::servePendingRequests Host name='%s'", name().utf8().data());
-
-    // We serve synchronous requests before any other requests to improve responsiveness in any
-    // WebProcess that is waiting on a synchronous load.
-    servePendingRequestsForQueue(m_syncLoadersPending, ResourceLoadPriorityHighest);
-    
-    for (int priority = ResourceLoadPriorityHighest; priority >= minimumPriority; --priority)
-        servePendingRequestsForQueue(m_loadersPending[priority], (ResourceLoadPriority)priority);
-}
-
-bool HostRecord::limitsRequests(ResourceLoadPriority priority, NetworkResourceLoader* loader) const
-{
-    ASSERT(loader);
-    ASSERT(loader->connectionToWebProcess());
-
-    if (priority == ResourceLoadPriorityVeryLow && !m_loadersInProgress.isEmpty())
-        return true;
-
-    if (loader->connectionToWebProcess()->isSerialLoadingEnabled() && m_loadersInProgress.size() >= 1)
-        return true;
-
-    // If we're exactly at the limit for requests in flight, and this loader is asynchronous, then we're done serving new requests.
-    // The synchronous loader exception handles the case where a sync XHR is made while 6 other requests are already in flight.
-    if (m_loadersInProgress.size() == m_maxRequestsInFlight && !loader->isSynchronous())
-        return true;
-
-    // If we're already past the limit of the number of loaders in flight, we won't even serve new synchronous requests right now.
-    if (m_loadersInProgress.size() > m_maxRequestsInFlight) {
-#ifndef NDEBUG
-        // If we have more loaders in progress than we should, at least one of them had better be synchronous.
-        NetworkResourceLoaderSet::iterator i = m_loadersInProgress.begin();
-        NetworkResourceLoaderSet::iterator end = m_loadersInProgress.end();
-        for (; i != end; ++i) {
-            if (i->get()->isSynchronous())
-                break;
-        }
-        ASSERT(i != end);
-#endif
-        return true;
-    }
-    return false;
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(NETWORK_PROCESS)
diff --git a/Source/WebKit2/NetworkProcess/HostRecord.h b/Source/WebKit2/NetworkProcess/HostRecord.h
deleted file mode 100644 (file)
index 7e18c3a..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef HostRecord_h
-#define HostRecord_h
-
-#if ENABLE(NETWORK_PROCESS)
-
-#include <WebCore/ResourceLoadPriority.h>
-#include <wtf/Deque.h>
-#include <wtf/HashSet.h>
-#include <wtf/RefCounted.h>
-#include <wtf/text/WTFString.h>
-
-namespace WebKit {
-
-class NetworkResourceLoader;
-
-typedef Deque<RefPtr<NetworkResourceLoader>> LoaderQueue;
-typedef uint64_t ResourceLoadIdentifier;
-
-class HostRecord : public RefCounted<HostRecord> {
-public:
-    static PassRefPtr<HostRecord> create(const String& name, int maxRequestsInFlight)
-    {
-        return adoptRef(new HostRecord(name, maxRequestsInFlight));
-    }
-    
-    ~HostRecord();
-    
-    const String& name() const { return m_name; }
-    
-    void scheduleResourceLoader(PassRefPtr<NetworkResourceLoader>);
-    void addLoaderInProgress(NetworkResourceLoader*);
-    void removeLoader(NetworkResourceLoader*);
-    bool hasRequests() const;
-    void servePendingRequests(WebCore::ResourceLoadPriority);
-
-    uint64_t pendingRequestCount() const;
-    uint64_t activeLoadCount() const;
-
-private:
-    HostRecord(const String& name, int maxRequestsInFlight);
-
-    void servePendingRequestsForQueue(LoaderQueue&, WebCore::ResourceLoadPriority);
-    bool limitsRequests(WebCore::ResourceLoadPriority, NetworkResourceLoader*) const;
-
-    LoaderQueue m_loadersPending[WebCore::ResourceLoadPriorityHighest + 1];
-    LoaderQueue m_syncLoadersPending;
-
-    typedef HashSet<RefPtr<NetworkResourceLoader>> NetworkResourceLoaderSet;
-    NetworkResourceLoaderSet m_loadersInProgress;
-
-    const String m_name;
-    int m_maxRequestsInFlight;
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(NETWORK_PROCESS)
-
-#endif // #ifndef HostRecord_h
index 8edd73b..0cd3fe9 100644 (file)
@@ -145,9 +145,8 @@ void NetworkConnectionToWebProcess::setDefersLoading(ResourceLoadIdentifier iden
     loader->setDefersLoading(defers);
 }
 
-void NetworkConnectionToWebProcess::servePendingRequests(uint32_t resourceLoadPriority)
+void NetworkConnectionToWebProcess::servePendingRequests(uint32_t)
 {
-    NetworkProcess::shared().networkResourceLoadScheduler().servePendingRequests(static_cast<ResourceLoadPriority>(resourceLoadPriority));
 }
 
 void NetworkConnectionToWebProcess::setSerialLoadingEnabled(bool enabled)
index 5eb545e..e12f8a5 100644 (file)
@@ -258,8 +258,6 @@ void NetworkProcess::getNetworkProcessStatistics(uint64_t callbackID)
 
     StatisticsData data;
 
-    data.statisticsNumbers.set("HostsPendingCount", scheduler.hostsPendingCount());
-    data.statisticsNumbers.set("HostsActiveCount", scheduler.hostsActiveCount());
     data.statisticsNumbers.set("LoadsPendingCount", scheduler.loadsPendingCount());
     data.statisticsNumbers.set("LoadsActiveCount", scheduler.loadsActiveCount());
     data.statisticsNumbers.set("DownloadsActiveCount", shared().downloadManager().activeDownloadCount());
index 56c4cc2..9c015e9 100644 (file)
@@ -1,8 +1,8 @@
 #include "config.h"
 #include "NetworkResourceLoadScheduler.h"
 
-#include "HostRecord.h"
 #include "Logging.h"
+#include "NetworkConnectionToWebProcess.h"
 #include "NetworkProcess.h"
 #include "NetworkResourceLoadParameters.h"
 #include "NetworkResourceLoader.h"
@@ -15,211 +15,51 @@ using namespace WebCore;
 
 namespace WebKit {
 
-static const unsigned maxRequestsInFlightForNonHTTPProtocols = 20;
-
 NetworkResourceLoadScheduler::NetworkResourceLoadScheduler()
-    : m_nonHTTPProtocolHost(HostRecord::create(String(), maxRequestsInFlightForNonHTTPProtocols))
-    , m_requestTimer(this, &NetworkResourceLoadScheduler::requestTimerFired)
-
-{
-    platformInitializeMaximumHTTPConnectionCountPerHost();
-}
-
-void NetworkResourceLoadScheduler::scheduleServePendingRequests()
-{
-    if (!m_requestTimer.isActive())
-        m_requestTimer.startOneShot(0);
-}
-
-void NetworkResourceLoadScheduler::requestTimerFired(WebCore::Timer<NetworkResourceLoadScheduler>*)
 {
-    servePendingRequests();
+    platformInitializeNetworkSettings();
 }
 
 void NetworkResourceLoadScheduler::scheduleLoader(PassRefPtr<NetworkResourceLoader> loader)
 {
-    ResourceLoadPriority priority = loader->priority();
-    const ResourceRequest& resourceRequest = loader->request();
-        
-    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::scheduleLoader resource '%s'", resourceRequest.url().string().utf8().data());
-
-    HostRecord* host = hostForURL(resourceRequest.url(), CreateIfNotFound);
-    bool hadRequests = host->hasRequests();
-    host->scheduleResourceLoader(loader);
-
-    if (priority > ResourceLoadPriorityLow || !resourceRequest.url().protocolIsInHTTPFamily() || (priority == ResourceLoadPriorityLow && !hadRequests)) {
-        // Try to request important resources immediately.
-        host->servePendingRequests(priority);
-        return;
-    }
-    
-    // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones.
-    scheduleServePendingRequests();
-}
-
-HostRecord* NetworkResourceLoadScheduler::hostForURL(const WebCore::URL& url, CreateHostPolicy createHostPolicy)
-{
-    if (!url.protocolIsInHTTPFamily())
-        return m_nonHTTPProtocolHost.get();
-
-    m_hosts.checkConsistency();
-    String hostName = url.host();
-    HostRecord* host = m_hosts.get(hostName);
-    if (!host && createHostPolicy == CreateIfNotFound) {
-        RefPtr<HostRecord> newHost = HostRecord::create(hostName, m_maxRequestsInFlightPerHost);
-        host = newHost.get();
-        m_hosts.add(hostName, newHost.release());
-    }
-    
-    return host;
-}
-
-void NetworkResourceLoadScheduler::removeLoader(NetworkResourceLoader* loader)
-{
-    ASSERT(RunLoop::isMain());
-    ASSERT(loader);
-
-    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::removeLoadIdentifier removing loader %s", loader->request().url().string().utf8().data());
-
-    HostRecord* host = loader->hostRecord();
-    
-    // Due to a race condition the WebProcess might have messaged the NetworkProcess to remove this identifier
-    // after the NetworkProcess has already removed it internally.
-    // In this situation we might not have a HostRecord to clean up.
-    if (host)
-        host->removeLoader(loader);
-
-    scheduleServePendingRequests();
-}
-
-void NetworkResourceLoadScheduler::receivedRedirect(NetworkResourceLoader* loader, const WebCore::URL& redirectURL)
-{
     ASSERT(RunLoop::isMain());
-    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::receivedRedirect loader originally for '%s' redirected to '%s'", loader->request().url().string().utf8().data(), redirectURL.string().utf8().data());
 
-    HostRecord* oldHost = loader->hostRecord();
+    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::scheduleLoader resource '%s'", loader->request().url().string().utf8().data());
 
-    // The load may have been cancelled while the message was in flight from network thread to main thread.
-    if (!oldHost)
+    // This request might be from WebProcess we've lost our connection to.
+    // If so we should just skip it.
+    if (!loader->connectionToWebProcess())
         return;
 
-    HostRecord* newHost = hostForURL(redirectURL, CreateIfNotFound);
-    
-    if (oldHost->name() == newHost->name())
+    if (loader->connectionToWebProcess()->isSerialLoadingEnabled() && !m_activeLoaders.isEmpty()) {
+        m_pendingSerialLoaders.append(loader);
         return;
-
-    oldHost->removeLoader(loader);
-    newHost->addLoaderInProgress(loader);
-}
-
-void NetworkResourceLoadScheduler::servePendingRequests(ResourceLoadPriority minimumPriority)
-{
-    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::servePendingRequests Serving requests for up to %i hosts with minimum priority %i", m_hosts.size(), minimumPriority);
-
-    m_requestTimer.stop();
-    
-    m_nonHTTPProtocolHost->servePendingRequests(minimumPriority);
-
-    m_hosts.checkConsistency();
-    Vector<RefPtr<HostRecord>> hostsToServe;
-    copyValuesToVector(m_hosts, hostsToServe);
-
-    size_t size = hostsToServe.size();
-    for (size_t i = 0; i < size; ++i) {
-        HostRecord* host = hostsToServe[i].get();
-        if (host->hasRequests())
-            host->servePendingRequests(minimumPriority);
-        else
-            m_hosts.remove(host->name());
     }
-}
+    m_activeLoaders.add(loader.get());
 
-static bool removeScheduledLoadersCalled = false;
+    loader->start();
+}
 
-void NetworkResourceLoadScheduler::removeScheduledLoaders(void* context)
+void NetworkResourceLoadScheduler::removeLoader(NetworkResourceLoader* loader)
 {
     ASSERT(RunLoop::isMain());
-    ASSERT(removeScheduledLoadersCalled);
 
-    NetworkResourceLoadScheduler* scheduler = static_cast<NetworkResourceLoadScheduler*>(context);
-    scheduler->removeScheduledLoaders();
-}
+    LOG(NetworkScheduling, "(NetworkProcess) NetworkResourceLoadScheduler::removeLoader resource '%s'", loader->request().url().string().utf8().data());
 
-void NetworkResourceLoadScheduler::removeScheduledLoaders()
-{
-    Vector<RefPtr<NetworkResourceLoader>> loadersToRemove;
-    {
-        MutexLocker locker(m_loadersToRemoveMutex);
-        loadersToRemove = m_loadersToRemove;
-        m_loadersToRemove.clear();
-        removeScheduledLoadersCalled = false;
-    }
-    
-    for (size_t i = 0; i < loadersToRemove.size(); ++i)
-        removeLoader(loadersToRemove[i].get());
-}
+    m_activeLoaders.remove(loader);
 
-void NetworkResourceLoadScheduler::scheduleRemoveLoader(NetworkResourceLoader* loader)
-{
-    MutexLocker locker(m_loadersToRemoveMutex);
-    
-    m_loadersToRemove.append(loader);
-    
-    if (!removeScheduledLoadersCalled) {
-        removeScheduledLoadersCalled = true;
-        callOnMainThread(NetworkResourceLoadScheduler::removeScheduledLoaders, this);
-    }
-}
-
-uint64_t NetworkResourceLoadScheduler::hostsPendingCount() const
-{
-    uint64_t count = m_nonHTTPProtocolHost->pendingRequestCount() ? 1 : 0;
-
-    HostMap::const_iterator end = m_hosts.end();
-    for (HostMap::const_iterator i = m_hosts.begin(); i != end; ++i) {
-        if (i->value->pendingRequestCount())
-            ++count;
-    }
-
-    return count;
+    while (!m_pendingSerialLoaders.isEmpty() && m_activeLoaders.isEmpty())
+        scheduleLoader(m_pendingSerialLoaders.takeLast());
 }
 
 uint64_t NetworkResourceLoadScheduler::loadsPendingCount() const
 {
-    uint64_t count = m_nonHTTPProtocolHost->pendingRequestCount();
-
-    HostMap::const_iterator end = m_hosts.end();
-    for (HostMap::const_iterator i = m_hosts.begin(); i != end; ++i)
-        count += i->value->pendingRequestCount();
-
-    return count;
-}
-
-uint64_t NetworkResourceLoadScheduler::hostsActiveCount() const
-{
-    uint64_t count = 0;
-
-    if (m_nonHTTPProtocolHost->activeLoadCount())
-        count = 1;
-
-    HostMap::const_iterator end = m_hosts.end();
-    for (HostMap::const_iterator i = m_hosts.begin(); i != end; ++i) {
-        if (i->value->activeLoadCount())
-            ++count;
-    }
-
-    return count;
+    return m_pendingSerialLoaders.size();
 }
 
 uint64_t NetworkResourceLoadScheduler::loadsActiveCount() const
 {
-    uint64_t count = m_nonHTTPProtocolHost->activeLoadCount();
-
-    HostMap::const_iterator end = m_hosts.end();
-    for (HostMap::const_iterator i = m_hosts.begin(); i != end; ++i)
-        count += i->value->activeLoadCount();
-
-    return count;
+    return m_activeLoaders.size();
 }
 
 } // namespace WebKit
index 840a278..fd211a7 100644 (file)
 #ifndef NetworkResourceLoadScheduler_h
 #define NetworkResourceLoadScheduler_h
 
-#include <WebCore/ResourceLoadPriority.h>
 #include <WebCore/Timer.h>
-#include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/text/StringHash.h>
 
 #if ENABLE(NETWORK_PROCESS)
 
-namespace WebCore {
-class URL;
-}
-
 namespace WebKit {
 
-class HostRecord;
 class NetworkResourceLoader;
 
 class NetworkResourceLoadScheduler {
@@ -49,56 +42,18 @@ class NetworkResourceLoadScheduler {
 public:
     NetworkResourceLoadScheduler();
     
-    // Adds the request to the queue for its host.
     void scheduleLoader(PassRefPtr<NetworkResourceLoader>);
-
-    // Called by the WebProcess when a ResourceLoader is being cleaned up.
     void removeLoader(NetworkResourceLoader*);
 
-    // Called within the NetworkProcess on a background thread when a resource load has finished.
-    void scheduleRemoveLoader(NetworkResourceLoader*);
-
-    void receivedRedirect(NetworkResourceLoader*, const WebCore::URL& redirectURL);
-    void servePendingRequests(WebCore::ResourceLoadPriority = WebCore::ResourceLoadPriorityVeryLow);
-
     // For NetworkProcess statistics reporting.
-    uint64_t hostsPendingCount() const;
     uint64_t loadsPendingCount() const;
-    uint64_t hostsActiveCount() const;
     uint64_t loadsActiveCount() const;
 
 private:
-    enum CreateHostPolicy {
-        CreateIfNotFound,
-        FindOnly
-    };
-    
-    HostRecord* hostForURL(const WebCore::URL&, CreateHostPolicy = FindOnly);
-    
-    void scheduleServePendingRequests();
-    void requestTimerFired(WebCore::Timer<NetworkResourceLoadScheduler>*);
-
-    void platformInitializeMaximumHTTPConnectionCountPerHost();
-
-    static void removeScheduledLoaders(void* context);
-    void removeScheduledLoaders();
-
-    typedef HashMap<String, RefPtr<HostRecord>, StringHash> HostMap;
-    HostMap m_hosts;
-
-    typedef HashSet<RefPtr<NetworkResourceLoader>> NetworkResourceLoaderSet;
-    NetworkResourceLoaderSet m_loaders;
-
-    RefPtr<HostRecord> m_nonHTTPProtocolHost;
-
-    bool m_isSerialLoadingEnabled;
-
-    WebCore::Timer<NetworkResourceLoadScheduler> m_requestTimer;
-    
-    Mutex m_loadersToRemoveMutex;
-    Vector<RefPtr<NetworkResourceLoader>> m_loadersToRemove;
+    static void platformInitializeNetworkSettings();
 
-    unsigned m_maxRequestsInFlightPerHost;
+    HashSet<RefPtr<NetworkResourceLoader>> m_activeLoaders;
+    Vector<RefPtr<NetworkResourceLoader>> m_pendingSerialLoaders;
 };
 
 } // namespace WebKit
index 205aec1..1de946a 100644 (file)
@@ -113,7 +113,6 @@ NetworkResourceLoader::~NetworkResourceLoader()
 {
     ASSERT(RunLoop::isMain());
     ASSERT(!m_handle);
-    ASSERT(!m_hostRecord);
 }
 
 bool NetworkResourceLoader::isSynchronous() const
@@ -161,7 +160,7 @@ void NetworkResourceLoader::cleanup()
     invalidateSandboxExtensions();
 
     // Tell the scheduler about this finished loader soon so it can start more network requests.
-    NetworkProcess::shared().networkResourceLoadScheduler().scheduleRemoveLoader(this);
+    NetworkProcess::shared().networkResourceLoadScheduler().removeLoader(this);
 
     if (m_handle) {
         // Explicit deref() balanced by a ref() in NetworkResourceLoader::start()
@@ -269,8 +268,6 @@ void NetworkResourceLoader::continueWillSendRequest(const ResourceRequest& newRe
     m_suggestedRequestForWillSendRequest.updateFromDelegatePreservingOldProperties(newRequest);
 #endif
 
-    RunLoop::main().dispatch(bind(&NetworkResourceLoadScheduler::receivedRedirect, &NetworkProcess::shared().networkResourceLoadScheduler(), this, m_suggestedRequestForWillSendRequest.url()));
-
     m_request = m_suggestedRequestForWillSendRequest;
     m_suggestedRequestForWillSendRequest = ResourceRequest();
 
index 1f0b59a..fb498a2 100644 (file)
@@ -28,9 +28,9 @@
 
 #if ENABLE(NETWORK_PROCESS)
 
-#include "HostRecord.h"
 #include "MessageSender.h"
 #include "NetworkConnectionToWebProcessMessages.h"
+#include "NetworkResourceLoadParameters.h"
 #include "ShareableResource.h"
 #include <WebCore/ResourceHandleClient.h>
 #include <WebCore/ResourceLoaderOptions.h>
@@ -129,9 +129,6 @@ public:
 
     bool isSynchronous() const;
     bool isLoadingMainResource() const { return m_isLoadingMainResource; }
-    
-    void setHostRecord(HostRecord* hostRecord) { ASSERT(RunLoop::isMain()); m_hostRecord = hostRecord; }
-    HostRecord* hostRecord() const { ASSERT(RunLoop::isMain()); return m_hostRecord.get(); }
 
     template<typename T>
     bool sendAbortingOnFailure(T&& message, unsigned messageSendFlags = 0)
@@ -197,7 +194,6 @@ private:
 
     RefPtr<NetworkConnectionToWebProcess> m_connection;
     
-    RefPtr<HostRecord> m_hostRecord;
     RefPtr<WebCore::SharedBuffer> m_bufferedData;
 };
 
index 07387cd..7d36a12 100644 (file)
@@ -37,12 +37,11 @@ using namespace WebCore;
 
 namespace WebKit {
 
-void NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountPerHost()
+void NetworkResourceLoadScheduler::platformInitializeNetworkSettings()
 {
     static const unsigned preferredConnectionCount = 6;
-    static const unsigned unlimitedRequestCount = 10000;
 
-    unsigned maximumHTTPConnectionCountPerHost = WKInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount);
+    WKInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount);
 
     Boolean keyExistsAndHasValidFormat = false;
     Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitEnableHTTPPipelining"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat);
@@ -52,10 +51,6 @@ void NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountP
     if (ResourceRequest::resourcePrioritiesEnabled()) {
         WKSetHTTPRequestMaximumPriority(toPlatformRequestPriority(ResourceLoadPriorityHighest));
         WKSetHTTPRequestMinimumFastLanePriority(toPlatformRequestPriority(ResourceLoadPriorityMedium));
-        m_maxRequestsInFlightPerHost = unlimitedRequestCount;
-    } else {
-        // Use WebKit scheduler when we can't use request priorities with CFNetwork.
-        m_maxRequestsInFlightPerHost = maximumHTTPConnectionCountPerHost;
     }
 }
 
index 9d03979..1a3fbe7 100644 (file)
 
 namespace WebKit {
 
-void NetworkResourceLoadScheduler::platformInitializeMaximumHTTPConnectionCountPerHost()
+void NetworkResourceLoadScheduler::platformInitializeNetworkSettings()
 {
-    // Soup has its own queue control; it wants to have all requests given to
-    // it, so that it is able to look ahead, and schedule them in a good way.
-    // See the comment in ResourceRequestSoup.cpp
-    static const unsigned unlimitedConnectionCount = 10000;
-
-    // FIXME: Take advantage of Web-platform specific knowledge that can help
-    // prioritization better than libsoup alone can do.
-    // See https://bugs.webkit.org/show_bug.cgi?id=110115#c13
-    m_maxRequestsInFlightPerHost = unlimitedConnectionCount;
 }
 
 } // namespace WebKit
index 90e867a..96c8253 100644 (file)
                512A9761180E031D0039A149 /* DatabaseProcessMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 512A975F180E03160039A149 /* DatabaseProcessMessages.h */; };
                512A9769180E09B80039A149 /* DatabaseProcessProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 512A9767180E09B80039A149 /* DatabaseProcessProxyMessageReceiver.cpp */; };
                512A976A180E09B80039A149 /* DatabaseProcessProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 512A9768180E09B80039A149 /* DatabaseProcessProxyMessages.h */; };
-               512C06881638F67E00ABB911 /* HostRecord.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 512C06861638F67E00ABB911 /* HostRecord.cpp */; };
-               512C06891638F67E00ABB911 /* HostRecord.h in Headers */ = {isa = PBXBuildFile; fileRef = 512C06871638F67E00ABB911 /* HostRecord.h */; };
                512C069016390E6900ABB911 /* NetworkResourceLoadSchedulerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 512C068F16390E6900ABB911 /* NetworkResourceLoadSchedulerMac.mm */; };
                512E34E4130B4D0500ABD19A /* WKApplicationCacheManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A33B3130B308C00F80CB5 /* WKApplicationCacheManager.cpp */; };
                512E34E5130B4D0500ABD19A /* WKApplicationCacheManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A33B4130B308C00F80CB5 /* WKApplicationCacheManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                512A9766180E05D20039A149 /* DatabaseProcessProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = DatabaseProcessProxy.messages.in; path = Databases/DatabaseProcessProxy.messages.in; sourceTree = "<group>"; };
                512A9767180E09B80039A149 /* DatabaseProcessProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseProcessProxyMessageReceiver.cpp; sourceTree = "<group>"; };
                512A9768180E09B80039A149 /* DatabaseProcessProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DatabaseProcessProxyMessages.h; sourceTree = "<group>"; };
-               512C06861638F67E00ABB911 /* HostRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HostRecord.cpp; path = NetworkProcess/HostRecord.cpp; sourceTree = "<group>"; };
-               512C06871638F67E00ABB911 /* HostRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HostRecord.h; path = NetworkProcess/HostRecord.h; sourceTree = "<group>"; };
                512C068F16390E6900ABB911 /* NetworkResourceLoadSchedulerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkResourceLoadSchedulerMac.mm; sourceTree = "<group>"; };
                512E3520130B550100ABD19A /* WebApplicationCacheManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebApplicationCacheManagerProxy.cpp; sourceTree = "<group>"; };
                512E3521130B550100ABD19A /* WebApplicationCacheManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebApplicationCacheManagerProxy.h; sourceTree = "<group>"; };
                                510CC7DC16138E2900D03ED3 /* mac */,
                                51FCB18017BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.cpp */,
                                51FCB18117BBFE0300394CD8 /* AsynchronousNetworkLoaderClient.h */,
-                               512C06861638F67E00ABB911 /* HostRecord.cpp */,
-                               512C06871638F67E00ABB911 /* HostRecord.h */,
                                513A16491630A9BF005D7D22 /* NetworkConnectionToWebProcess.cpp */,
                                513A164A1630A9BF005D7D22 /* NetworkConnectionToWebProcess.h */,
                                513A164B1630A9BF005D7D22 /* NetworkConnectionToWebProcess.messages.in */,
                                BC06F44A12DBD1F5002D78DE /* GeolocationPermissionRequestManagerProxy.h in Headers */,
                                BC06F43A12DBCCFB002D78DE /* GeolocationPermissionRequestProxy.h in Headers */,
                                C0CE72AD1247E78D00BC0EC4 /* HandleMessage.h in Headers */,
-                               512C06891638F67E00ABB911 /* HostRecord.h in Headers */,
                                37F90DE31376560E0051CF68 /* HTTPCookieAcceptPolicy.h in Headers */,
                                BCCF6B2512C93E7A008F9C35 /* ImageOptions.h in Headers */,
                                1A1E093418861D3800D2DC49 /* WebProgressTrackerClient.h in Headers */,
                                BC06F43012DBB9B6002D78DE /* GeolocationPermissionRequestManager.cpp in Sources */,
                                BC06F44B12DBD1F5002D78DE /* GeolocationPermissionRequestManagerProxy.cpp in Sources */,
                                BC06F43B12DBCCFB002D78DE /* GeolocationPermissionRequestProxy.cpp in Sources */,
-                               512C06881638F67E00ABB911 /* HostRecord.cpp in Sources */,
                                BC64696F11DBE603006455B0 /* APIArray.cpp in Sources */,
                                BCBCB0CD1215E33A00DE59CA /* ImmutableDictionary.cpp in Sources */,
                                BC204EE211C83E98008F3375 /* InjectedBundle.cpp in Sources */,