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