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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64 encodedDat aLength) | 227 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64 encodedDat aLength) |
228 { | 228 { |
229 // If load has been cancelled after finishing (which could happen with a | 229 // If load has been cancelled after finishing (which could happen with a |
230 // JavaScript that changes the window location), do nothing. | 230 // JavaScript that changes the window location), do nothing. |
231 if (m_state == Terminated) | 231 if (m_state == Terminated) |
232 return; | 232 return; |
233 | 233 |
234 if (m_notifiedLoadComplete) | 234 if (m_notifiedLoadComplete) |
235 return; | 235 return; |
236 m_notifiedLoadComplete = true; | 236 m_notifiedLoadComplete = true; |
237 m_requestCountTracker.clear(); | |
dcheng
2014/10/20 19:28:04
Maybe shove these two lines into a helper?
Nate Chapin
2014/10/21 22:00:09
Done.
| |
237 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength); | 238 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength); |
238 } | 239 } |
239 | 240 |
240 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, int in traPriorityValue) | 241 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority, int in traPriorityValue) |
241 { | 242 { |
242 if (m_loader) { | 243 if (m_loader) { |
243 m_host->didChangeLoadingPriority(m_resource, loadPriority, intraPriority Value); | 244 m_host->didChangeLoadingPriority(m_resource, loadPriority, intraPriority Value); |
244 ASSERT(m_state != Terminated); | 245 ASSERT(m_state != Terminated); |
245 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>( loadPriority), intraPriorityValue); | 246 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>( loadPriority), intraPriorityValue); |
246 } | 247 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 m_resource->setResourceError(nonNullError); | 281 m_resource->setResourceError(nonNullError); |
281 | 282 |
282 if (m_loader) { | 283 if (m_loader) { |
283 m_connectionState = ConnectionStateCanceled; | 284 m_connectionState = ConnectionStateCanceled; |
284 m_loader->cancel(); | 285 m_loader->cancel(); |
285 m_loader.clear(); | 286 m_loader.clear(); |
286 } | 287 } |
287 | 288 |
288 if (!m_notifiedLoadComplete) { | 289 if (!m_notifiedLoadComplete) { |
289 m_notifiedLoadComplete = true; | 290 m_notifiedLoadComplete = true; |
291 m_requestCountTracker.clear(); | |
290 m_host->didFailLoading(m_resource, nonNullError); | 292 m_host->didFailLoading(m_resource, nonNullError); |
291 } | 293 } |
292 | 294 |
293 if (m_state == Finishing) | 295 if (m_state == Finishing) |
294 m_resource->error(Resource::LoadError); | 296 m_resource->error(Resource::LoadError); |
295 if (m_state != Terminated) | 297 if (m_state != Terminated) |
296 releaseResources(); | 298 releaseResources(); |
297 } | 299 } |
298 | 300 |
299 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedRequest, const blink::WebURLResponse& passedRedirectResponse) | 301 void ResourceLoader::willSendRequest(blink::WebURLLoader*, blink::WebURLRequest& passedRequest, const blink::WebURLResponse& passedRedirectResponse) |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 } | 418 } |
417 if (m_state == Terminated) | 419 if (m_state == Terminated) |
418 return; | 420 return; |
419 | 421 |
420 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) | 422 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) |
421 return; | 423 return; |
422 m_state = Finishing; | 424 m_state = Finishing; |
423 | 425 |
424 if (!m_notifiedLoadComplete) { | 426 if (!m_notifiedLoadComplete) { |
425 m_notifiedLoadComplete = true; | 427 m_notifiedLoadComplete = true; |
428 m_requestCountTracker.clear(); | |
426 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque st.url())); | 429 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque st.url())); |
427 } | 430 } |
428 | 431 |
429 ASSERT(m_state != Terminated); | 432 ASSERT(m_state != Terminated); |
430 m_resource->error(Resource::LoadError); | 433 m_resource->error(Resource::LoadError); |
431 cancel(); | 434 cancel(); |
432 } | 435 } |
433 | 436 |
434 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength) | 437 void ResourceLoader::didReceiveData(blink::WebURLLoader*, const char* data, int length, int encodedDataLength) |
435 { | 438 { |
(...skipping 26 matching lines...) Expand all Loading... | |
462 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); | 465 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con nectionState == ConnectionStateReceivingData); |
463 m_connectionState = ConnectionStateFinishedLoading; | 466 m_connectionState = ConnectionStateFinishedLoading; |
464 if (m_state != Initialized) | 467 if (m_state != Initialized) |
465 return; | 468 return; |
466 ASSERT(m_state != Terminated); | 469 ASSERT(m_state != Terminated); |
467 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1 ().data()); | 470 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1 ().data()); |
468 | 471 |
469 RefPtrWillBeRawPtr<ResourceLoader> protect(this); | 472 RefPtrWillBeRawPtr<ResourceLoader> protect(this); |
470 ResourcePtr<Resource> protectResource(m_resource); | 473 ResourcePtr<Resource> protectResource(m_resource); |
471 m_state = Finishing; | 474 m_state = Finishing; |
475 m_resource->setLoadFinishTime(finishTime); | |
dcheng
2014/10/20 18:35:14
What is the significance to splitting this out of
| |
472 didFinishLoadingOnePart(finishTime, encodedDataLength); | 476 didFinishLoadingOnePart(finishTime, encodedDataLength); |
473 if (m_state == Terminated) | 477 if (m_state == Terminated) |
474 return; | 478 return; |
475 m_resource->finish(finishTime); | 479 m_resource->finish(); |
476 | 480 |
477 // If the load has been cancelled by a delegate in response to didFinishLoad (), do not release | 481 // If the load has been cancelled by a delegate in response to didFinishLoad (), do not release |
478 // the resources a second time, they have been released by cancel. | 482 // the resources a second time, they have been released by cancel. |
479 if (m_state == Terminated) | 483 if (m_state == Terminated) |
480 return; | 484 return; |
481 releaseResources(); | 485 releaseResources(); |
482 } | 486 } |
483 | 487 |
484 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err or) | 488 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err or) |
485 { | 489 { |
486 m_connectionState = ConnectionStateFailed; | 490 m_connectionState = ConnectionStateFailed; |
487 ASSERT(m_state != Terminated); | 491 ASSERT(m_state != Terminated); |
488 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string( ).latin1().data()); | 492 WTF_LOG(ResourceLoading, "Failed to load '%s'.\n", m_resource->url().string( ).latin1().data()); |
489 | 493 |
490 RefPtrWillBeRawPtr<ResourceLoader> protect(this); | 494 RefPtrWillBeRawPtr<ResourceLoader> protect(this); |
491 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get()); | 495 RefPtrWillBeRawPtr<ResourceLoaderHost> protectHost(m_host.get()); |
492 ResourcePtr<Resource> protectResource(m_resource); | 496 ResourcePtr<Resource> protectResource(m_resource); |
493 m_state = Finishing; | 497 m_state = Finishing; |
494 m_resource->setResourceError(error); | 498 m_resource->setResourceError(error); |
495 | 499 |
496 if (!m_notifiedLoadComplete) { | 500 if (!m_notifiedLoadComplete) { |
497 m_notifiedLoadComplete = true; | 501 m_notifiedLoadComplete = true; |
502 m_requestCountTracker.clear(); | |
498 m_host->didFailLoading(m_resource, error); | 503 m_host->didFailLoading(m_resource, error); |
499 } | 504 } |
500 if (m_state == Terminated) | 505 if (m_state == Terminated) |
501 return; | 506 return; |
502 | 507 |
503 m_resource->error(Resource::LoadError); | 508 m_resource->error(Resource::LoadError); |
504 | 509 |
505 if (m_state == Terminated) | 510 if (m_state == Terminated) |
506 return; | 511 return; |
507 | 512 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); | 553 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
549 } | 554 } |
550 | 555 |
551 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const | 556 ResourceRequest& ResourceLoader::applyOptions(ResourceRequest& request) const |
552 { | 557 { |
553 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); | 558 request.setAllowStoredCredentials(m_options.allowCredentials == AllowStoredC redentials); |
554 return request; | 559 return request; |
555 } | 560 } |
556 | 561 |
557 } | 562 } |
OLD | NEW |