OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) | 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/loader/ResourceLoader.h" | 31 #include "core/loader/ResourceLoader.h" |
32 | 32 |
33 #include "core/inspector/InspectorInstrumentation.h" | 33 #include "core/inspector/InspectorInstrumentation.h" |
34 #include "core/loader/DocumentLoader.h" | 34 #include "core/loader/ResourceLoaderHost.h" |
35 #include "core/loader/FrameLoader.h" | |
36 #include "core/loader/FrameLoaderClient.h" | |
37 #include "core/loader/appcache/ApplicationCacheHost.h" | |
38 #include "core/loader/cache/CachedResourceLoader.h" | |
39 #include "core/page/Frame.h" | |
40 #include "core/page/Page.h" | 35 #include "core/page/Page.h" |
41 #include "core/platform/Logging.h" | 36 #include "core/platform/Logging.h" |
42 #include "core/platform/network/ResourceError.h" | 37 #include "core/platform/network/ResourceError.h" |
43 #include "core/platform/network/ResourceHandle.h" | 38 #include "core/platform/network/ResourceHandle.h" |
44 | 39 |
45 namespace WebCore { | 40 namespace WebCore { |
46 | 41 |
47 ResourceLoader::RequestCountTracker::RequestCountTracker(CachedResourceLoader* c
achedResourceLoader, CachedResource* resource) | 42 ResourceLoader::RequestCountTracker::RequestCountTracker(ResourceLoaderHost* hos
t, CachedResource* resource) |
48 : m_cachedResourceLoader(cachedResourceLoader) | 43 : m_host(host) |
49 , m_resource(resource) | 44 , m_resource(resource) |
50 { | 45 { |
51 m_cachedResourceLoader->incrementRequestCount(m_resource); | 46 m_host->incrementRequestCount(m_resource); |
52 } | 47 } |
53 | 48 |
54 ResourceLoader::RequestCountTracker::~RequestCountTracker() | 49 ResourceLoader::RequestCountTracker::~RequestCountTracker() |
55 { | 50 { |
56 m_cachedResourceLoader->decrementRequestCount(m_resource); | 51 m_host->decrementRequestCount(m_resource); |
57 } | 52 } |
58 | 53 |
59 PassRefPtr<ResourceLoader> ResourceLoader::create(DocumentLoader* documentLoader
, CachedResource* resource, const ResourceRequest& request, const ResourceLoader
Options& options) | 54 PassRefPtr<ResourceLoader> ResourceLoader::create(ResourceLoaderHost* host, Cach
edResource* resource, const ResourceRequest& request, const ResourceLoaderOption
s& options) |
60 { | 55 { |
61 RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(documentLoader, re
source, options))); | 56 RefPtr<ResourceLoader> loader(adoptRef(new ResourceLoader(host, resource, op
tions))); |
62 if (!loader->init(request)) | 57 if (!loader->init(request)) |
63 return 0; | 58 return 0; |
64 loader->start(); | 59 loader->start(); |
65 return loader.release(); | 60 return loader.release(); |
66 } | 61 } |
67 | 62 |
68 ResourceLoader::ResourceLoader(DocumentLoader* documentLoader, CachedResource* r
esource, ResourceLoaderOptions options) | 63 ResourceLoader::ResourceLoader(ResourceLoaderHost* host, CachedResource* resourc
e, const ResourceLoaderOptions& options) |
69 : m_frame(documentLoader->frame()) | 64 : m_host(host) |
70 , m_documentLoader(documentLoader) | |
71 , m_loadingMultipartContent(false) | 65 , m_loadingMultipartContent(false) |
72 , m_notifiedLoadComplete(false) | 66 , m_notifiedLoadComplete(false) |
73 , m_defersLoading(m_frame->page()->defersLoading()) | 67 , m_defersLoading(host->defersLoading()) |
74 , m_options(options) | 68 , m_options(options) |
75 , m_resource(resource) | 69 , m_resource(resource) |
76 , m_state(Uninitialized) | 70 , m_state(Uninitialized) |
77 , m_requestCountTracker(adoptPtr(new RequestCountTracker(documentLoader->cac
hedResourceLoader(), resource))) | 71 , m_requestCountTracker(adoptPtr(new RequestCountTracker(host, resource))) |
78 { | 72 { |
79 } | 73 } |
80 | 74 |
81 ResourceLoader::~ResourceLoader() | 75 ResourceLoader::~ResourceLoader() |
82 { | 76 { |
83 ASSERT(m_state == Terminated); | 77 ASSERT(m_state == Terminated); |
84 } | 78 } |
85 | 79 |
86 void ResourceLoader::releaseResources() | 80 void ResourceLoader::releaseResources() |
87 { | 81 { |
88 ASSERT(m_state != Terminated); | 82 ASSERT(m_state != Terminated); |
89 if (m_state != Uninitialized) { | 83 if (m_state != Uninitialized) { |
90 m_requestCountTracker.clear(); | 84 m_requestCountTracker.clear(); |
91 m_documentLoader->cachedResourceLoader()->loadDone(m_resource); | 85 m_host->didLoadResource(m_resource); |
92 if (m_state == Terminated) | 86 if (m_state == Terminated) |
93 return; | 87 return; |
94 m_resource->clearLoader(); | 88 m_resource->clearLoader(); |
95 m_documentLoader->removeResourceLoader(this); | 89 m_host->willTerminateResourceLoader(this); |
96 } | 90 } |
97 | 91 |
98 ASSERT(m_state != Terminated); | 92 ASSERT(m_state != Terminated); |
99 | 93 |
100 // It's possible that when we release the handle, it will be | 94 // It's possible that when we release the handle, it will be |
101 // deallocated and release the last reference to this object. | 95 // deallocated and release the last reference to this object. |
102 // We need to retain to avoid accessing the object after it | 96 // We need to retain to avoid accessing the object after it |
103 // has been deallocated and also to avoid reentering this method. | 97 // has been deallocated and also to avoid reentering this method. |
104 RefPtr<ResourceLoader> protector(this); | 98 RefPtr<ResourceLoader> protector(this); |
105 | 99 |
106 m_frame = 0; | 100 m_host.clear(); |
107 m_documentLoader = 0; | |
108 | |
109 m_state = Terminated; | 101 m_state = Terminated; |
110 | 102 |
111 if (m_handle) { | 103 if (m_handle) { |
112 // Clear out the ResourceHandle's client so that it doesn't try to call | 104 // Clear out the ResourceHandle's client so that it doesn't try to call |
113 // us back after we release it, unless it has been replaced by someone e
lse. | 105 // us back after we release it, unless it has been replaced by someone e
lse. |
114 if (m_handle->client() == this) | 106 if (m_handle->client() == this) |
115 m_handle->setClient(0); | 107 m_handle->setClient(0); |
116 m_handle = 0; | 108 m_handle = 0; |
117 } | 109 } |
118 | 110 |
(...skipping 10 matching lines...) Expand all Loading... |
129 | 121 |
130 willSendRequest(0, clientRequest, ResourceResponse()); | 122 willSendRequest(0, clientRequest, ResourceResponse()); |
131 if (clientRequest.isNull()) { | 123 if (clientRequest.isNull()) { |
132 cancel(); | 124 cancel(); |
133 return false; | 125 return false; |
134 } | 126 } |
135 ASSERT(m_state != Terminated); | 127 ASSERT(m_state != Terminated); |
136 | 128 |
137 m_originalRequest = m_request = clientRequest; | 129 m_originalRequest = m_request = clientRequest; |
138 m_state = Initialized; | 130 m_state = Initialized; |
139 m_documentLoader->addResourceLoader(this); | 131 m_host->didInitializeResourceLoader(this); |
140 return true; | 132 return true; |
141 } | 133 } |
142 | 134 |
143 void ResourceLoader::start() | 135 void ResourceLoader::start() |
144 { | 136 { |
145 ASSERT(!m_handle); | 137 ASSERT(!m_handle); |
146 ASSERT(!m_request.isNull()); | 138 ASSERT(!m_request.isNull()); |
147 ASSERT(m_deferredRequest.isNull()); | 139 ASSERT(m_deferredRequest.isNull()); |
148 | 140 |
149 m_documentLoader->applicationCacheHost()->willStartLoadingResource(m_request
); | 141 m_host->willStartLoadingResource(m_request); |
150 | 142 |
151 if (m_defersLoading) { | 143 if (m_defersLoading) { |
152 m_deferredRequest = m_request; | 144 m_deferredRequest = m_request; |
153 return; | 145 return; |
154 } | 146 } |
155 | 147 |
156 if (m_state != Terminated) | 148 if (m_state != Terminated) |
157 m_handle = ResourceHandle::create(m_request, this, m_defersLoading, m_op
tions.sniffContent == SniffContent, m_options.allowCredentials); | 149 m_handle = ResourceHandle::create(m_request, this, m_defersLoading, m_op
tions.sniffContent == SniffContent, m_options.allowCredentials); |
158 } | 150 } |
159 | 151 |
160 void ResourceLoader::setDefersLoading(bool defers) | 152 void ResourceLoader::setDefersLoading(bool defers) |
161 { | 153 { |
162 m_defersLoading = defers; | 154 m_defersLoading = defers; |
163 if (m_handle) | 155 if (m_handle) |
164 m_handle->setDefersLoading(defers); | 156 m_handle->setDefersLoading(defers); |
165 if (!defers && !m_deferredRequest.isNull()) { | 157 if (!defers && !m_deferredRequest.isNull()) { |
166 m_request = m_deferredRequest; | 158 m_request = m_deferredRequest; |
167 m_deferredRequest = ResourceRequest(); | 159 m_deferredRequest = ResourceRequest(); |
168 start(); | 160 start(); |
169 } | 161 } |
170 } | 162 } |
171 | 163 |
172 FrameLoader* ResourceLoader::frameLoader() const | |
173 { | |
174 if (!m_frame) | |
175 return 0; | |
176 return m_frame->loader(); | |
177 } | |
178 | |
179 void ResourceLoader::didDownloadData(ResourceHandle*, int length) | 164 void ResourceLoader::didDownloadData(ResourceHandle*, int length) |
180 { | 165 { |
181 RefPtr<ResourceLoader> protect(this); | 166 RefPtr<ResourceLoader> protect(this); |
182 m_resource->didDownloadData(length); | 167 m_resource->didDownloadData(length); |
183 } | 168 } |
184 | 169 |
185 void ResourceLoader::didFinishLoadingOnePart(double finishTime) | 170 void ResourceLoader::didFinishLoadingOnePart(double finishTime) |
186 { | 171 { |
187 // If load has been cancelled after finishing (which could happen with a | 172 // If load has been cancelled after finishing (which could happen with a |
188 // JavaScript that changes the window location), do nothing. | 173 // JavaScript that changes the window location), do nothing. |
189 if (m_state == Terminated) | 174 if (m_state == Terminated) |
190 return; | 175 return; |
191 | 176 |
192 if (m_notifiedLoadComplete) | 177 if (m_notifiedLoadComplete) |
193 return; | 178 return; |
194 m_notifiedLoadComplete = true; | 179 m_notifiedLoadComplete = true; |
195 if (m_options.sendLoadCallbacks == SendCallbacks) | 180 m_host->didFinishLoading(m_resource, finishTime, m_options); |
196 frameLoader()->notifier()->dispatchDidFinishLoading(m_documentLoader.get
(), m_resource->identifier(), finishTime); | |
197 } | 181 } |
198 | 182 |
199 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority) | 183 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority) |
200 { | 184 { |
201 if (handle()) { | 185 if (handle()) { |
202 frameLoader()->client()->dispatchDidChangeResourcePriority(m_resource->i
dentifier(), loadPriority); | 186 m_host->didChangeLoadingPriority(m_resource, loadPriority); |
203 handle()->didChangePriority(loadPriority); | 187 handle()->didChangePriority(loadPriority); |
204 } | 188 } |
205 } | 189 } |
206 | 190 |
207 void ResourceLoader::cancelIfNotFinishing() | 191 void ResourceLoader::cancelIfNotFinishing() |
208 { | 192 { |
209 if (m_state != Initialized) | 193 if (m_state != Initialized) |
210 return; | 194 return; |
211 cancel(); | 195 cancel(); |
212 } | 196 } |
(...skipping 22 matching lines...) Expand all Loading... |
235 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string()
.latin1().data()); | 219 LOG(ResourceLoading, "Cancelled load of '%s'.\n", m_resource->url().string()
.latin1().data()); |
236 if (m_state == Initialized) | 220 if (m_state == Initialized) |
237 m_state = Finishing; | 221 m_state = Finishing; |
238 m_resource->setResourceError(nonNullError); | 222 m_resource->setResourceError(nonNullError); |
239 | 223 |
240 if (m_handle) { | 224 if (m_handle) { |
241 m_handle->cancel(); | 225 m_handle->cancel(); |
242 m_handle = 0; | 226 m_handle = 0; |
243 } | 227 } |
244 | 228 |
245 if (m_options.sendLoadCallbacks == SendCallbacks && !m_notifiedLoadComplete) | 229 m_host->didFailLoading(m_resource, nonNullError, m_options); |
246 frameLoader()->notifier()->dispatchDidFail(m_documentLoader.get(), m_res
ource->identifier(), nonNullError); | |
247 | 230 |
248 if (m_state == Finishing) | 231 if (m_state == Finishing) |
249 m_resource->error(CachedResource::LoadError); | 232 m_resource->error(CachedResource::LoadError); |
250 if (m_state != Terminated) | 233 if (m_state != Terminated) |
251 releaseResources(); | 234 releaseResources(); |
252 } | 235 } |
253 | 236 |
254 ResourceError ResourceLoader::cancelledError() | 237 ResourceError ResourceLoader::cancelledError() |
255 { | 238 { |
256 return frameLoader()->cancelledError(m_request); | 239 return m_host->cancelledLoadingError(m_request); |
257 } | 240 } |
258 | 241 |
259 ResourceError ResourceLoader::cannotShowURLError() | 242 ResourceError ResourceLoader::cannotShowURLError() |
260 { | 243 { |
261 return frameLoader()->client()->cannotShowURLError(m_request); | 244 return m_host->cannotShowURLLoadingError(m_request); |
262 } | 245 } |
263 | 246 |
264 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request,
const ResourceResponse& redirectResponse) | 247 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request,
const ResourceResponse& redirectResponse) |
265 { | 248 { |
266 // Store the previous URL because we may modify it. | 249 // Store the previous URL because we may modify it. |
267 KURL previousURL = m_request.url(); | 250 KURL previousURL = m_request.url(); |
268 RefPtr<ResourceLoader> protect(this); | 251 RefPtr<ResourceLoader> protect(this); |
269 | 252 |
270 ASSERT(!request.isNull()); | 253 ASSERT(!request.isNull()); |
271 if (!redirectResponse.isNull()) { | 254 if (!redirectResponse.isNull()) { |
272 if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->ty
pe(), request.url(), m_options)) { | 255 if (!m_host->shouldRequest(m_resource, request, m_options)) { |
273 cancel(); | 256 cancel(); |
274 return; | 257 return; |
275 } | 258 } |
276 if (m_resource->type() == CachedResource::ImageResource && m_documentLoa
der->cachedResourceLoader()->shouldDeferImageLoad(request.url())) { | 259 |
277 cancel(); | |
278 return; | |
279 } | |
280 m_resource->willSendRequest(request, redirectResponse); | 260 m_resource->willSendRequest(request, redirectResponse); |
281 } | 261 } |
282 | 262 |
283 if (request.isNull() || m_state == Terminated) | 263 if (request.isNull() || m_state == Terminated) |
284 return; | 264 return; |
285 | 265 |
286 if (m_options.sendLoadCallbacks == SendCallbacks) | 266 m_host->willSendRequest(m_resource, request, redirectResponse, m_options); |
287 frameLoader()->notifier()->dispatchWillSendRequest(m_documentLoader.get(
), m_resource->identifier(), request, redirectResponse, m_options.initiatorInfo)
; | |
288 else | |
289 InspectorInstrumentation::willSendRequest(m_frame.get(), m_resource->ide
ntifier(), m_documentLoader.get(), request, redirectResponse, m_options.initiato
rInfo); | |
290 | |
291 m_request = request; | 267 m_request = request; |
292 | 268 |
293 if (request.isNull()) | 269 if (request.isNull()) |
294 cancel(); | 270 cancel(); |
295 } | 271 } |
296 | 272 |
297 void ResourceLoader::didReceiveCachedMetadata(ResourceHandle*, const char* data,
int length) | 273 void ResourceLoader::didReceiveCachedMetadata(ResourceHandle*, const char* data,
int length) |
298 { | 274 { |
299 ASSERT(m_state == Initialized); | 275 ASSERT(m_state == Initialized); |
300 m_resource->setSerializedCachedMetadata(data, length); | 276 m_resource->setSerializedCachedMetadata(data, length); |
(...skipping 11 matching lines...) Expand all Loading... |
312 ASSERT(!response.isNull()); | 288 ASSERT(!response.isNull()); |
313 ASSERT(m_state == Initialized); | 289 ASSERT(m_state == Initialized); |
314 | 290 |
315 // Reference the object in this method since the additional processing can d
o | 291 // Reference the object in this method since the additional processing can d
o |
316 // anything including removing the last reference to this object. | 292 // anything including removing the last reference to this object. |
317 RefPtr<ResourceLoader> protect(this); | 293 RefPtr<ResourceLoader> protect(this); |
318 m_resource->responseReceived(response); | 294 m_resource->responseReceived(response); |
319 if (m_state == Terminated) | 295 if (m_state == Terminated) |
320 return; | 296 return; |
321 | 297 |
322 if (m_options.sendLoadCallbacks == SendCallbacks) | 298 m_host->didReceiveResponse(m_resource, response, m_options); |
323 frameLoader()->notifier()->dispatchDidReceiveResponse(m_documentLoader.g
et(), m_resource->identifier(), response); | |
324 | 299 |
325 if (response.isMultipart()) { | 300 if (response.isMultipart()) { |
326 m_loadingMultipartContent = true; | 301 m_loadingMultipartContent = true; |
327 | 302 |
328 // We don't count multiParts in a CachedResourceLoader's request count | 303 // We don't count multiParts in a CachedResourceLoader's request count |
329 m_requestCountTracker.clear(); | 304 m_requestCountTracker.clear(); |
330 if (!m_resource->isImage()) { | 305 if (!m_resource->isImage()) { |
331 cancel(); | 306 cancel(); |
332 return; | 307 return; |
333 } | 308 } |
334 } else if (m_loadingMultipartContent) { | 309 } else if (m_loadingMultipartContent) { |
335 // Since a subresource loader does not load multipart sections progressi
vely, data was delivered to the loader all at once. | 310 // Since a subresource loader does not load multipart sections progressi
vely, data was delivered to the loader all at once. |
336 // After the first multipart section is complete, signal to delegates th
at this load is "finished" | 311 // After the first multipart section is complete, signal to delegates th
at this load is "finished" |
337 m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this); | 312 m_host->subresourceLoaderFinishedLoadingOnePart(this); |
338 didFinishLoadingOnePart(0); | 313 didFinishLoadingOnePart(0); |
339 } | 314 } |
340 | 315 |
341 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) | 316 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) |
342 return; | 317 return; |
343 m_state = Finishing; | 318 m_state = Finishing; |
344 m_resource->error(CachedResource::LoadError); | 319 m_resource->error(CachedResource::LoadError); |
345 cancel(); | 320 cancel(); |
346 } | 321 } |
347 | 322 |
348 void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int lengt
h, int encodedDataLength) | 323 void ResourceLoader::didReceiveData(ResourceHandle*, const char* data, int lengt
h, int encodedDataLength) |
349 { | 324 { |
350 // It is possible to receive data on uninitialized resources if it had an er
ror status code, and we are running a nested message | 325 // It is possible to receive data on uninitialized resources if it had an er
ror status code, and we are running a nested message |
351 // loop. When this occurs, ignoring the data is the correct action. | 326 // loop. When this occurs, ignoring the data is the correct action. |
352 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn
oreHTTPStatusCodeErrors()) | 327 if (m_resource->response().httpStatusCode() >= 400 && !m_resource->shouldIgn
oreHTTPStatusCodeErrors()) |
353 return; | 328 return; |
354 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv
eResourceData(m_frame.get(), m_resource->identifier(), encodedDataLength); | 329 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willReceiv
eResourceData(m_host->inspectedFrame(), m_resource->identifier(), encodedDataLen
gth); |
355 ASSERT(m_state == Initialized); | 330 ASSERT(m_state == Initialized); |
356 | 331 |
357 // Reference the object in this method since the additional processing can d
o | 332 // Reference the object in this method since the additional processing can d
o |
358 // anything including removing the last reference to this object. | 333 // anything including removing the last reference to this object. |
359 RefPtr<ResourceLoader> protect(this); | 334 RefPtr<ResourceLoader> protect(this); |
360 | 335 |
361 // FIXME: If we get a resource with more than 2B bytes, this code won't do t
he right thing. | 336 // FIXME: If we get a resource with more than 2B bytes, this code won't do t
he right thing. |
362 // However, with today's computers and networking speeds, this won't happen
in practice. | 337 // However, with today's computers and networking speeds, this won't happen
in practice. |
363 // Could be an issue with a giant local file. | 338 // Could be an issue with a giant local file. |
364 if (m_options.sendLoadCallbacks == SendCallbacks && m_frame) | 339 m_host->didReceiveData(m_resource, data, length, static_cast<int>(encodedDat
aLength), m_options); |
365 frameLoader()->notifier()->dispatchDidReceiveData(m_documentLoader.get()
, m_resource->identifier(), data, length, static_cast<int>(encodedDataLength)); | |
366 | |
367 m_resource->appendData(data, length); | 340 m_resource->appendData(data, length); |
368 | 341 |
369 InspectorInstrumentation::didReceiveResourceData(cookie); | 342 InspectorInstrumentation::didReceiveResourceData(cookie); |
370 } | 343 } |
371 | 344 |
372 void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime) | 345 void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime) |
373 { | 346 { |
374 if (m_state != Initialized) | 347 if (m_state != Initialized) |
375 return; | 348 return; |
376 ASSERT(m_state != Terminated); | 349 ASSERT(m_state != Terminated); |
(...skipping 11 matching lines...) Expand all Loading... |
388 return; | 361 return; |
389 releaseResources(); | 362 releaseResources(); |
390 } | 363 } |
391 | 364 |
392 void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error) | 365 void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error) |
393 { | 366 { |
394 ASSERT(m_state != Terminated); | 367 ASSERT(m_state != Terminated); |
395 LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().la
tin1().data()); | 368 LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().la
tin1().data()); |
396 | 369 |
397 RefPtr<ResourceLoader> protect(this); | 370 RefPtr<ResourceLoader> protect(this); |
| 371 RefPtr<ResourceLoaderHost> protectHost(m_host); |
398 CachedResourceHandle<CachedResource> protectResource(m_resource); | 372 CachedResourceHandle<CachedResource> protectResource(m_resource); |
399 m_state = Finishing; | 373 m_state = Finishing; |
400 m_resource->setResourceError(error); | 374 m_resource->setResourceError(error); |
401 m_resource->error(CachedResource::LoadError); | 375 m_resource->error(CachedResource::LoadError); |
402 | 376 |
403 if (m_state == Terminated) | 377 if (m_state == Terminated) |
404 return; | 378 return; |
405 | 379 |
406 if (!m_notifiedLoadComplete) { | 380 if (!m_notifiedLoadComplete) { |
407 m_notifiedLoadComplete = true; | 381 m_notifiedLoadComplete = true; |
408 if (m_options.sendLoadCallbacks == SendCallbacks) | 382 m_host->didFailLoading(m_resource, error, m_options); |
409 frameLoader()->notifier()->dispatchDidFail(m_documentLoader.get(), m
_resource->identifier(), error); | |
410 } | 383 } |
411 | 384 |
412 releaseResources(); | 385 releaseResources(); |
413 } | 386 } |
414 | 387 |
415 void ResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const | 388 void ResourceLoader::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const |
416 { | 389 { |
417 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); | 390 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::Loader); |
418 info.addMember(m_handle, "handle"); | 391 info.addMember(m_handle, "handle"); |
419 info.addMember(m_frame, "frame"); | 392 info.addMember(m_host, "host"); |
420 info.addMember(m_documentLoader, "documentLoader"); | |
421 info.addMember(m_request, "request"); | 393 info.addMember(m_request, "request"); |
422 info.addMember(m_originalRequest, "originalRequest"); | 394 info.addMember(m_originalRequest, "originalRequest"); |
423 info.addMember(m_deferredRequest, "deferredRequest"); | 395 info.addMember(m_deferredRequest, "deferredRequest"); |
424 info.addMember(m_options, "options"); | 396 info.addMember(m_options, "options"); |
425 info.addMember(m_resource, "resource"); | 397 info.addMember(m_resource, "resource"); |
426 info.addMember(m_documentLoader, "documentLoader"); | |
427 info.addMember(m_requestCountTracker, "requestCountTracker"); | 398 info.addMember(m_requestCountTracker, "requestCountTracker"); |
428 } | 399 } |
429 | 400 |
| 401 bool ResourceLoader::isLoadedBy(CachedResourceLoader* loader) const |
| 402 { |
| 403 m_host->isLoadedBy(loader); |
430 } | 404 } |
| 405 |
| 406 } |
OLD | NEW |