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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const | 441 bool ResourceLoader::isLoadedBy(ResourceLoaderHost* loader) const |
442 { | 442 { |
443 return m_host->isLoadedBy(loader); | 443 return m_host->isLoadedBy(loader); |
444 } | 444 } |
445 | 445 |
446 void ResourceLoader::requestSynchronously() | 446 void ResourceLoader::requestSynchronously() |
447 { | 447 { |
448 OwnPtr<blink::WebURLLoader> loader = adoptPtr(blink::Platform::current()->cr
eateURLLoader()); | 448 OwnPtr<blink::WebURLLoader> loader = adoptPtr(blink::Platform::current()->cr
eateURLLoader()); |
449 ASSERT(loader); | 449 ASSERT(loader); |
450 | 450 |
| 451 // downloadToFile is not supported for synchronous requests. |
| 452 ASSERT(!m_request.downloadToFile()); |
| 453 |
451 RefPtr<ResourceLoader> protect(this); | 454 RefPtr<ResourceLoader> protect(this); |
452 RefPtr<ResourceLoaderHost> protectHost(m_host); | 455 RefPtr<ResourceLoaderHost> protectHost(m_host); |
453 ResourcePtr<Resource> protectResource(m_resource); | 456 ResourcePtr<Resource> protectResource(m_resource); |
454 | 457 |
455 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); | 458 RELEASE_ASSERT(m_connectionState == ConnectionStateNew); |
456 m_connectionState = ConnectionStateStarted; | 459 m_connectionState = ConnectionStateStarted; |
457 | 460 |
458 blink::WrappedResourceRequest requestIn(m_request); | 461 blink::WrappedResourceRequest requestIn(m_request); |
459 requestIn.setAllowStoredCredentials(m_options.allowCredentials == AllowStore
dCredentials); | 462 requestIn.setAllowStoredCredentials(m_options.allowCredentials == AllowStore
dCredentials); |
460 blink::WebURLResponse responseOut; | 463 blink::WebURLResponse responseOut; |
461 responseOut.initialize(); | 464 responseOut.initialize(); |
462 blink::WebURLError errorOut; | 465 blink::WebURLError errorOut; |
463 blink::WebData dataOut; | 466 blink::WebData dataOut; |
464 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); | 467 loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); |
465 if (errorOut.reason) { | 468 if (errorOut.reason) { |
466 didFail(0, errorOut); | 469 didFail(0, errorOut); |
467 return; | 470 return; |
468 } | 471 } |
469 didReceiveResponse(0, responseOut); | 472 didReceiveResponse(0, responseOut); |
470 if (m_state == Terminated) | 473 if (m_state == Terminated) |
471 return; | 474 return; |
472 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse()
.resourceLoadInfo(); | 475 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse()
.resourceLoadInfo(); |
473 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe
ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength; | 476 int64 encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedDataLe
ngth : blink::WebURLLoaderClient::kUnknownEncodedDataLength; |
474 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa
taLength); | 477 m_host->didReceiveData(m_resource, dataOut.data(), dataOut.size(), encodedDa
taLength); |
475 m_resource->setResourceBuffer(dataOut); | 478 m_resource->setResourceBuffer(dataOut); |
476 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); | 479 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
477 } | 480 } |
478 | 481 |
479 } | 482 } |
OLD | NEW |