| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64 encodedDat
aLength) | 222 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64 encodedDat
aLength) |
| 223 { | 223 { |
| 224 // If load has been cancelled after finishing (which could happen with a | 224 // If load has been cancelled after finishing (which could happen with a |
| 225 // JavaScript that changes the window location), do nothing. | 225 // JavaScript that changes the window location), do nothing. |
| 226 if (m_state == Terminated) | 226 if (m_state == Terminated) |
| 227 return; | 227 return; |
| 228 | 228 |
| 229 if (m_notifiedLoadComplete) | 229 if (m_notifiedLoadComplete) |
| 230 return; | 230 return; |
| 231 m_notifiedLoadComplete = true; | 231 m_notifiedLoadComplete = true; |
| 232 m_requestCountTracker.clear(); |
| 232 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength); | 233 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength); |
| 233 } | 234 } |
| 234 | 235 |
| 235 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, int in
traPriorityValue) | 236 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, int in
traPriorityValue) |
| 236 { | 237 { |
| 237 if (m_loader) { | 238 if (m_loader) { |
| 238 m_host->didChangeLoadingPriority(m_resource, loadPriority, intraPriority
Value); | 239 m_host->didChangeLoadingPriority(m_resource, loadPriority, intraPriority
Value); |
| 239 ASSERT(m_state != Terminated); | 240 ASSERT(m_state != Terminated); |
| 240 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>(
loadPriority), intraPriorityValue); | 241 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>(
loadPriority), intraPriorityValue); |
| 241 } | 242 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 m_resource->setResourceError(nonNullError); | 276 m_resource->setResourceError(nonNullError); |
| 276 | 277 |
| 277 if (m_loader) { | 278 if (m_loader) { |
| 278 m_connectionState = ConnectionStateCanceled; | 279 m_connectionState = ConnectionStateCanceled; |
| 279 m_loader->cancel(); | 280 m_loader->cancel(); |
| 280 m_loader.clear(); | 281 m_loader.clear(); |
| 281 } | 282 } |
| 282 | 283 |
| 283 if (!m_notifiedLoadComplete) { | 284 if (!m_notifiedLoadComplete) { |
| 284 m_notifiedLoadComplete = true; | 285 m_notifiedLoadComplete = true; |
| 286 m_requestCountTracker.clear(); |
| 285 m_host->didFailLoading(m_resource, nonNullError); | 287 m_host->didFailLoading(m_resource, nonNullError); |
| 286 } | 288 } |
| 287 | 289 |
| 288 if (m_state == Finishing) | 290 if (m_state == Finishing) |
| 289 m_resource->error(Resource::LoadError); | 291 m_resource->error(Resource::LoadError); |
| 290 if (m_state != Terminated) | 292 if (m_state != Terminated) |
| 291 releaseResources(); | 293 releaseResources(); |
| 292 } | 294 } |
| 293 | 295 |
| 294 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest&
passedRequest, const blink::WebURLResponse& passedRedirectResponse) | 296 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest&
passedRequest, const blink::WebURLResponse& passedRedirectResponse) |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 402 } |
| 401 if (m_state == Terminated) | 403 if (m_state == Terminated) |
| 402 return; | 404 return; |
| 403 | 405 |
| 404 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) | 406 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) |
| 405 return; | 407 return; |
| 406 m_state = Finishing; | 408 m_state = Finishing; |
| 407 | 409 |
| 408 if (!m_notifiedLoadComplete) { | 410 if (!m_notifiedLoadComplete) { |
| 409 m_notifiedLoadComplete = true; | 411 m_notifiedLoadComplete = true; |
| 412 m_requestCountTracker.clear(); |
| 410 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque
st.url())); | 413 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque
st.url())); |
| 411 } | 414 } |
| 412 | 415 |
| 413 ASSERT(m_state != Terminated); | 416 ASSERT(m_state != Terminated); |
| 414 m_resource->error(Resource::LoadError); | 417 m_resource->error(Resource::LoadError); |
| 415 cancel(); | 418 cancel(); |
| 416 } | 419 } |
| 417 | 420 |
| 418 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int
length, int encodedDataLength) | 421 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int
length, int encodedDataLength) |
| 419 { | 422 { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 445 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con
nectionState == ConnectionStateReceivingData); | 448 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con
nectionState == ConnectionStateReceivingData); |
| 446 m_connectionState = ConnectionStateFinishedLoading; | 449 m_connectionState = ConnectionStateFinishedLoading; |
| 447 if (m_state != Initialized) | 450 if (m_state != Initialized) |
| 448 return; | 451 return; |
| 449 ASSERT(m_state != Terminated); | 452 ASSERT(m_state != Terminated); |
| 450 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1
().data()); | 453 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1
().data()); |
| 451 | 454 |
| 452 RefPtrWillBeRawPtr<ResourceLoader> protect(this); | 455 RefPtrWillBeRawPtr<ResourceLoader> protect(this); |
| 453 ResourcePtr<Resource> protectResource(m_resource); | 456 ResourcePtr<Resource> protectResource(m_resource); |
| 454 m_state = Finishing; | 457 m_state = Finishing; |
| 458 m_resource->setLoadFinishTime(finishTime); |
| 455 didFinishLoadingOnePart(finishTime, encodedDataLength); | 459 didFinishLoadingOnePart(finishTime, encodedDataLength); |
| 456 if (m_state == Terminated) | 460 if (m_state == Terminated) |
| 457 return; | 461 return; |
| 458 m_resource->finish(finishTime); | 462 m_resource->finish(); |
| 459 | 463 |
| 460 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release | 464 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release |
| 461 // the resources a second time, they have been released by cancel. | 465 // the resources a second time, they have been released by cancel. |
| 462 if (m_state == Terminated) | 466 if (m_state == Terminated) |
| 463 return; | 467 return; |
| 464 releaseResources(); | 468 releaseResources(); |
| 465 } | 469 } |
| 466 | 470 |
| 467 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err
or) | 471 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err
or) |
| 468 { | 472 { |
| 469 m_connectionState = ConnectionStateFailed; | 473 m_connectionState = ConnectionStateFailed; |
| 470 ASSERT(m_state != Terminated); | 474 ASSERT(m_state != Terminated); |
| 471 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string(
).latin1().data()); | 475 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string(
).latin1().data()); |
| 472 | 476 |
| 473 RefPtrWillBeRawPtr<ResourceLoader> protect(this); | 477 RefPtrWillBeRawPtr<ResourceLoader> protect(this); |
| 474 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get()); | 478 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get()); |
| 475 ResourcePtr<Resource> protectResource(m_resource); | 479 ResourcePtr<Resource> protectResource(m_resource); |
| 476 m_state = Finishing; | 480 m_state = Finishing; |
| 477 m_resource->setResourceError(error); | 481 m_resource->setResourceError(error); |
| 478 | 482 |
| 479 if (!m_notifiedLoadComplete) { | 483 if (!m_notifiedLoadComplete) { |
| 480 m_notifiedLoadComplete = true; | 484 m_notifiedLoadComplete = true; |
| 485 m_requestCountTracker.clear(); |
| 481 m_host->didFailLoading(m_resource, error); | 486 m_host->didFailLoading(m_resource, error); |
| 482 } | 487 } |
| 483 if (m_state == Terminated) | 488 if (m_state == Terminated) |
| 484 return; | 489 return; |
| 485 | 490 |
| 486 m_resource->error(Resource::LoadError); | 491 m_resource->error(Resource::LoadError); |
| 487 | 492 |
| 488 if (m_state == Terminated) | 493 if (m_state == Terminated) |
| 489 return; | 494 return; |
| 490 | 495 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); | 536 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
| 532 } | 537 } |
| 533 | 538 |
| 534 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const | 539 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const |
| 535 { | 540 { |
| 536 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC
redentials); | 541 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC
redentials); |
| 537 return request; | 542 return request; |
| 538 } | 543 } |
| 539 | 544 |
| 540 } | 545 } |
| OLD | NEW |