CTTE: DocumentThreadableLoader always has a Document.
<https://webkit.org/b/128364>
DocumentThreadableLoader always has an "owner" Document, so store
that as a reference instead of a pointer. Removed some unnecessary
assertions exposed by this change.
Reviewed by Antti Koivisto.
* loader/DocumentThreadableLoader.cpp:
(WebCore::DocumentThreadableLoader::loadResourceSynchronously):
(WebCore::DocumentThreadableLoader::create):
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader):
(WebCore::DocumentThreadableLoader::didReceiveResponse):
(WebCore::DocumentThreadableLoader::didReceiveData):
(WebCore::DocumentThreadableLoader::didFinishLoading):
(WebCore::DocumentThreadableLoader::didFail):
(WebCore::DocumentThreadableLoader::preflightFailure):
(WebCore::DocumentThreadableLoader::loadRequest):
(WebCore::DocumentThreadableLoader::securityOrigin):
* loader/DocumentThreadableLoader.h:
* loader/ThreadableLoader.cpp:
(WebCore::ThreadableLoader::create):
(WebCore::ThreadableLoader::loadResourceSynchronously):
* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::mainThreadCreateLoader):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163622 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/loader/DocumentThreadableLoader.cpp b/Source/WebCore/loader/DocumentThreadableLoader.cpp
index 02e98eb..f15fc18 100644
--- a/Source/WebCore/loader/DocumentThreadableLoader.cpp
+++ b/Source/WebCore/loader/DocumentThreadableLoader.cpp
@@ -56,14 +56,14 @@
namespace WebCore {
-void DocumentThreadableLoader::loadResourceSynchronously(Document* document, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
+void DocumentThreadableLoader::loadResourceSynchronously(Document& document, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
{
// The loader will be deleted as soon as this function exits.
- RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, &client, LoadSynchronously, request, options));
+ RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadSynchronously, request, options));
ASSERT(loader->hasOneRef());
}
-PassRefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document* document, ThreadableLoaderClient* client, const ResourceRequest& request, const ThreadableLoaderOptions& options)
+PassRefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document& document, ThreadableLoaderClient& client, const ResourceRequest& request, const ThreadableLoaderOptions& options)
{
RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, request, options));
if (!loader->m_resource)
@@ -71,16 +71,14 @@
return loader.release();
}
-DocumentThreadableLoader::DocumentThreadableLoader(Document* document, ThreadableLoaderClient* client, BlockingBehavior blockingBehavior, const ResourceRequest& request, const ThreadableLoaderOptions& options)
- : m_client(client)
+DocumentThreadableLoader::DocumentThreadableLoader(Document& document, ThreadableLoaderClient& client, BlockingBehavior blockingBehavior, const ResourceRequest& request, const ThreadableLoaderOptions& options)
+ : m_client(&client)
, m_document(document)
, m_options(options)
, m_sameOriginRequest(securityOrigin()->canRequest(request.url()))
, m_simpleRequest(true)
, m_async(blockingBehavior == LoadAsynchronously)
{
- ASSERT(document);
- ASSERT(client);
// Setting an outgoing referer is only supported in the async code path.
ASSERT(m_async || request.httpReferrer().isEmpty());
@@ -248,8 +246,8 @@
String accessControlErrorDescription;
if (m_actualRequest) {
#if ENABLE(INSPECTOR)
- DocumentLoader* loader = m_document->frame()->loader().documentLoader();
- InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_document->frame(), identifier, response);
+ DocumentLoader* loader = m_document.frame()->loader().documentLoader();
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceResponse(m_document.frame(), identifier, response);
InspectorInstrumentation::didReceiveResourceResponse(cookie, identifier, loader, response, 0);
#endif
@@ -293,7 +291,7 @@
// Preflight data should be invisible to clients.
if (m_actualRequest) {
#if ENABLE(INSPECTOR)
- InspectorInstrumentation::didReceiveData(m_document->frame(), identifier, 0, 0, dataLength);
+ InspectorInstrumentation::didReceiveData(m_document.frame(), identifier, 0, 0, dataLength);
#else
UNUSED_PARAM(identifier);
#endif
@@ -318,7 +316,7 @@
{
if (m_actualRequest) {
#if ENABLE(INSPECTOR)
- InspectorInstrumentation::didFinishLoading(m_document->frame(), m_document->frame()->loader().documentLoader(), identifier, finishTime);
+ InspectorInstrumentation::didFinishLoading(m_document.frame(), m_document.frame()->loader().documentLoader(), identifier, finishTime);
#endif
ASSERT(!m_sameOriginRequest);
ASSERT(m_options.crossOriginRequestPolicy == UseAccessControl);
@@ -331,7 +329,7 @@
{
#if ENABLE(INSPECTOR)
if (m_actualRequest)
- InspectorInstrumentation::didFailLoading(m_document->frame(), m_document->frame()->loader().documentLoader(), identifier, error);
+ InspectorInstrumentation::didFailLoading(m_document.frame(), m_document.frame()->loader().documentLoader(), identifier, error);
#else
UNUSED_PARAM(identifier);
#endif
@@ -357,7 +355,7 @@
ResourceError error(errorDomainWebKitInternal, 0, url, errorDescription);
#if ENABLE(INSPECTOR)
if (m_actualRequest)
- InspectorInstrumentation::didFailLoading(m_document->frame(), m_document->frame()->loader().documentLoader(), identifier, error);
+ InspectorInstrumentation::didFailLoading(m_document.frame(), m_document.frame()->loader().documentLoader(), identifier, error);
#else
UNUSED_PARAM(identifier);
#endif
@@ -389,12 +387,12 @@
newRequest.setInitiator(m_options.initiator);
#endif
ASSERT(!m_resource);
- m_resource = m_document->cachedResourceLoader()->requestRawResource(newRequest);
+ m_resource = m_document.cachedResourceLoader()->requestRawResource(newRequest);
if (m_resource) {
#if ENABLE(INSPECTOR)
if (m_resource->loader()) {
unsigned long identifier = m_resource->loader()->identifier();
- InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_document, identifier, m_client);
+ InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(&m_document, identifier, m_client);
}
#endif
m_resource->addClient(this);
@@ -407,10 +405,10 @@
ResourceError error;
ResourceResponse response;
unsigned long identifier = std::numeric_limits<unsigned long>::max();
- if (m_document->frame())
- identifier = m_document->frame()->loader().loadResourceSynchronously(request, m_options.allowCredentials, m_options.clientCredentialPolicy, error, response, data);
+ if (m_document.frame())
+ identifier = m_document.frame()->loader().loadResourceSynchronously(request, m_options.allowCredentials, m_options.clientCredentialPolicy, error, response, data);
- InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(m_document, identifier, m_client);
+ InspectorInstrumentation::documentThreadableLoaderStartedLoadingForClient(&m_document, identifier, m_client);
// No exception for file:/// resources, see <rdar://problem/4962298>.
// Also, if we have an HTTP response, then it wasn't a network error in fact.
@@ -446,7 +444,7 @@
SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
{
- return m_options.securityOrigin ? m_options.securityOrigin.get() : m_document->securityOrigin();
+ return m_options.securityOrigin ? m_options.securityOrigin.get() : m_document.securityOrigin();
}
} // namespace WebCore