Commit ca3e2da0 authored by andersca@apple.com's avatar andersca@apple.com

Make it easier to extend NetworkResourceLoadParameters

https://bugs.webkit.org/show_bug.cgi?id=114992

Reviewed by Sam Weinig.

Turn NetworkResourceLoadParameters into a struct which matches all our other parameter classes in WebKit2. Fill in the struct manually
instead of having a constructor with 9 parameters.

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad):
(WebKit::NetworkConnectionToWebProcess::performSynchronousLoad):
* NetworkProcess/SchedulableLoader.cpp:
(WebKit::SchedulableLoader::SchedulableLoader):
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:
(NetworkResourceLoadParameters):
* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::loadResourceSynchronously):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148913 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e927135c
2013-04-22 Anders Carlsson <andersca@apple.com>
Make it easier to extend NetworkResourceLoadParameters
https://bugs.webkit.org/show_bug.cgi?id=114992
Reviewed by Sam Weinig.
Turn NetworkResourceLoadParameters into a struct which matches all our other parameter classes in WebKit2. Fill in the struct manually
instead of having a constructor with 9 parameters.
* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::scheduleResourceLoad):
(WebKit::NetworkConnectionToWebProcess::performSynchronousLoad):
* NetworkProcess/SchedulableLoader.cpp:
(WebKit::SchedulableLoader::SchedulableLoader):
* Shared/Network/NetworkResourceLoadParameters.cpp:
(WebKit::NetworkResourceLoadParameters::NetworkResourceLoadParameters):
(WebKit::NetworkResourceLoadParameters::encode):
(WebKit::NetworkResourceLoadParameters::decode):
* Shared/Network/NetworkResourceLoadParameters.h:
(NetworkResourceLoadParameters):
* WebProcess/Network/WebResourceLoadScheduler.cpp:
(WebKit::WebResourceLoadScheduler::scheduleLoad):
* WebProcess/WebCoreSupport/WebPlatformStrategies.cpp:
(WebKit::WebPlatformStrategies::loadResourceSynchronously):
2013-04-22 Tim Horton <timothy_horton@apple.com>
PDFPlugin: Support unlocking encrypted PDFs
......@@ -118,14 +118,14 @@ void NetworkConnectionToWebProcess::didReceiveInvalidMessage(CoreIPC::Connection
void NetworkConnectionToWebProcess::scheduleResourceLoad(const NetworkResourceLoadParameters& loadParameters)
{
RefPtr<NetworkResourceLoader> loader = NetworkResourceLoader::create(loadParameters, this);
m_networkResourceLoaders.add(loadParameters.identifier(), loader);
m_networkResourceLoaders.add(loadParameters.identifier, loader);
NetworkProcess::shared().networkResourceLoadScheduler().scheduleLoader(loader.get());
}
void NetworkConnectionToWebProcess::performSynchronousLoad(const NetworkResourceLoadParameters& loadParameters, PassRefPtr<Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::DelayedReply> reply)
{
RefPtr<SyncNetworkResourceLoader> loader = SyncNetworkResourceLoader::create(loadParameters, this, reply);
m_syncNetworkResourceLoaders.add(loadParameters.identifier(), loader);
m_syncNetworkResourceLoaders.add(loadParameters.identifier, loader);
NetworkProcess::shared().networkResourceLoadScheduler().scheduleLoader(loader.get());
}
......
......@@ -38,19 +38,19 @@ using namespace WebCore;
namespace WebKit {
SchedulableLoader::SchedulableLoader(const NetworkResourceLoadParameters& parameters, NetworkConnectionToWebProcess* connection)
: m_identifier(parameters.identifier())
, m_webPageID(parameters.webPageID())
, m_webFrameID(parameters.webFrameID())
, m_request(parameters.request())
, m_priority(parameters.priority())
, m_contentSniffingPolicy(parameters.contentSniffingPolicy())
, m_allowStoredCredentials(parameters.allowStoredCredentials())
, m_inPrivateBrowsingMode(parameters.inPrivateBrowsingMode())
: m_identifier(parameters.identifier)
, m_webPageID(parameters.webPageID)
, m_webFrameID(parameters.webFrameID)
, m_request(parameters.request)
, m_priority(parameters.priority)
, m_contentSniffingPolicy(parameters.contentSniffingPolicy)
, m_allowStoredCredentials(parameters.allowStoredCredentials)
, m_inPrivateBrowsingMode(parameters.inPrivateBrowsingMode)
, m_connection(connection)
, m_shouldClearReferrerOnHTTPSToHTTPRedirect(parameters.shouldClearReferrerOnHTTPSToHTTPRedirect())
, m_shouldClearReferrerOnHTTPSToHTTPRedirect(parameters.shouldClearReferrerOnHTTPSToHTTPRedirect)
{
for (size_t i = 0, count = parameters.requestBodySandboxExtensions().size(); i < count; ++i) {
if (RefPtr<SandboxExtension> extension = SandboxExtension::create(parameters.requestBodySandboxExtensions()[i]))
for (size_t i = 0, count = parameters.requestBodySandboxExtensions.size(); i < count; ++i) {
if (RefPtr<SandboxExtension> extension = SandboxExtension::create(parameters.requestBodySandboxExtensions[i]))
m_requestBodySandboxExtensions.append(extension);
}
......@@ -66,11 +66,11 @@ SchedulableLoader::SchedulableLoader(const NetworkResourceLoadParameters& parame
}
if (m_request.url().protocolIs("blob")) {
ASSERT(!SandboxExtension::create(parameters.resourceSandboxExtension()));
ASSERT(!SandboxExtension::create(parameters.resourceSandboxExtension));
m_resourceSandboxExtensions = NetworkBlobRegistry::shared().sandboxExtensions(m_request.url());
} else
#endif
if (RefPtr<SandboxExtension> resourceSandboxExtension = SandboxExtension::create(parameters.resourceSandboxExtension()))
if (RefPtr<SandboxExtension> resourceSandboxExtension = SandboxExtension::create(parameters.resourceSandboxExtension))
m_resourceSandboxExtensions.append(resourceSandboxExtension);
}
......
......@@ -38,44 +38,31 @@ using namespace WebCore;
namespace WebKit {
NetworkResourceLoadParameters::NetworkResourceLoadParameters()
: m_identifier(0)
, m_webPageID(0)
, m_webFrameID(0)
, m_priority(ResourceLoadPriorityVeryLow)
, m_contentSniffingPolicy(SniffContent)
, m_allowStoredCredentials(DoNotAllowStoredCredentials)
, m_inPrivateBrowsingMode(false)
, m_shouldClearReferrerOnHTTPSToHTTPRedirect(true)
{
}
NetworkResourceLoadParameters::NetworkResourceLoadParameters(ResourceLoadIdentifier identifier, uint64_t webPageID, uint64_t webFrameID, const ResourceRequest& request, ResourceLoadPriority priority, ContentSniffingPolicy contentSniffingPolicy, StoredCredentials allowStoredCredentials, bool inPrivateBrowsingMode, bool shouldClearReferrerOnHTTPSToHTTPRedirect)
: m_identifier(identifier)
, m_webPageID(webPageID)
, m_webFrameID(webFrameID)
, m_request(request)
, m_priority(priority)
, m_contentSniffingPolicy(contentSniffingPolicy)
, m_allowStoredCredentials(allowStoredCredentials)
, m_inPrivateBrowsingMode(inPrivateBrowsingMode)
, m_shouldClearReferrerOnHTTPSToHTTPRedirect(shouldClearReferrerOnHTTPSToHTTPRedirect)
: identifier(0)
, webPageID(0)
, webFrameID(0)
, priority(ResourceLoadPriorityVeryLow)
, contentSniffingPolicy(SniffContent)
, allowStoredCredentials(DoNotAllowStoredCredentials)
, inPrivateBrowsingMode(false)
, shouldClearReferrerOnHTTPSToHTTPRedirect(true)
{
}
void NetworkResourceLoadParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
{
encoder << m_identifier;
encoder << m_webPageID;
encoder << m_webFrameID;
encoder << m_request;
encoder << identifier;
encoder << webPageID;
encoder << webFrameID;
encoder << request;
encoder << static_cast<bool>(m_request.httpBody());
if (m_request.httpBody()) {
encoder << static_cast<bool>(request.httpBody());
if (request.httpBody()) {
EncoderAdapter httpBodyEncoderAdapter;
m_request.httpBody()->encode(httpBodyEncoderAdapter);
request.httpBody()->encode(httpBodyEncoderAdapter);
encoder << httpBodyEncoderAdapter.dataReference();
const Vector<FormDataElement>& elements = m_request.httpBody()->elements();
const Vector<FormDataElement>& elements = request.httpBody()->elements();
size_t fileCount = 0;
for (size_t i = 0, count = elements.size(); i < count; ++i) {
if (elements[i].m_type == FormDataElement::encodedFile)
......@@ -95,31 +82,31 @@ void NetworkResourceLoadParameters::encode(CoreIPC::ArgumentEncoder& encoder) co
encoder << requestBodySandboxExtensions;
}
if (m_request.url().isLocalFile()) {
if (request.url().isLocalFile()) {
SandboxExtension::Handle requestSandboxExtension;
SandboxExtension::createHandle(m_request.url().fileSystemPath(), SandboxExtension::ReadOnly, requestSandboxExtension);
SandboxExtension::createHandle(request.url().fileSystemPath(), SandboxExtension::ReadOnly, requestSandboxExtension);
encoder << requestSandboxExtension;
}
encoder.encodeEnum(m_priority);
encoder.encodeEnum(m_contentSniffingPolicy);
encoder.encodeEnum(m_allowStoredCredentials);
encoder << m_inPrivateBrowsingMode;
encoder << m_shouldClearReferrerOnHTTPSToHTTPRedirect;
encoder.encodeEnum(priority);
encoder.encodeEnum(contentSniffingPolicy);
encoder.encodeEnum(allowStoredCredentials);
encoder << inPrivateBrowsingMode;
encoder << shouldClearReferrerOnHTTPSToHTTPRedirect;
}
bool NetworkResourceLoadParameters::decode(CoreIPC::ArgumentDecoder& decoder, NetworkResourceLoadParameters& result)
{
if (!decoder.decode(result.m_identifier))
if (!decoder.decode(result.identifier))
return false;
if (!decoder.decode(result.m_webPageID))
if (!decoder.decode(result.webPageID))
return false;
if (!decoder.decode(result.m_webFrameID))
if (!decoder.decode(result.webFrameID))
return false;
if (!decoder.decode(result.m_request))
if (!decoder.decode(result.request))
return false;
bool hasHTTPBody;
......@@ -131,26 +118,26 @@ bool NetworkResourceLoadParameters::decode(CoreIPC::ArgumentDecoder& decoder, Ne
if (!decoder.decode(formData))
return false;
DecoderAdapter httpBodyDecoderAdapter(formData.data(), formData.size());
result.m_request.setHTTPBody(FormData::decode(httpBodyDecoderAdapter));
result.request.setHTTPBody(FormData::decode(httpBodyDecoderAdapter));
if (!decoder.decode(result.m_requestBodySandboxExtensions))
if (!decoder.decode(result.requestBodySandboxExtensions))
return false;
}
if (result.m_request.url().isLocalFile()) {
if (!decoder.decode(result.m_resourceSandboxExtension))
if (result.request.url().isLocalFile()) {
if (!decoder.decode(result.resourceSandboxExtension))
return false;
}
if (!decoder.decodeEnum(result.m_priority))
if (!decoder.decodeEnum(result.priority))
return false;
if (!decoder.decodeEnum(result.m_contentSniffingPolicy))
if (!decoder.decodeEnum(result.contentSniffingPolicy))
return false;
if (!decoder.decodeEnum(result.m_allowStoredCredentials))
if (!decoder.decodeEnum(result.allowStoredCredentials))
return false;
if (!decoder.decode(result.m_inPrivateBrowsingMode))
if (!decoder.decode(result.inPrivateBrowsingMode))
return false;
if (!decoder.decode(result.m_shouldClearReferrerOnHTTPSToHTTPRedirect))
if (!decoder.decode(result.shouldClearReferrerOnHTTPSToHTTPRedirect))
return false;
return true;
......
......@@ -45,35 +45,21 @@ typedef uint64_t ResourceLoadIdentifier;
class NetworkResourceLoadParameters {
public:
NetworkResourceLoadParameters();
NetworkResourceLoadParameters(ResourceLoadIdentifier, uint64_t webPageID, uint64_t webFrameID, const WebCore::ResourceRequest&, WebCore::ResourceLoadPriority, WebCore::ContentSniffingPolicy, WebCore::StoredCredentials, bool inPrivateBrowsingMode, bool shouldClearReferrerOnHTTPSToHTTPRedirect);
void encode(CoreIPC::ArgumentEncoder&) const;
static bool decode(CoreIPC::ArgumentDecoder&, NetworkResourceLoadParameters&);
ResourceLoadIdentifier identifier() const { return m_identifier; }
uint64_t webPageID() const { return m_webPageID; }
uint64_t webFrameID() const { return m_webFrameID; }
const WebCore::ResourceRequest& request() const { return m_request; }
const SandboxExtension::HandleArray& requestBodySandboxExtensions() const { return m_requestBodySandboxExtensions; }
const SandboxExtension::Handle& resourceSandboxExtension() const { return m_resourceSandboxExtension; }
WebCore::ResourceLoadPriority priority() const { return m_priority; }
WebCore::ContentSniffingPolicy contentSniffingPolicy() const { return m_contentSniffingPolicy; }
WebCore::StoredCredentials allowStoredCredentials() const { return m_allowStoredCredentials; }
bool inPrivateBrowsingMode() const { return m_inPrivateBrowsingMode; }
bool shouldClearReferrerOnHTTPSToHTTPRedirect() const { return m_shouldClearReferrerOnHTTPSToHTTPRedirect; }
private:
ResourceLoadIdentifier m_identifier;
uint64_t m_webPageID;
uint64_t m_webFrameID;
WebCore::ResourceRequest m_request;
SandboxExtension::HandleArray m_requestBodySandboxExtensions; // Created automatically for the sender.
SandboxExtension::Handle m_resourceSandboxExtension; // Created automatically for the sender.
WebCore::ResourceLoadPriority m_priority;
WebCore::ContentSniffingPolicy m_contentSniffingPolicy;
WebCore::StoredCredentials m_allowStoredCredentials;
bool m_inPrivateBrowsingMode;
bool m_shouldClearReferrerOnHTTPSToHTTPRedirect;
ResourceLoadIdentifier identifier;
uint64_t webPageID;
uint64_t webFrameID;
WebCore::ResourceRequest request;
SandboxExtension::HandleArray requestBodySandboxExtensions; // Created automatically for the sender.
SandboxExtension::Handle resourceSandboxExtension; // Created automatically for the sender.
WebCore::ResourceLoadPriority priority;
WebCore::ContentSniffingPolicy contentSniffingPolicy;
WebCore::StoredCredentials allowStoredCredentials;
bool inPrivateBrowsingMode;
bool shouldClearReferrerOnHTTPSToHTTPRedirect;
};
} // namespace WebKit
......
......@@ -107,7 +107,17 @@ void WebResourceLoadScheduler::scheduleLoad(ResourceLoader* resourceLoader, Reso
WebFrame* webFrame = static_cast<WebFrameLoaderClient*>(resourceLoader->frameLoader()->client())->webFrame();
WebPage* webPage = webFrame->page();
NetworkResourceLoadParameters loadParameters(identifier, webPage->pageID(), webFrame->frameID(), resourceLoader->request(), priority, contentSniffingPolicy, allowStoredCredentials, privateBrowsingEnabled, shouldClearReferrerOnHTTPSToHTTPRedirect);
NetworkResourceLoadParameters loadParameters;
loadParameters.identifier = identifier;
loadParameters.webPageID = webPage->pageID();
loadParameters.webFrameID = webFrame->frameID();
loadParameters.request = resourceLoader->request();
loadParameters.priority = priority;
loadParameters.contentSniffingPolicy = contentSniffingPolicy;
loadParameters.allowStoredCredentials = allowStoredCredentials;
loadParameters.inPrivateBrowsingMode = privateBrowsingEnabled;
loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = shouldClearReferrerOnHTTPSToHTTPRedirect;
if (!WebProcess::shared().networkConnection()->connection()->send(Messages::NetworkConnectionToWebProcess::ScheduleResourceLoad(loadParameters), 0)) {
// We probably failed to schedule this load with the NetworkProcess because it had crashed.
// This load will never succeed so we will schedule it to fail asynchronously.
......
......@@ -235,7 +235,15 @@ void WebPlatformStrategies::loadResourceSynchronously(NetworkingContext* context
CoreIPC::DataReference dataReference;
NetworkResourceLoadParameters loadParameters(resourceLoadIdentifier, 0, 0, request, ResourceLoadPriorityHighest, SniffContent, storedCredentials, context->storageSession().isPrivateBrowsingSession(), context->shouldClearReferrerOnHTTPSToHTTPRedirect());
NetworkResourceLoadParameters loadParameters;
loadParameters.identifier = resourceLoadIdentifier;
loadParameters.request = request;
loadParameters.priority = ResourceLoadPriorityHighest;
loadParameters.contentSniffingPolicy = SniffContent;
loadParameters.allowStoredCredentials = storedCredentials;
loadParameters.inPrivateBrowsingMode = context->storageSession().isPrivateBrowsingSession();
loadParameters.shouldClearReferrerOnHTTPSToHTTPRedirect = context->shouldClearReferrerOnHTTPSToHTTPRedirect();
if (!WebProcess::shared().networkConnection()->connection()->sendSync(Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad(loadParameters), Messages::NetworkConnectionToWebProcess::PerformSynchronousLoad::Reply(error, response, dataReference), 0)) {
response = ResourceResponse();
error = internalError(request.url());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment