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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 } | 181 } |
182 | 182 |
183 void ResourceLoader::didDownloadData(blink::WebURLLoader*, int length, int encod
edDataLength) | 183 void ResourceLoader::didDownloadData(blink::WebURLLoader*, int length, int encod
edDataLength) |
184 { | 184 { |
185 RefPtr<ResourceLoader> protect(this); | 185 RefPtr<ResourceLoader> protect(this); |
186 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse); | 186 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse); |
187 m_host->didDownloadData(m_resource, length, encodedDataLength); | 187 m_host->didDownloadData(m_resource, length, encodedDataLength); |
188 m_resource->didDownloadData(length); | 188 m_resource->didDownloadData(length); |
189 } | 189 } |
190 | 190 |
191 void ResourceLoader::didFinishLoadingOnePart(double finishTime) | 191 void ResourceLoader::didFinishLoadingOnePart(double finishTime, int64 encodedDat
aLength) |
192 { | 192 { |
193 // If load has been cancelled after finishing (which could happen with a | 193 // If load has been cancelled after finishing (which could happen with a |
194 // JavaScript that changes the window location), do nothing. | 194 // JavaScript that changes the window location), do nothing. |
195 if (m_state == Terminated) | 195 if (m_state == Terminated) |
196 return; | 196 return; |
197 | 197 |
198 if (m_notifiedLoadComplete) | 198 if (m_notifiedLoadComplete) |
199 return; | 199 return; |
200 m_notifiedLoadComplete = true; | 200 m_notifiedLoadComplete = true; |
201 m_host->didFinishLoading(m_resource, finishTime); | 201 m_host->didFinishLoading(m_resource, finishTime, encodedDataLength); |
202 } | 202 } |
203 | 203 |
204 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority) | 204 void ResourceLoader::didChangePriority(ResourceLoadPriority loadPriority) |
205 { | 205 { |
206 if (m_loader) { | 206 if (m_loader) { |
207 m_host->didChangeLoadingPriority(m_resource, loadPriority); | 207 m_host->didChangeLoadingPriority(m_resource, loadPriority); |
208 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>(
loadPriority)); | 208 m_loader->didChangePriority(static_cast<blink::WebURLRequest::Priority>(
loadPriority)); |
209 } | 209 } |
210 } | 210 } |
211 | 211 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 // We don't count multiParts in a ResourceFetcher's request count | 345 // We don't count multiParts in a ResourceFetcher's request count |
346 m_requestCountTracker.clear(); | 346 m_requestCountTracker.clear(); |
347 if (!m_resource->isImage()) { | 347 if (!m_resource->isImage()) { |
348 cancel(); | 348 cancel(); |
349 return; | 349 return; |
350 } | 350 } |
351 } else if (isMultipartPayload) { | 351 } else if (isMultipartPayload) { |
352 // Since a subresource loader does not load multipart sections progressi
vely, data was delivered to the loader all at once. | 352 // Since a subresource loader does not load multipart sections progressi
vely, data was delivered to the loader all at once. |
353 // After the first multipart section is complete, signal to delegates th
at this load is "finished" | 353 // After the first multipart section is complete, signal to delegates th
at this load is "finished" |
354 m_host->subresourceLoaderFinishedLoadingOnePart(this); | 354 m_host->subresourceLoaderFinishedLoadingOnePart(this); |
355 didFinishLoadingOnePart(0); | 355 didFinishLoadingOnePart(0, blink::WebURLLoaderClient::kUnknownEncodedDat
aLength); |
356 } | 356 } |
357 | 357 |
358 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) | 358 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor
eHTTPStatusCodeErrors()) |
359 return; | 359 return; |
360 m_state = Finishing; | 360 m_state = Finishing; |
361 | 361 |
362 if (!m_notifiedLoadComplete) { | 362 if (!m_notifiedLoadComplete) { |
363 m_notifiedLoadComplete = true; | 363 m_notifiedLoadComplete = true; |
364 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque
st.url())); | 364 m_host->didFailLoading(m_resource, ResourceError::cancelledError(m_reque
st.url())); |
365 } | 365 } |
(...skipping 17 matching lines...) Expand all Loading... |
383 // anything including removing the last reference to this object. | 383 // anything including removing the last reference to this object. |
384 RefPtr<ResourceLoader> protect(this); | 384 RefPtr<ResourceLoader> protect(this); |
385 | 385 |
386 // FIXME: If we get a resource with more than 2B bytes, this code won't do t
he right thing. | 386 // FIXME: If we get a resource with more than 2B bytes, this code won't do t
he right thing. |
387 // However, with today's computers and networking speeds, this won't happen
in practice. | 387 // However, with today's computers and networking speeds, this won't happen
in practice. |
388 // Could be an issue with a giant local file. | 388 // Could be an issue with a giant local file. |
389 m_host->didReceiveData(m_resource, data, length, encodedDataLength); | 389 m_host->didReceiveData(m_resource, data, length, encodedDataLength); |
390 m_resource->appendData(data, length); | 390 m_resource->appendData(data, length); |
391 } | 391 } |
392 | 392 |
393 void ResourceLoader::didFinishLoading(blink::WebURLLoader*, double finishTime) | 393 void ResourceLoader::didFinishLoading(blink::WebURLLoader*, double finishTime, i
nt64 encodedDataLength) |
394 { | 394 { |
395 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con
nectionState == ConnectionStateReceivingData); | 395 RELEASE_ASSERT(m_connectionState == ConnectionStateReceivedResponse || m_con
nectionState == ConnectionStateReceivingData); |
396 m_connectionState = ConnectionStateFinishedLoading; | 396 m_connectionState = ConnectionStateFinishedLoading; |
397 if (m_state != Initialized) | 397 if (m_state != Initialized) |
398 return; | 398 return; |
399 ASSERT(m_state != Terminated); | 399 ASSERT(m_state != Terminated); |
400 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1
().data()); | 400 WTF_LOG(ResourceLoading, "Received '%s'.", m_resource->url().string().latin1
().data()); |
401 | 401 |
402 RefPtr<ResourceLoader> protect(this); | 402 RefPtr<ResourceLoader> protect(this); |
403 ResourcePtr<Resource> protectResource(m_resource); | 403 ResourcePtr<Resource> protectResource(m_resource); |
404 m_state = Finishing; | 404 m_state = Finishing; |
405 didFinishLoadingOnePart(finishTime); | 405 didFinishLoadingOnePart(finishTime, encodedDataLength); |
406 m_resource->finish(finishTime); | 406 m_resource->finish(finishTime); |
407 | 407 |
408 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release | 408 // If the load has been cancelled by a delegate in response to didFinishLoad
(), do not release |
409 // the resources a second time, they have been released by cancel. | 409 // the resources a second time, they have been released by cancel. |
410 if (m_state == Terminated) | 410 if (m_state == Terminated) |
411 return; | 411 return; |
412 releaseResources(); | 412 releaseResources(); |
413 } | 413 } |
414 | 414 |
415 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err
or) | 415 void ResourceLoader::didFail(blink::WebURLLoader*, const blink::WebURLError& err
or) |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 blink::WebData dataOut; | 462 blink::WebData dataOut; |
463 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); | 463 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); |
464 if (errorOut.reason) { | 464 if (errorOut.reason) { |
465 didFail(0, errorOut); | 465 didFail(0, errorOut); |
466 return; | 466 return; |
467 } | 467 } |
468 didReceiveResponse(0, responseOut); | 468 didReceiveResponse(0, responseOut); |
469 if (m_state == Terminated) | 469 if (m_state == Terminated) |
470 return; | 470 return; |
471 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse()
.resourceLoadInfo(); | 471 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse()
.resourceLoadInfo(); |
472 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), resourceL
oadInfo ? resourceLoadInfo->encodedDataLength : -1); | 472 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe
ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength; |
| 473 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa
taLength); |
473 m_resource->setResourceBuffer(dataOut); | 474 m_resource->setResourceBuffer(dataOut); |
474 didFinishLoading(0, monotonicallyIncreasingTime()); | 475 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
475 } | 476 } |
476 | 477 |
477 } | 478 } |
OLD | NEW |