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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 162 |
163 void ResourceLoader::start() | 163 void ResourceLoader::start() |
164 { | 164 { |
165 ASSERT(!m_handle); | 165 ASSERT(!m_handle); |
166 ASSERT(!m_request.isNull()); | 166 ASSERT(!m_request.isNull()); |
167 ASSERT(m_deferredRequest.isNull()); | 167 ASSERT(m_deferredRequest.isNull()); |
168 | 168 |
169 if (m_documentLoader->scheduleArchiveLoad(this, m_request)) | 169 if (m_documentLoader->scheduleArchiveLoad(this, m_request)) |
170 return; | 170 return; |
171 | 171 |
172 if (m_documentLoader->applicationCacheHost()->maybeLoadResource(this, m_requ
est, m_request.url())) | 172 m_documentLoader->applicationCacheHost()->willStartLoadingResource(m_request
); |
173 return; | |
174 | 173 |
175 if (m_defersLoading) { | 174 if (m_defersLoading) { |
176 m_deferredRequest = m_request; | 175 m_deferredRequest = m_request; |
177 return; | 176 return; |
178 } | 177 } |
179 | 178 |
180 if (!m_reachedTerminalState) | 179 if (!m_reachedTerminalState) |
181 m_handle = ResourceHandle::create(m_frame->loader()->networkingContext()
, m_request, this, m_defersLoading, m_options.sniffContent == SniffContent, m_op
tions.allowCredentials); | 180 m_handle = ResourceHandle::create(m_frame->loader()->networkingContext()
, m_request, this, m_defersLoading, m_options.sniffContent == SniffContent, m_op
tions.allowCredentials); |
182 } | 181 } |
183 | 182 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 return frameLoader()->cancelledError(m_request); | 297 return frameLoader()->cancelledError(m_request); |
299 } | 298 } |
300 | 299 |
301 ResourceError ResourceLoader::cannotShowURLError() | 300 ResourceError ResourceLoader::cannotShowURLError() |
302 { | 301 { |
303 return frameLoader()->client()->cannotShowURLError(m_request); | 302 return frameLoader()->client()->cannotShowURLError(m_request); |
304 } | 303 } |
305 | 304 |
306 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request,
const ResourceResponse& redirectResponse) | 305 void ResourceLoader::willSendRequest(ResourceHandle*, ResourceRequest& request,
const ResourceResponse& redirectResponse) |
307 { | 306 { |
308 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForRedirect(t
his, request, redirectResponse)) | |
309 return; | |
310 | |
311 // Store the previous URL because we may modify it. | 307 // Store the previous URL because we may modify it. |
312 KURL previousURL = m_request.url(); | 308 KURL previousURL = m_request.url(); |
313 RefPtr<ResourceLoader> protect(this); | 309 RefPtr<ResourceLoader> protect(this); |
314 | 310 |
315 ASSERT(!request.isNull()); | 311 ASSERT(!request.isNull()); |
316 if (!redirectResponse.isNull()) { | 312 if (!redirectResponse.isNull()) { |
317 if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->ty
pe(), request.url())) { | 313 if (!m_documentLoader->cachedResourceLoader()->canRequest(m_resource->ty
pe(), request.url())) { |
318 cancel(); | 314 cancel(); |
319 return; | 315 return; |
320 } | 316 } |
(...skipping 30 matching lines...) Expand all Loading... |
351 | 347 |
352 void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent,
unsigned long long totalBytesToBeSent) | 348 void ResourceLoader::didSendData(ResourceHandle*, unsigned long long bytesSent,
unsigned long long totalBytesToBeSent) |
353 { | 349 { |
354 ASSERT(m_state == Initialized); | 350 ASSERT(m_state == Initialized); |
355 RefPtr<ResourceLoader> protect(this); | 351 RefPtr<ResourceLoader> protect(this); |
356 m_resource->didSendData(bytesSent, totalBytesToBeSent); | 352 m_resource->didSendData(bytesSent, totalBytesToBeSent); |
357 } | 353 } |
358 | 354 |
359 void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
response) | 355 void ResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceResponse&
response) |
360 { | 356 { |
361 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForResponse(t
his, response)) | |
362 return; | |
363 ASSERT(!response.isNull()); | 357 ASSERT(!response.isNull()); |
364 ASSERT(m_state == Initialized); | 358 ASSERT(m_state == Initialized); |
365 | 359 |
366 // Reference the object in this method since the additional processing can d
o | 360 // Reference the object in this method since the additional processing can d
o |
367 // anything including removing the last reference to this object. | 361 // anything including removing the last reference to this object. |
368 RefPtr<ResourceLoader> protect(this); | 362 RefPtr<ResourceLoader> protect(this); |
369 | 363 |
370 if (m_resource->resourceToRevalidate()) { | 364 if (m_resource->resourceToRevalidate()) { |
371 if (response.httpStatusCode() == 304) { | 365 if (response.httpStatusCode() == 304) { |
372 // 304 Not modified / Use local copy | 366 // 304 Not modified / Use local copy |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 457 |
464 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release | 458 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release |
465 // the resources a second time, they have been released by cancel. | 459 // the resources a second time, they have been released by cancel. |
466 if (m_cancelled) | 460 if (m_cancelled) |
467 return; | 461 return; |
468 releaseResources(); | 462 releaseResources(); |
469 } | 463 } |
470 | 464 |
471 void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error) | 465 void ResourceLoader::didFail(ResourceHandle*, const ResourceError& error) |
472 { | 466 { |
473 if (documentLoader()->applicationCacheHost()->maybeLoadFallbackForError(this
, error) || m_state != Initialized) | |
474 return; | |
475 ASSERT(!reachedTerminalState()); | 467 ASSERT(!reachedTerminalState()); |
476 LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().la
tin1().data()); | 468 LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string().la
tin1().data()); |
477 | 469 |
478 RefPtr<ResourceLoader> protect(this); | 470 RefPtr<ResourceLoader> protect(this); |
479 CachedResourceHandle<CachedResource> protectResource(m_resource); | 471 CachedResourceHandle<CachedResource> protectResource(m_resource); |
480 m_state = Finishing; | 472 m_state = Finishing; |
481 if (m_resource->resourceToRevalidate()) | 473 if (m_resource->resourceToRevalidate()) |
482 memoryCache()->revalidationFailed(m_resource); | 474 memoryCache()->revalidationFailed(m_resource); |
483 m_resource->setResourceError(error); | 475 m_resource->setResourceError(error); |
484 m_resource->error(CachedResource::LoadError); | 476 m_resource->error(CachedResource::LoadError); |
(...skipping 25 matching lines...) Expand all Loading... |
510 info.addMember(m_request, "request"); | 502 info.addMember(m_request, "request"); |
511 info.addMember(m_originalRequest, "originalRequest"); | 503 info.addMember(m_originalRequest, "originalRequest"); |
512 info.addMember(m_deferredRequest, "deferredRequest"); | 504 info.addMember(m_deferredRequest, "deferredRequest"); |
513 info.addMember(m_options, "options"); | 505 info.addMember(m_options, "options"); |
514 info.addMember(m_resource, "resource"); | 506 info.addMember(m_resource, "resource"); |
515 info.addMember(m_documentLoader, "documentLoader"); | 507 info.addMember(m_documentLoader, "documentLoader"); |
516 info.addMember(m_requestCountTracker, "requestCountTracker"); | 508 info.addMember(m_requestCountTracker, "requestCountTracker"); |
517 } | 509 } |
518 | 510 |
519 } | 511 } |
OLD | NEW |