Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(885)

Unified Diff: trunk/Source/core/loader/ResourceLoader.cpp

Issue 19683007: Revert 154452 "Refactoring: Introduce ResouceLoaderHost interfac..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/Source/core/loader/ResourceLoader.h ('k') | trunk/Source/core/loader/ResourceLoaderHost.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/Source/core/loader/ResourceLoader.cpp
===================================================================
--- trunk/Source/core/loader/ResourceLoader.cpp (revision 154456)
+++ trunk/Source/core/loader/ResourceLoader.cpp (working copy)
@@ -31,7 +31,12 @@
#include "core/loader/ResourceLoader.h"
#include "core/inspector/InspectorInstrumentation.h"
-#include "core/loader/ResourceLoaderHost.h"
+#include "core/loader/DocumentLoader.h"
+#include "core/loader/FrameLoader.h"
+#include "core/loader/FrameLoaderClient.h"
+#include "core/loader/appcache/ApplicationCacheHost.h"
+#include "core/loader/cache/CachedResourceLoader.h"
+#include "core/page/Frame.h"
#include "core/page/Page.h"
#include "core/platform/Logging.h"
#include "core/platform/network/ResourceError.h"
@@ -39,36 +44,37 @@
namespace WebCore {
-ResourceLoader::RequestCountTracker::RequestCountTracker(ResourceLoaderHost* host, CachedResource* resource)
- : m_host(host)
+ResourceLoader::RequestCountTracker::RequestCountTracker(CachedResourceLoader* cachedResourceLoader, CachedResource* resource)
+ : m_cachedResourceLoader(cachedResourceLoader)
, m_resource(resource)
{
- m_host->incrementRequestCount(m_resource);
+ m_cachedResourceLoader->incrementRequestCount(m_resource);
}
ResourceLoader::RequestCountTracker::~RequestCountTracker()
{
- m_host->decrementRequestCount(m_resource);
+ m_cachedResourceLoader->decrementRequestCount(m_resource);
}
-PassRefPtr<ResourceLoader> ResourceLoader::create(ResourceLoaderHost* host, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
+PassRefPtr<ResourceLoader> ResourceLoader::create(DocumentLoader* documentLoader, CachedResource* resource, const ResourceRequest& request, const ResourceLoaderOptions& options)
{
- RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(host, resource, options)));
+ RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(documentLoader, resource, options)));
if (!loader->init(request))
return 0;
loader->start();
return loader.release();
}
-ResourceLoader::ResourceLoader(ResourceLoaderHost* host, CachedResource* resource, const ResourceLoaderOptions& options)
- : m_host(host)
+ResourceLoader::ResourceLoader(DocumentLoader* documentLoader, CachedResource* resource, ResourceLoaderOptions options)
+ : m_frame(documentLoader->frame())
+ , m_documentLoader(documentLoader)
, m_loadingMultipartContent(false)
, m_notifiedLoadComplete(false)
- , m_defersLoading(host->defersLoading())
+ , m_defersLoading(m_frame->page()->defersLoading())
, m_options(options)
, m_resource(resource)
, m_state(Uninitialized)
- , m_requestCountTracker(adoptPtr(new RequestCountTracker(host, resource)))
+ , m_requestCountTracker(adoptPtr(new RequestCountTracker(documentLoader->cachedResourceLoader(), resource)))
{
}
@@ -82,11 +88,11 @@
ASSERT(m_state != Terminated);
if (m_state != Uninitialized) {
m_requestCountTracker.clear();
- m_host->didLoadResource(m_resource);
+ m_documentLoader->cachedResourceLoader()->loadDone(m_resource);
if (m_state == Terminated)
return;
m_resource->clearLoader();
- m_host->willTerminateResourceLoader(this);
+ m_documentLoader->removeResourceLoader(this);
}
ASSERT(m_state != Terminated);
@@ -97,7 +103,9 @@
// has been deallocated and also to avoid reentering this method.
RefPtr<ResourceLoader> protector(this);
- m_host.clear();
+ m_frame = 0;
+ m_documentLoader = 0;
+
m_state = Terminated;
if (m_handle) {
@@ -128,7 +136,7 @@
m_originalRequest = m_request = clientRequest;
m_state = Initialized;
- m_host->didInitializeResourceLoader(this);
+ m_documentLoader->addResourceLoader(this);
return true;
}
@@ -138,7 +146,7 @@
ASSERT(!m_request.isNull());
ASSERT(m_deferredRequest.isNull());
- m_host->willStartLoadingResource(m_request);
+ m_documentLoader->applicationCacheHost()->willStartLoadingResource(m_request);
if (m_defersLoading) {
m_deferredRequest = m_request;
@@ -161,6 +169,13 @@
}
}
+FrameLoader* ResourceLoader::frameLoader() const
+{
+ if (!m_frame)
+ return 0;
+ return m_frame->loader();
+}
+
void ResourceLoader::didDownloadData(ResourceHandle*, int length)
{
RefPtr<ResourceLoader> protect(this);
@@ -177,13 +192,14 @@
if (m_notifiedLoadComplete)
return;
m_notifiedLoadComplete = true;
- m_host->didFinishLoading(m_resource, finishTime, m_options);
+ if (m_options.sendLoadCallbacks == SendCallbacks)
+ frameLoader()->notifier()->dispatchDidFinishLoading(m_documentLoader.get(), m_resource->identifier(), finishTime);
}
void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority)
{
if (handle()) {
- m_host->didChangeLoadingPriority(m_resource, loadPriority);
+ frameLoader()->client()->dispatchDidChangeResourcePriority(m_resource->identifier(), loadPriority);
handle()->didChangePriority(loadPriority);
}
}
@@ -226,7 +242,8 @@
m_handle = 0;
}
- m_host->didFailLoading(m_resource, nonNullError, m_options);
+ if (m_options.sendLoadCallbacks == SendCallbacks && !m_notifiedLoadComplete)
+ frameLoader()->notifier()->dispatchDidFail(m_documentLoader.get(), m_resource->identifier(), nonNullError);
if (m_state == Finishing)
m_resource->error(CachedResource::LoadError);
@@ -242,18 +259,25 @@
ASSERT(!request.isNull());
if (!redirectResponse.isNull()) {
- if (!m_host->shouldRequest(m_resource, request, m_options)) {
+ if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), request.url(), m_options)) {
cancel();
return;
}
-
+ if (m_resource->type() == CachedResource::ImageResource && m_documentLoader->cachedResourceLoader()->shouldDeferImageLoad(request.url())) {
+ cancel();
+ return;
+ }
m_resource->willSendRequest(request, redirectResponse);
}
if (request.isNull() || m_state == Terminated)
return;
- m_host->willSendRequest(m_resource, request, redirectResponse, m_options);
+ if (m_options.sendLoadCallbacks == SendCallbacks)
+ frameLoader()->notifier()->dispatchWillSendRequest(m_documentLoader.get(), m_resource->identifier(), request, redirectResponse, m_options.initiatorInfo);
+ else
+ InspectorInstrumentation::willSendRequest(m_frame.get(), m_resource->identifier(), m_documentLoader.get(), request, redirectResponse, m_options.initiatorInfo);
+
m_request = request;
if (request.isNull())
@@ -285,7 +309,8 @@
if (m_state == Terminated)
return;
- m_host->didReceiveResponse(m_resource, response, m_options);
+ if (m_options.sendLoadCallbacks == SendCallbacks)
+ frameLoader()->notifier()->dispatchDidReceiveResponse(m_documentLoader.get(), m_resource->identifier(), response);
if (response.isMultipart()) {
m_loadingMultipartContent = true;
@@ -299,7 +324,7 @@
} else if (m_loadingMultipartContent) {
// Since a subresource loader does not load multipart sections progressively, data was delivered to the loader all at once.
// After the first multipart section is complete, signal to delegates that this load is "finished"
- m_host->subresourceLoaderFinishedLoadingOnePart(this);
+ m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this);
didFinishLoadingOnePart(0);
}
@@ -316,7 +341,7 @@
// loop. When this occurs, ignoring the data is the correct action.
if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors())
return;
- InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_host->inspectedFrame(), m_resource->identifier(), encodedDataLength);
+ InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiveResourceData(m_frame.get(), m_resource->identifier(), encodedDataLength);
ASSERT(m_state == Initialized);
// Reference the object in this method since the additional processing can do
@@ -326,7 +351,9 @@
// FIXME: If we get a resource with more than 2B bytes, this code won't do the right thing.
// However, with today's computers and networking speeds, this won't happen in practice.
// Could be an issue with a giant local file.
- m_host->didReceiveData(m_resource, data, length, encodedDataLength, m_options);
+ if (m_options.sendLoadCallbacks == SendCallbacks && m_frame)
+ frameLoader()->notifier()->dispatchDidReceiveData(m_documentLoader.get(), m_resource->identifier(), data, length, static_cast<int>(encodedDataLength));
+
m_resource->appendData(data, length);
InspectorInstrumentation::didReceiveResourceData(cookie);
@@ -358,7 +385,6 @@
LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().latin1().data());
RefPtr<ResourceLoader> protect(this);
- RefPtr<ResourceLoaderHost> protectHost(m_host);
CachedResourceHandle<CachedResource> protectResource(m_resource);
m_state = Finishing;
m_resource->setResourceError(error);
@@ -369,15 +395,11 @@
if (!m_notifiedLoadComplete) {
m_notifiedLoadComplete = true;
- m_host->didFailLoading(m_resource, error, m_options);
+ if (m_options.sendLoadCallbacks == SendCallbacks)
+ frameLoader()->notifier()->dispatchDidFail(m_documentLoader.get(), m_resource->identifier(), error);
}
releaseResources();
}
-bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const
-{
- return m_host->isLoadedBy(loader);
}
-
-}
« no previous file with comments | « trunk/Source/core/loader/ResourceLoader.h ('k') | trunk/Source/core/loader/ResourceLoaderHost.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698