Rework NetworkProcess resource load identifiers.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Jan 2013 00:41:44 +0000 (00:41 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Jan 2013 00:41:44 +0000 (00:41 +0000)
commit7337c916f8f2b28b5d11eef286dfc2b6da54cfbc
tree5bce52369a5dcb0d2d8361705c555c57438d4ee5
parent79b22f80e247a9ade01c77b15c3444530854b038
Rework NetworkProcess resource load identifiers.
<rdar://problem/12934449> and https://bugs.webkit.org/show_bug.cgi?id=107192

Reviewed by Alexey Proskuryakov.

Source/WebCore:

No new tests (No effect in tested configs).

* WebCore.exp.in:

Include an identifier argument for synchronous loads:
* loader/LoaderStrategy.cpp:
(WebCore::LoaderStrategy::loadResourceSynchronously):
* loader/LoaderStrategy.h:

Pass along a unique identifier to the synchronous load:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadResourceSynchronously):

Remove the "setIdentifier" method:
* loader/ResourceLoader.cpp:
* loader/ResourceLoader.h:

Source/WebKit2:

Having the NetworkProcess vend out identifiers to WebProcesses was a bad idea.
This patch reverts that so that WebProcesses are in control of their own unique identifiers.

The NetworkProcess doesn't need identifiers at all.
It can represent outstanding loads with the loaders themselves.

This patch adds a "SchedulableLoader" base class for normal and synchronous loaders.
It reworks each use of identifiers into using SchedulableLoaders instead.

This also gave an opportunity to move the serving of pending requests for a host into the
HostRecord itself which cleans certain things up nicely.

Change HostRecord to have queues of SchedulableLoaders instead of identifiers.
Make HostRecord responsible for actually starting the loaders in its queues:
* NetworkProcess/HostRecord.cpp:
(WebKit::HostRecord::~HostRecord):
(WebKit::HostRecord::scheduleResourceLoader):
(WebKit::HostRecord::addLoaderInProgress):
(WebKit::HostRecord::removeLoader):
(WebKit::HostRecord::hasRequests):
(WebKit::HostRecord::servePendingRequestsForQueue):
(WebKit::HostRecord::servePendingRequests):
(WebKit::HostRecord::limitsRequests):
* NetworkProcess/HostRecord.h:
(WebKit::HostRecord::create): HostRecord is now also RefCounted. new and delete are so 2004.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad): Create the loader then schedule
  it with the scheduler, instead of having the scheduler create it.
(WebKit::NetworkConnectionToWebProcess::performSynchronousLoad):
(WebKit::NetworkConnectionToWebProcess::removeLoadIdentifier):
* NetworkProcess/NetworkConnectionToWebProcess.h:
* NetworkProcess/NetworkConnectionToWebProcess.messages.in:

Remove maps and sets of identifiers, replacing them with sets of SchedulableLoaders where needed.
Rely on HostRecords to actually manage sets of SchedulableLoaders.
Rely on HostRecord to do the actual serving of its pending requests:
* NetworkProcess/NetworkResourceLoadScheduler.cpp:
(WebKit::NetworkResourceLoadScheduler::NetworkResourceLoadScheduler):
(WebKit::NetworkResourceLoadScheduler::scheduleLoader):
(WebKit::NetworkResourceLoadScheduler::hostForURL):
(WebKit::NetworkResourceLoadScheduler::removeLoader):
(WebKit::NetworkResourceLoadScheduler::receivedRedirect):
(WebKit::NetworkResourceLoadScheduler::servePendingRequests):
(WebKit::NetworkResourceLoadScheduler::removeScheduledLoaders):
(WebKit::NetworkResourceLoadScheduler::scheduleRemoveLoader):
* NetworkProcess/NetworkResourceLoadScheduler.h:

A new base class for all loaders that the scheduler and HostRecords might need to know about:
* NetworkProcess/SchedulableLoader.cpp:
(WebKit::SchedulableLoader::SchedulableLoader):
(WebKit::SchedulableLoader::~SchedulableLoader):
* NetworkProcess/SchedulableLoader.h:
(WebKit::SchedulableLoader::loadParameters):
(WebKit::SchedulableLoader::connectionToWebProcess):
(WebKit::SchedulableLoader::isSynchronous):
(WebKit::SchedulableLoader::setHostRecord):
(WebKit::SchedulableLoader::hostRecord):

Change to inherit from SchedulableLoader, removing some of the duplicated data and methods:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::NetworkResourceLoader):
(WebKit::NetworkResourceLoader::connection):
(WebKit::NetworkResourceLoader::destinationID):
(WebKit::NetworkResourceLoader::start):
(WebKit::NetworkResourceLoader::stop):
(WebKit::NetworkResourceLoader::didReceiveResponse):
(WebKit::NetworkResourceLoader::didFail):
(WebKit::NetworkResourceLoader::willSendRequest):
(WebKit::NetworkResourceLoader::shouldUseCredentialStorage):
* NetworkProcess/NetworkResourceLoader.h:
(WebKit::NetworkResourceLoader::create):

Change to inherit from SchedulableLoader, removing some of the duplicated data and methods:
* NetworkProcess/SyncNetworkResourceLoader.cpp:
(WebKit::SyncNetworkResourceLoader::SyncNetworkResourceLoader):
(WebKit::SyncNetworkResourceLoader::start):
* NetworkProcess/SyncNetworkResourceLoader.h:
(WebKit::SyncNetworkResourceLoader::create):
(WebKit::SyncNetworkResourceLoader::isSynchronous):

Fold the WebProcess resource load identifier in with the load parameters:
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:
(WebKit::NetworkResourceLoadParameters::identifier):

The identifier is preset in the WebProcess and doesn't come from the NetworkProcess,
so the message to schedule a load can now be asynchronous:
* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):

Update to include a WebProcess generated identifier along with synchronous loads:
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::loadResourceSynchronously):
* WebProcess/WebCoreSupport/WebPlatformStrategies.h:

* WebKit2.xcodeproj/project.pbxproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@140218 268f45cc-cd09-0410-ab3c-d52691b4dbfc
27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/LoaderStrategy.cpp
Source/WebCore/loader/LoaderStrategy.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/loader/ResourceLoader.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/HostRecord.cpp
Source/WebKit2/NetworkProcess/HostRecord.h
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.h
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.messages.in
Source/WebKit2/NetworkProcess/NetworkResourceLoadScheduler.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoadScheduler.h
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.h
Source/WebKit2/NetworkProcess/SchedulableLoader.cpp [new file with mode: 0644]
Source/WebKit2/NetworkProcess/SchedulableLoader.h [new file with mode: 0644]
Source/WebKit2/NetworkProcess/SyncNetworkResourceLoader.cpp
Source/WebKit2/NetworkProcess/SyncNetworkResourceLoader.h
Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.cpp
Source/WebKit2/Shared/Network/NetworkResourceLoadParameters.h
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Network/WebResourceLoadScheduler.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebPlatformStrategies.h