Changeset 97765 in webkit
- Timestamp:
- Oct 18, 2011 9:31:32 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r97750 r97765 1 2011-10-18 Nate Chapin <japhet@chromium.org> 2 3 Test update for https://bugs.webkit.org/show_bug.cgi?id=61225. 4 Due to changes in the implementation of DocumentThreadableLoader (and 5 therefore XHR), this test will have empty (rather than null) content 6 if we go over the length limit. 7 8 Reviewed by Antti Koivisto. 9 10 * http/tests/inspector/network/network-content-replacement-xhr-expected.txt: 11 1 12 2011-10-18 Mihnea Ovidenie <mihnea@adobe.com> 2 13 -
trunk/LayoutTests/http/tests/inspector/network/network-content-replacement-xhr-expected.txt
r90389 r97765 3 3 4 4 http://127.0.0.1:8000/inspector/network/resources/resource.php?size=200 5 resource.content: null5 resource.content: 6 6 http://127.0.0.1:8000/inspector/network/resources/resource.php?size=100 7 7 resource.content: **************************************************************************************************** 8 8 http://127.0.0.1:8000/inspector/network/resources/resource.php?size=201 9 resource.content: null9 resource.content: 10 10 http://127.0.0.1:8000/inspector/network/resources/resource.php?size=100 11 11 resource.content: **************************************************************************************************** -
trunk/Source/WebCore/ChangeLog
r97764 r97765 1 2011-10-18 Nate Chapin <japhet@chromium.org> 2 3 Make DocumentThreadableLoader a CachedResourceClient. 4 This will allow us to cache ThreadableLoaderClients as 5 appropriate in a later patch. 6 https://bugs.webkit.org/show_bug.cgi?id=61225 7 8 Reviewed by Antti Koivisto. 9 10 No new tests, no functionality change intended. 11 12 * WebCore.gypi: 13 * loader/DocumentThreadableLoader.cpp: 14 (WebCore::DocumentThreadableLoader::notifyFinished): CachedResourceClients don't send separate callbacks 15 for didFail() and didFinishLoading(), so we need to differentiate here. 16 (WebCore::DocumentThreadableLoader::loadRequest): Call CachedResourceLoader::requestRawResource() 17 instead of ResourceLoadScheduler::scheduleSubresourceLoad(). 18 * loader/DocumentThreadableLoader.h: 19 * loader/cache/CachedRawResource.cpp: 20 (WebCore::CachedRawResource::data): Handle the complexity of some ThreadableLoaderClients setting 21 DoNotBufferData in ResoureLoaderOptions. If the DataBufferingPolicy is BufferData, then the 22 'data' input parameter will contain all data received so far, and we need to determine the 23 incremental data to forward to the clients. If the policy is DoNotBufferData, 'data' is just 24 the incremental data. 25 * loader/cache/CachedRawResource.h: 26 * loader/cache/CachedResource.cpp: 27 * loader/cache/CachedResource.h: 28 (WebCore::CachedResource::preloadResult): 29 (WebCore::CachedResource::didSendData): 30 (WebCore::CachedResource::didDownloadData): 31 (WebCore::CachedResource::setLoadFinishTime): 32 (WebCore::CachedResource::loadFinishTime): 33 * loader/cache/CachedResourceClient.h: Add several new callbacks needed by DocumentThreadableLoader. 34 * loader/cache/CachedResourceRequest.cpp: 35 (WebCore::CachedResourceRequest::didReceiveResponse): CachedResource::setResponse() can now cancel 36 the request, so protect appropriately. 37 * loader/cache/CachedResourceRequest.h: 38 * loader/chromium/CachedRawResourceChromium.cpp: Added (plumb didDownloadData() to DocumentThreadableLoader). 39 * loader/chromium/CachedResourceRequestChromium.cpp: Added (plumb didDownloadData() to DocumentThreadableLoader). 40 * loader/chromium/DocumentThreadableLoaderChromium.cpp: 41 * platform/network/BlobResourceHandle.cpp: 42 (WebCore::BlobResourceHandle::notifyResponse): Protect before setting response, since it might kill us. 43 1 44 2011-10-18 Sheriff Bot <webkit.review.bot@gmail.com> 2 45 -
trunk/Source/WebCore/WebCore.gypi
r97756 r97765 2854 2854 'loader/cache/MemoryCache.cpp', 2855 2855 'loader/cf/ResourceLoaderCFNet.cpp', 2856 'loader/chromium/CachedRawResourceChromium.cpp', 2857 'loader/chromium/CachedResourceRequestChromium.cpp', 2856 2858 'loader/chromium/DocumentThreadableLoaderChromium.cpp', 2857 2859 'loader/chromium/ResourceLoaderChromium.cpp', -
trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp
r96060 r97765 32 32 #include "DocumentThreadableLoader.h" 33 33 34 #include "AuthenticationChallenge.h" 34 #include "CachedRawResource.h" 35 #include "CachedResourceLoader.h" 35 36 #include "CrossOriginAccessControl.h" 36 37 #include "CrossOriginPreflightResultCache.h" … … 39 40 #include "Frame.h" 40 41 #include "FrameLoader.h" 41 #include "ResourceHandle.h" 42 #include "ResourceLoadScheduler.h" 42 #include "ResourceError.h" 43 43 #include "ResourceRequest.h" 44 44 #include "SecurityOrigin.h" 45 #include "SubresourceLoader.h"46 45 #include "ThreadableLoaderClient.h" 46 #include <wtf/Assertions.h> 47 47 #include <wtf/UnusedParam.h> 48 48 … … 64 64 { 65 65 RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, request, options)); 66 if (!loader->m_ loader)66 if (!loader->m_resource) 67 67 loader = 0; 68 68 return loader.release(); … … 134 134 DocumentThreadableLoader::~DocumentThreadableLoader() 135 135 { 136 if (m_ loader)137 m_ loader->clearClient();136 if (m_resource) 137 m_resource->removeClient(this); 138 138 } 139 139 140 140 void DocumentThreadableLoader::cancel() 141 141 { 142 if ( !m_loader)143 return;144 145 m_loader->cancel();146 m_loader->clearClient();147 m_loader = 0;142 if (m_client) { 143 ResourceError error(errorDomainWebKitInternal, 0, m_resource->url(), "Load cancelled"); 144 error.setIsCancellation(true); 145 didFail(error); 146 } 147 clearResource(); 148 148 m_client = 0; 149 149 } … … 151 151 void DocumentThreadableLoader::setDefersLoading(bool value) 152 152 { 153 if (m_loader) 154 m_loader->setDefersLoading(value); 155 } 156 157 void DocumentThreadableLoader::willSendRequest(SubresourceLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse) 158 { 159 ASSERT(m_client); 160 ASSERT_UNUSED(loader, loader == m_loader); 153 if (m_resource) 154 m_resource->setDefersLoading(value); 155 } 156 157 void DocumentThreadableLoader::clearResource() 158 { 159 if (m_resource) { 160 m_resource->removeClient(this); 161 m_resource = 0; 162 } 163 } 164 165 void DocumentThreadableLoader::redirectReceived(CachedResource* resource, ResourceRequest& request, const ResourceResponse& redirectResponse) 166 { 167 ASSERT(m_client); 168 ASSERT_UNUSED(resource, resource == m_resource); 161 169 162 170 if (!isAllowedRedirect(request.url())) { … … 170 178 } 171 179 172 void DocumentThreadableLoader::didSendData(SubresourceLoader* loader, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) 173 { 174 ASSERT(m_client); 175 ASSERT_UNUSED(loader, loader == m_loader); 176 180 void DocumentThreadableLoader::dataSent(CachedResource* resource, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) 181 { 182 ASSERT(m_client); 183 ASSERT_UNUSED(resource, resource == m_resource); 177 184 m_client->didSendData(bytesSent, totalBytesToBeSent); 178 185 } 179 186 180 void DocumentThreadableLoader:: didReceiveResponse(SubresourceLoader* loader, const ResourceResponse& response)181 { 182 ASSERT (loader == m_loader);183 didReceiveResponse( loader->identifier(), response);187 void DocumentThreadableLoader::responseReceived(CachedResource* resource, const ResourceResponse& response) 188 { 189 ASSERT_UNUSED(resource, resource == m_resource); 190 didReceiveResponse(m_resource->identifier(), response); 184 191 } 185 192 … … 224 231 } 225 232 226 void DocumentThreadableLoader::d idReceiveData(SubresourceLoader* loader, const char* data, int dataLength)227 { 228 ASSERT(m_client); 229 ASSERT_UNUSED( loader, loader == m_loader);233 void DocumentThreadableLoader::dataReceived(CachedResource* resource, const char* data, int dataLength) 234 { 235 ASSERT(m_client); 236 ASSERT_UNUSED(resource, resource == m_resource); 230 237 231 238 #if ENABLE(INSPECTOR) … … 241 248 } 242 249 243 void DocumentThreadableLoader::didReceiveCachedMetadata(SubresourceLoader* loader, const char* data, int dataLength) 244 { 245 ASSERT(m_client); 246 ASSERT_UNUSED(loader, loader == m_loader); 247 248 // Preflight data should be invisible to clients. 249 if (m_actualRequest) 250 return; 251 252 m_client->didReceiveCachedMetadata(data, dataLength); 253 } 254 255 void DocumentThreadableLoader::didFinishLoading(SubresourceLoader* loader, double finishTime) 256 { 257 ASSERT(loader == m_loader); 258 ASSERT(m_client); 259 didFinishLoading(loader->identifier(), finishTime); 250 void DocumentThreadableLoader::notifyFinished(CachedResource* resource) 251 { 252 ASSERT(m_client); 253 ASSERT_UNUSED(resource, resource == m_resource); 254 255 if (m_resource && (m_resource->errorOccurred() || m_resource->wasCanceled())) { 256 ResourceError error("Network Request Failed", 0, m_resource->url(), "Resource failed to load"); 257 if (m_resource->wasCanceled()) 258 error.setIsCancellation(true); 259 didFail(error); 260 } else 261 didFinishLoading(m_resource->identifier(), m_resource->loadFinishTime()); 260 262 } 261 263 … … 275 277 } 276 278 277 void DocumentThreadableLoader::didFail(SubresourceLoader* loader, const ResourceError& error) 278 { 279 ASSERT(m_client); 280 // m_loader may be null if we arrive here via SubresourceLoader::create in the ctor 281 ASSERT_UNUSED(loader, loader == m_loader || !m_loader); 282 279 void DocumentThreadableLoader::didFail(const ResourceError& error) 280 { 283 281 #if ENABLE(INSPECTOR) 284 282 if (m_preflightRequestIdentifier) … … 295 293 296 294 actualRequest->setHTTPOrigin(securityOrigin()->toString()); 295 296 clearResource(); 297 297 298 298 // It should be ok to skip the security check since we already asked about the preflight request. … … 325 325 } 326 326 327 ResourceRequest newRequest(request); 327 328 #if ENABLE(INSPECTOR) 328 329 if (m_actualRequest) { 329 ResourceRequest newRequest(request);330 330 // Because willSendRequest only gets called during redirects, we initialize the identifier and the first willSendRequest here. 331 331 m_preflightRequestIdentifier = m_document->frame()->page()->progress()->createUniqueIdentifier(); … … 334 334 } 335 335 #endif 336 337 // Clear the loader so that any callbacks from SubresourceLoader::create will not have the old loader.338 m_loader = 0;339 m_loader = resourceLoadScheduler()->scheduleSubresourceLoad(m_document->frame(), this, request, ResourceLoadPriorityMedium, options);336 ASSERT(!m_resource); 337 m_resource = m_document->cachedResourceLoader()->requestRawResource(newRequest, options); 338 if (m_resource) 339 m_resource->addClient(this); 340 340 return; 341 341 } … … 368 368 const char* bytes = static_cast<const char*>(data.data()); 369 369 int len = static_cast<int>(data.size()); 370 d idReceiveData(0, bytes, len);370 dataReceived(0, bytes, len); 371 371 372 372 didFinishLoading(identifier, 0.0); -
trunk/Source/WebCore/loader/DocumentThreadableLoader.h
r95901 r97765 32 32 #define DocumentThreadableLoader_h 33 33 34 #include "CachedRawResource.h" 35 #include "CachedResourceHandle.h" 34 36 #include "FrameLoaderTypes.h" 35 #include "SubresourceLoaderClient.h"36 37 #include "ThreadableLoader.h" 37 38 #include <wtf/Forward.h> … … 49 50 class ThreadableLoaderClient; 50 51 51 class DocumentThreadableLoader : public RefCounted<DocumentThreadableLoader>, public ThreadableLoader, private SubresourceLoaderClient {52 class DocumentThreadableLoader : public RefCounted<DocumentThreadableLoader>, public ThreadableLoader, private CachedRawResourceClient { 52 53 WTF_MAKE_FAST_ALLOCATED; 53 54 public: … … 74 75 DocumentThreadableLoader(Document*, ThreadableLoaderClient*, BlockingBehavior, const ResourceRequest&, const ThreadableLoaderOptions&); 75 76 76 virtual void willSendRequest(SubresourceLoader*, ResourceRequest&, const ResourceResponse& redirectResponse); 77 virtual void didSendData(SubresourceLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent); 77 void clearResource(); 78 78 79 virtual void didReceiveResponse(SubresourceLoader*, const ResourceResponse&);80 virtual void d idReceiveData(SubresourceLoader*, const char*, int dataLength);81 virtual void didReceiveCachedMetadata(SubresourceLoader*, const char*, int dataLength);82 virtual void d idFinishLoading(SubresourceLoader*, double);83 virtual void didFail(SubresourceLoader*, const ResourceError&);84 79 // CachedRawResourceClient 80 virtual void dataSent(CachedResource*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent); 81 virtual void responseReceived(CachedResource*, const ResourceResponse&); 82 virtual void dataReceived(CachedResource*, const char* data, int dataLength); 83 virtual void redirectReceived(CachedResource*, ResourceRequest&, const ResourceResponse&); 84 virtual void notifyFinished(CachedResource*); 85 85 #if PLATFORM(CHROMIUM) 86 virtual void d idDownloadData(SubresourceLoader*, int dataLength);86 virtual void dataDownloaded(CachedResource*, int); 87 87 #endif 88 88 89 89 void didReceiveResponse(unsigned long identifier, const ResourceResponse&); 90 90 void didFinishLoading(unsigned long identifier, double finishTime); 91 void didFail(const ResourceError&); 91 92 void makeSimpleCrossOriginAccessRequest(const ResourceRequest& request); 92 93 void makeCrossOriginAccessRequestWithPreflight(const ResourceRequest& request); … … 99 100 SecurityOrigin* securityOrigin() const; 100 101 101 RefPtr<SubresourceLoader> m_loader;102 CachedResourceHandle<CachedRawResource> m_resource; 102 103 ThreadableLoaderClient* m_client; 103 104 Document* m_document; -
trunk/Source/WebCore/loader/cache/CachedRawResource.cpp
r96961 r97765 38 38 CachedRawResource::CachedRawResource(ResourceRequest& resourceRequest) 39 39 : CachedResource(resourceRequest, RawResource) 40 , m_dataLength(0) 40 41 { 41 42 } … … 43 44 void CachedRawResource::data(PassRefPtr<SharedBuffer> data, bool allDataReceived) 44 45 { 45 m_data = data; 46 if (data) { 47 // If we are buffering data, then we are saving the buffer in m_data and need to manually 48 // calculate the incremental data. If we are not buffering, then m_data will be null and 49 // the buffer contains only the incremental data. 50 size_t previousDataLength = (m_options.shouldBufferData == BufferData) ? m_dataLength : 0; 51 ASSERT(data->size() >= previousDataLength); 52 const char* incrementalData = data->data() + previousDataLength; 53 size_t incrementalDataLength = data->size() - previousDataLength; 54 55 if (incrementalDataLength) { 56 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); 57 while (CachedRawResourceClient* c = w.next()) 58 c->dataReceived(this, incrementalData, incrementalDataLength); 59 } 60 } 61 62 if (m_options.shouldBufferData == BufferData) { 63 m_dataLength = data ? data->size() : 0; 64 m_data = data; 65 } 46 66 CachedResource::data(m_data, allDataReceived); 67 } 68 69 void CachedRawResource::didAddClient(CachedResourceClient* c) 70 { 71 if (m_data) { 72 static_cast<CachedRawResourceClient*>(c)->responseReceived(this, m_response); 73 static_cast<CachedRawResourceClient*>(c)->dataReceived(this, m_data->data(), m_data->size()); 74 } 75 CachedResource::didAddClient(c); 47 76 } 48 77 … … 53 82 } 54 83 84 void CachedRawResource::willSendRequest(ResourceRequest& request, const ResourceResponse& response) 85 { 86 if (!response.isNull()) { 87 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); 88 while (CachedRawResourceClient* c = w.next()) 89 c->redirectReceived(this, request, response); 90 } 91 CachedResource::willSendRequest(request, response); 92 } 93 94 void CachedRawResource::setResponse(const ResourceResponse& response) 95 { 96 CachedResource::setResponse(response); 97 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); 98 while (CachedRawResourceClient* c = w.next()) 99 c->responseReceived(this, m_response); 100 } 101 102 void CachedRawResource::didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent) 103 { 104 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); 105 while (CachedRawResourceClient* c = w.next()) 106 c->dataSent(this, bytesSent, totalBytesToBeSent); 107 } 108 109 void CachedRawResource::setDefersLoading(bool defers) 110 { 111 if (m_request) 112 m_request->setDefersLoading(defers); 113 } 114 115 unsigned long CachedRawResource::identifier() const 116 { 117 return m_request ? m_request->identifier() : 0; 118 } 119 55 120 } // namespace WebCore -
trunk/Source/WebCore/loader/cache/CachedRawResource.h
r96961 r97765 25 25 26 26 #include "CachedResource.h" 27 #include "CachedResourceClient.h" 27 28 28 29 namespace WebCore { … … 31 32 public: 32 33 CachedRawResource(ResourceRequest&); 34 35 // FIXME: AssociatedURLLoader shouldn't be a DocumentThreadableLoader and therefore shouldn't 36 // use CachedRawResource. However, it is, and it needs to be able to defer loading. 37 // This can be fixed by splitting CORS preflighting out of DocumentThreacableLoader. 38 virtual void setDefersLoading(bool); 33 39 40 // FIXME: This is exposed for the InpsectorInstrumentation for preflights in DocumentThreadableLoader. It's also really lame. 41 unsigned long identifier() const; 42 34 43 private: 44 virtual void didAddClient(CachedResourceClient*); 35 45 virtual void data(PassRefPtr<SharedBuffer> data, bool allDataReceived); 36 46 37 47 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return true; } 38 48 virtual void allClientsRemoved(); 49 50 virtual void willSendRequest(ResourceRequest&, const ResourceResponse&); 51 virtual void setResponse(const ResourceResponse&); 52 virtual void didSendData(unsigned long long bytesSent, unsigned long long totalBytesToBeSent); 53 #if PLATFORM(CHROMIUM) 54 virtual void didDownloadData(int); 55 #endif 56 57 size_t m_dataLength; 58 }; 59 60 61 class CachedRawResourceClient : public CachedResourceClient { 62 public: 63 virtual ~CachedRawResourceClient() { } 64 static CachedResourceClientType expectedType() { return RawResourceType; } 65 virtual CachedResourceClientType resourceClientType() { return expectedType(); } 66 67 virtual void dataSent(CachedResource*, unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { } 68 virtual void responseReceived(CachedResource*, const ResourceResponse&) { } 69 virtual void dataReceived(CachedResource*, const char* /* data */, int /* length */) { } 70 virtual void redirectReceived(CachedResource*, ResourceRequest&, const ResourceResponse&) { } 71 #if PLATFORM(CHROMIUM) 72 virtual void dataDownloaded(CachedResource*, int) { } 73 #endif 39 74 }; 40 75 -
trunk/Source/WebCore/loader/cache/CachedResource.cpp
r97637 r97765 88 88 , m_responseTimestamp(currentTime()) 89 89 , m_lastDecodedAccessTime(0) 90 , m_loadFinishTime(0) 90 91 , m_encodedSize(0) 91 92 , m_decodedSize(0) -
trunk/Source/WebCore/loader/cache/CachedResource.h
r97637 r97765 119 119 }; 120 120 PreloadResult preloadResult() const { return static_cast<PreloadResult>(m_preloadResult); } 121 void setRequestedFromNetworkingLayer() { m_requestedFromNetworkingLayer = true; }122 121 123 122 virtual void didAddClient(CachedResourceClient*); … … 174 173 SharedBuffer* data() const { ASSERT(!m_purgeableData); return m_data.get(); } 175 174 176 void setResponse(const ResourceResponse&); 175 virtual void willSendRequest(ResourceRequest&, const ResourceResponse&) { m_requestedFromNetworkingLayer = true; } 176 virtual void setResponse(const ResourceResponse&); 177 177 const ResourceResponse& response() const { return m_response; } 178 178 … … 232 232 void clearResourceToRevalidate(); 233 233 void updateResponseAfterRevalidation(const ResourceResponse& validatingResponse); 234 235 virtual void didSendData(unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */) { } 236 #if PLATFORM(CHROMIUM) 237 virtual void didDownloadData(int) { } 238 #endif 239 240 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } 241 double loadFinishTime() const { return m_loadFinishTime; } 234 242 235 243 protected: … … 267 275 268 276 double m_lastDecodedAccessTime; // Used as a "thrash guard" in the cache 277 double m_loadFinishTime; 269 278 270 279 unsigned m_encodedSize; -
trunk/Source/WebCore/loader/cache/CachedResourceClient.h
r97637 r97765 39 39 ImageType, 40 40 FontType, 41 StyleSheetType 41 StyleSheetType, 42 RawResourceType 42 43 }; 43 44 -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.cpp
r97637 r97765 91 91 CachedResourceRequest::~CachedResourceRequest() 92 92 { 93 if (m_loader) 94 m_loader->clearClient(); 93 95 } 94 96 … … 143 145 } 144 146 145 void CachedResourceRequest::willSendRequest(SubresourceLoader* loader, ResourceRequest& req, const ResourceResponse& )147 void CachedResourceRequest::willSendRequest(SubresourceLoader* loader, ResourceRequest& req, const ResourceResponse& response) 146 148 { 147 149 if (!m_cachedResourceLoader->canRequest(m_resource->type(), req.url())) { … … 149 151 return; 150 152 } 151 m_resource-> setRequestedFromNetworkingLayer();153 m_resource->willSendRequest(req, response); 152 154 } 153 155 … … 159 161 } 160 162 161 void CachedResourceRequest::didFinishLoading(SubresourceLoader* loader, double) 163 unsigned long CachedResourceRequest::identifier() const 164 { 165 return m_loader->identifier(); 166 } 167 168 void CachedResourceRequest::setDefersLoading(bool defers) 169 { 170 if (m_loader) 171 m_loader->setDefersLoading(defers); 172 } 173 174 void CachedResourceRequest::didFinishLoading(SubresourceLoader* loader, double finishTime) 162 175 { 163 176 if (m_finishing) … … 179 192 if (!m_resource->errorOccurred()) { 180 193 m_cachedResourceLoader->loadFinishing(); 194 m_resource->setLoadFinishTime(finishTime); 181 195 m_resource->data(loader->resourceData(), true); 182 196 if (!m_resource->errorOccurred()) … … 240 254 } 241 255 256 // setResponse() might cancel the request, so we need to keep ourselves alive. Unfortunately, 257 // we can't protect a CachedResourceRequest, but we can protect m_resource, which has the 258 // power to kill the CachedResourceRequest (and will switch isLoading() to false if it does so). 259 CachedResourceHandle<CachedResource> protect(m_resource); 242 260 m_resource->setResponse(response); 261 if (!protect->isLoading()) 262 return; 243 263 244 264 String encoding = response.textEncodingName(); … … 272 292 return; 273 293 274 if (m_resource->response().httpStatusCode() >= 400) { 275 if (!m_resource->shouldIgnoreHTTPStatusCodeErrors()) 276 m_resource->error(CachedResource::LoadError); 277 return; 278 } 279 280 // Set the data. 281 if (m_multipart) { 282 // The loader delivers the data in a multipart section all at once, send eof. 283 // The resource data will change as the next part is loaded, so we need to make a copy. 294 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgnoreHTTPStatusCodeErrors()) { 295 m_resource->error(CachedResource::LoadError); 296 return; 297 } 298 299 // There are two cases where we might need to create our own SharedBuffer instead of copying the one in ResourceLoader. 300 // (1) Multipart content: The loader delivers the data in a multipart section all at once, then sends eof. 301 // The resource data will change as the next part is loaded, so we need to make a copy. 302 // (2) Our client requested that the data not be buffered at the ResourceLoader level via ResourceLoaderOptions. In this case, 303 // ResourceLoader::resourceData() will be null. However, unlike the multipart case, we don't want to tell the CachedResource 304 // that all data has been received yet. 305 if (m_multipart || !loader->resourceData()) { 284 306 RefPtr<SharedBuffer> copiedData = SharedBuffer::create(data, size); 285 m_resource->data(copiedData.release(), true);307 m_resource->data(copiedData.release(), m_multipart); 286 308 } else 287 309 m_resource->data(loader->resourceData(), false); … … 293 315 m_resource->setSerializedCachedMetadata(data, size); 294 316 } 295 317 318 void CachedResourceRequest::didSendData(SubresourceLoader*, unsigned long long bytesSent, unsigned long long totalBytesToBeSent) 319 { 320 m_resource->didSendData(bytesSent, totalBytesToBeSent); 321 } 322 296 323 void CachedResourceRequest::end() 297 324 { -
trunk/Source/WebCore/loader/cache/CachedResourceRequest.h
r96961 r97765 50 50 void cancel(); 51 51 52 // FIXME: Like CachedResource::identifier(), this is a lame hack for preflight InspectorInstrumentation in DocumentThreadableLoader. 53 unsigned long identifier() const; 54 55 // FIXME: See CachedRawResource::setDefersLoading() for the relevant rant. 56 void setDefersLoading(bool); 57 52 58 private: 53 59 CachedResourceRequest(CachedResourceLoader*, CachedResource*); … … 59 65 virtual void didFail(SubresourceLoader*, const ResourceError&); 60 66 void end(); 67 68 virtual void didSendData(SubresourceLoader*, unsigned long long /*bytesSent*/, unsigned long long /*totalBytesToBeSent*/); 69 #if PLATFORM(CHROMIUM) 70 virtual void didDownloadData(SubresourceLoader*, int); 71 #endif 61 72 62 73 RefPtr<SubresourceLoader> m_loader; -
trunk/Source/WebCore/loader/chromium/CachedRawResourceChromium.cpp
r97764 r97765 30 30 31 31 #include "config.h" 32 #include " DocumentThreadableLoader.h"32 #include "CachedRawResource.h" 33 33 34 #include " SubresourceLoader.h"35 #include " ThreadableLoaderClient.h"34 #include "CachedResourceClient.h" 35 #include "CachedResourceClientWalker.h" 36 36 37 37 namespace WebCore { 38 38 39 void DocumentThreadableLoader::didDownloadData(SubresourceLoader* loader,int dataLength)39 void CachedRawResource::didDownloadData(int dataLength) 40 40 { 41 ASSERT(m_client); 42 ASSERT_UNUSED(loader, loader == m_loader); 43 ASSERT(!m_actualRequest); 44 45 m_client->didDownloadData(dataLength); 41 CachedResourceClientWalker<CachedRawResourceClient> w(m_clients); 42 while (CachedRawResourceClient* c = w.next()) 43 c->dataDownloaded(this, dataLength); 46 44 } 47 45 48 } // namespace WebCore46 } -
trunk/Source/WebCore/loader/chromium/CachedResourceRequestChromium.cpp
r97764 r97765 30 30 31 31 #include "config.h" 32 #include " DocumentThreadableLoader.h"32 #include "CachedResourceRequest.h" 33 33 34 #include "CachedResource.h" 34 35 #include "SubresourceLoader.h" 35 #include "ThreadableLoaderClient.h"36 36 37 37 namespace WebCore { 38 38 39 void DocumentThreadableLoader::didDownloadData(SubresourceLoader* loader, int dataLength)39 void CachedResourceRequest::didDownloadData(SubresourceLoader* loader, int length) 40 40 { 41 ASSERT(m_client);42 41 ASSERT_UNUSED(loader, loader == m_loader); 43 ASSERT(!m_actualRequest); 44 45 m_client->didDownloadData(dataLength); 42 m_resource->didDownloadData(length); 46 43 } 47 44 48 } // namespace WebCore45 } -
trunk/Source/WebCore/loader/chromium/DocumentThreadableLoaderChromium.cpp
r95901 r97765 32 32 #include "DocumentThreadableLoader.h" 33 33 34 #include " SubresourceLoader.h"34 #include "CachedRawResource.h" 35 35 #include "ThreadableLoaderClient.h" 36 36 37 37 namespace WebCore { 38 38 39 void DocumentThreadableLoader::d idDownloadData(SubresourceLoader* loader, int dataLength)39 void DocumentThreadableLoader::dataDownloaded(CachedResource* resource, int dataLength) 40 40 { 41 41 ASSERT(m_client); 42 ASSERT_UNUSED( loader, loader == m_loader);42 ASSERT_UNUSED(resource, resource == m_resource); 43 43 ASSERT(!m_actualRequest); 44 44 -
trunk/Source/WebCore/loader/icon/IconLoader.h
r96961 r97765 27 27 #define IconLoader_h 28 28 29 #include "CachedR esourceClient.h"29 #include "CachedRawResource.h" 30 30 #include "CachedResourceHandle.h" 31 31 #include <wtf/Forward.h> … … 38 38 class Frame; 39 39 40 class IconLoader : private CachedR esourceClient {40 class IconLoader : private CachedRawResourceClient { 41 41 WTF_MAKE_NONCOPYABLE(IconLoader); WTF_MAKE_FAST_ALLOCATED; 42 42 public: 43 43 static PassOwnPtr<IconLoader> create(Frame*); 44 ~IconLoader();44 virtual ~IconLoader(); 45 45 46 46 void startLoading(); -
trunk/Source/WebCore/platform/network/BlobResourceHandle.cpp
r95901 r97765 539 539 540 540 if (m_errorCode) { 541 RefPtr<BlobResourceHandle> protect(this); 541 542 notifyResponseOnError(); 542 543 notifyFinish();
Note: See TracChangeset
for help on using the changeset viewer.