Title: [131919] trunk/Source/WebCore
- Revision
- 131919
- Author
- [email protected]
- Date
- 2012-10-19 10:40:55 -0700 (Fri, 19 Oct 2012)
Log Message
Reorder some functions in SubresourceLoader to permit main resources
https://bugs.webkit.org/show_bug.cgi?id=99769
Reviewed by Adam Barth.
Most resource types that go through the memory cache (and therefore
through SubresourceLoader) are not sensitive to the exact ordering of
the callbacks they receive, particularly as it relates to ResourceLoadNotifier
calls. Main resources are not so lenient. For main resources to be cacheable
and maintain the current behavior as precisely as possible, we will need to
rearrange SubresourceLoader's willSendRequest() and didReceiveData().
No new tests, refactor only.
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequest): There are a series of checks that can result
in the request being canceled, plus calls to CachedResource::willSendRequest() and
ResourceLoader::willSendRequest(). MainResourceLoader (which will be a
CachedResourceClient) has work it expects to do before ResourceLoader::willSendRequest()
is called, but the calls are out of order for that, so swap those.
(WebCore::SubresourceLoader::didReceiveData): We need to populate ResourceLoader::m_resourceData
before notifying CachedResource of new data, but we also want to do CachedResourceClients calls
before calling ResourceLoadNotifier. This means we can't delegate to ResourceLoader.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (131918 => 131919)
--- trunk/Source/WebCore/ChangeLog 2012-10-19 17:36:06 UTC (rev 131918)
+++ trunk/Source/WebCore/ChangeLog 2012-10-19 17:40:55 UTC (rev 131919)
@@ -1,3 +1,29 @@
+2012-10-19 Nate Chapin <[email protected]>
+
+ Reorder some functions in SubresourceLoader to permit main resources
+ https://bugs.webkit.org/show_bug.cgi?id=99769
+
+ Reviewed by Adam Barth.
+
+ Most resource types that go through the memory cache (and therefore
+ through SubresourceLoader) are not sensitive to the exact ordering of
+ the callbacks they receive, particularly as it relates to ResourceLoadNotifier
+ calls. Main resources are not so lenient. For main resources to be cacheable
+ and maintain the current behavior as precisely as possible, we will need to
+ rearrange SubresourceLoader's willSendRequest() and didReceiveData().
+
+ No new tests, refactor only.
+
+ * loader/SubresourceLoader.cpp:
+ (WebCore::SubresourceLoader::willSendRequest): There are a series of checks that can result
+ in the request being canceled, plus calls to CachedResource::willSendRequest() and
+ ResourceLoader::willSendRequest(). MainResourceLoader (which will be a
+ CachedResourceClient) has work it expects to do before ResourceLoader::willSendRequest()
+ is called, but the calls are out of order for that, so swap those.
+ (WebCore::SubresourceLoader::didReceiveData): We need to populate ResourceLoader::m_resourceData
+ before notifying CachedResource of new data, but we also want to do CachedResourceClients calls
+ before calling ResourceLoadNotifier. This means we can't delegate to ResourceLoader.
+
2012-10-19 Chris Fleizach <[email protected]>
AX: aria-hidden=false does not work as expected
Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (131918 => 131919)
--- trunk/Source/WebCore/loader/SubresourceLoader.cpp 2012-10-19 17:36:06 UTC (rev 131918)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp 2012-10-19 17:40:55 UTC (rev 131919)
@@ -128,17 +128,24 @@
{
// Store the previous URL because the call to ResourceLoader::willSendRequest will modify it.
KURL previousURL = request().url();
-
- ResourceLoader::willSendRequest(newRequest, redirectResponse);
- if (!previousURL.isNull() && !newRequest.isNull() && previousURL != newRequest.url()) {
- if (m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
- if (m_resource->type() != CachedResource::ImageResource || !m_documentLoader->cachedResourceLoader()->shouldDeferImageLoad(newRequest.url())) {
- m_resource->willSendRequest(newRequest, redirectResponse);
- return;
- }
+
+ ASSERT(!newRequest.isNull());
+ if (!previousURL.isNull() && previousURL != newRequest.url()) {
+ if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->type(), newRequest.url())) {
+ cancel();
+ return;
}
- cancel();
+ if (m_resource->type() == CachedResource::ImageResource && m_documentLoader->cachedResourceLoader()->shouldDeferImageLoad(newRequest.url())) {
+ cancel();
+ return;
+ }
+ m_resource->willSendRequest(newRequest, redirectResponse);
}
+
+ if (newRequest.isNull() || reachedTerminalState())
+ return;
+
+ ResourceLoader::willSendRequest(newRequest, redirectResponse);
}
void SubresourceLoader::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent)
@@ -207,12 +214,11 @@
// Reference the object in this method since the additional processing can do
// anything including removing the last reference to this object; one example of this is 3266216.
RefPtr<SubresourceLoader> protect(this);
- ResourceLoader::didReceiveData(data, length, encodedDataLength, allAtOnce);
-
- if (m_loadingMultipartContent)
- return;
-
- sendDataToResource(data, length);
+ addData(data, length, allAtOnce);
+ if (!m_loadingMultipartContent)
+ sendDataToResource(data, length);
+ if (shouldSendResourceLoadCallbacks() && m_frame)
+ frameLoader()->notifier()->didReceiveData(this, data, length, static_cast<int>(encodedDataLength));
}
bool SubresourceLoader::checkForHTTPStatusCodeError()
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes