| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 m_requestCountTracker.clear(); | 459 m_requestCountTracker.clear(); |
| 460 if (!m_resource->isImage()) { | 460 if (!m_resource->isImage()) { |
| 461 cancel(); | 461 cancel(); |
| 462 return; | 462 return; |
| 463 } | 463 } |
| 464 } | 464 } |
| 465 | 465 |
| 466 RefPtr<ResourceBuffer> buffer = resourceData(); | 466 RefPtr<ResourceBuffer> buffer = resourceData(); |
| 467 if (m_loadingMultipartContent && buffer && buffer->size()) { | 467 if (m_loadingMultipartContent && buffer && buffer->size()) { |
| 468 sendDataToResource(buffer->data(), buffer->size()); | 468 sendDataToResource(buffer->data(), buffer->size()); |
| 469 m_resource->finishOnePart(); |
| 469 clearResourceData(); | 470 clearResourceData(); |
| 470 // Since a subresource loader does not load multipart sections progressi
vely, data was delivered to the loader all at once. | 471 // Since a subresource loader does not load multipart sections progressi
vely, data was delivered to the loader all at once. |
| 471 // After the first multipart section is complete, signal to delegates th
at this load is "finished" | 472 // After the first multipart section is complete, signal to delegates th
at this load is "finished" |
| 472 m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this); | 473 m_documentLoader->subresourceLoaderFinishedLoadingOnePart(this); |
| 473 didFinishLoadingOnePart(0); | 474 didFinishLoadingOnePart(0); |
| 474 } | 475 } |
| 475 | 476 |
| 476 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) | 477 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) |
| 477 return; | 478 return; |
| 478 m_state = Finishing; | 479 m_state = Finishing; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 509 } | 510 } |
| 510 | 511 |
| 511 void ResourceLoader::sendDataToResource(const char* data, int length) | 512 void ResourceLoader::sendDataToResource(const char* data, int length) |
| 512 { | 513 { |
| 513 // There are two cases where we might need to create our own SharedBuffer in
stead of copying the one in ResourceLoader. | 514 // There are two cases where we might need to create our own SharedBuffer in
stead of copying the one in ResourceLoader. |
| 514 // (1) Multipart content: The loader delivers the data in a multipart sectio
n all at once, then sends eof. | 515 // (1) Multipart content: The loader delivers the data in a multipart sectio
n all at once, then sends eof. |
| 515 // The resource data will change as the next part is loaded, so we need
to make a copy. | 516 // The resource data will change as the next part is loaded, so we need
to make a copy. |
| 516 // (2) Our client requested that the data not be buffered at the ResourceLoa
der level via ResourceLoaderOptions. In this case, | 517 // (2) Our client requested that the data not be buffered at the ResourceLoa
der level via ResourceLoaderOptions. In this case, |
| 517 // ResourceLoader::resourceData() will be null. However, unlike the mult
ipart case, we don't want to tell the CachedResource | 518 // ResourceLoader::resourceData() will be null. However, unlike the mult
ipart case, we don't want to tell the CachedResource |
| 518 // that all data has been received yet. | 519 // that all data has been received yet. |
| 519 if (m_loadingMultipartContent || !resourceData()) { | 520 RefPtr<ResourceBuffer> buffer; |
| 520 RefPtr<ResourceBuffer> copiedData = ResourceBuffer::create(data, length)
; | 521 if (m_loadingMultipartContent || !resourceData()) |
| 521 m_resource->data(copiedData.release(), m_loadingMultipartContent); | 522 buffer = ResourceBuffer::create(data, length); |
| 522 } else | 523 else |
| 523 m_resource->data(resourceData(), false); | 524 buffer = resourceData(); |
| 525 m_resource->data(buffer.release()); |
| 524 } | 526 } |
| 525 | 527 |
| 526 void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime) | 528 void ResourceLoader::didFinishLoading(ResourceHandle*, double finishTime) |
| 527 { | 529 { |
| 528 if (m_state != Initialized) | 530 if (m_state != Initialized) |
| 529 return; | 531 return; |
| 530 ASSERT(!reachedTerminalState()); | 532 ASSERT(!reachedTerminalState()); |
| 531 ASSERT(!m_resource->resourceToRevalidate()); | 533 ASSERT(!m_resource->resourceToRevalidate()); |
| 532 ASSERT(!m_resource->errorOccurred()); | 534 ASSERT(!m_resource->errorOccurred()); |
| 533 LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().d
ata()); | 535 LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1().d
ata()); |
| 534 | 536 |
| 535 RefPtr<ResourceLoader> protect(this); | 537 RefPtr<ResourceLoader> protect(this); |
| 536 CachedResourceHandle<CachedResource> protectResource(m_resource); | 538 CachedResourceHandle<CachedResource> protectResource(m_resource); |
| 537 m_state = Finishing; | 539 m_state = Finishing; |
| 538 m_resource->setLoadFinishTime(finishTime); | 540 m_resource->setLoadFinishTime(finishTime); |
| 539 m_resource->data(resourceData(), true); | |
| 540 m_resource->finish(); | 541 m_resource->finish(); |
| 541 didFinishLoadingOnePart(finishTime); | 542 didFinishLoadingOnePart(finishTime); |
| 542 | 543 |
| 543 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release | 544 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release |
| 544 // the resources a second time, they have been released by cancel. | 545 // the resources a second time, they have been released by cancel. |
| 545 if (m_cancelled) | 546 if (m_cancelled) |
| 546 return; | 547 return; |
| 547 releaseResources(); | 548 releaseResources(); |
| 548 } | 549 } |
| 549 | 550 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 info.addMember(m_originalRequest, "originalRequest"); | 600 info.addMember(m_originalRequest, "originalRequest"); |
| 600 info.addMember(m_resourceData, "resourceData"); | 601 info.addMember(m_resourceData, "resourceData"); |
| 601 info.addMember(m_deferredRequest, "deferredRequest"); | 602 info.addMember(m_deferredRequest, "deferredRequest"); |
| 602 info.addMember(m_options, "options"); | 603 info.addMember(m_options, "options"); |
| 603 info.addMember(m_resource, "resource"); | 604 info.addMember(m_resource, "resource"); |
| 604 info.addMember(m_documentLoader, "documentLoader"); | 605 info.addMember(m_documentLoader, "documentLoader"); |
| 605 info.addMember(m_requestCountTracker, "requestCountTracker"); | 606 info.addMember(m_requestCountTracker, "requestCountTracker"); |
| 606 } | 607 } |
| 607 | 608 |
| 608 } | 609 } |
| OLD | NEW |