| 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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 int encodedBodyLength) { | 223 int encodedBodyLength) { |
| 224 CHECK_GE(length, 0); | 224 CHECK_GE(length, 0); |
| 225 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength); | 225 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength); |
| 226 m_resource->addToEncodedBodyLength(encodedBodyLength); | 226 m_resource->addToEncodedBodyLength(encodedBodyLength); |
| 227 m_resource->addToDecodedBodyLength(length); | 227 m_resource->addToDecodedBodyLength(length); |
| 228 m_resource->appendData(data, length); | 228 m_resource->appendData(data, length); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void ResourceLoader::didFinishLoadingFirstPartInMultipart() { | 231 void ResourceLoader::didFinishLoadingFirstPartInMultipart() { |
| 232 m_fetcher->didFinishLoading(m_resource.get(), 0, | 232 m_fetcher->didFinishLoading(m_resource.get(), 0, |
| 233 WebURLLoaderClient::kUnknownEncodedDataLength, | |
| 234 ResourceFetcher::DidFinishFirstPartInMultipart); | 233 ResourceFetcher::DidFinishFirstPartInMultipart); |
| 235 } | 234 } |
| 236 | 235 |
| 237 void ResourceLoader::didFinishLoading(WebURLLoader*, | 236 void ResourceLoader::didFinishLoading(WebURLLoader*, |
| 238 double finishTime, | 237 double finishTime, |
| 239 int64_t encodedDataLength) { | 238 int64_t encodedDataLength) { |
| 239 m_resource->setEncodedDataLength(encodedDataLength); |
| 240 m_loader.reset(); | 240 m_loader.reset(); |
| 241 m_fetcher->didFinishLoading(m_resource.get(), finishTime, encodedDataLength, | 241 m_fetcher->didFinishLoading(m_resource.get(), finishTime, |
| 242 ResourceFetcher::DidFinishLoading); | 242 ResourceFetcher::DidFinishLoading); |
| 243 } | 243 } |
| 244 | 244 |
| 245 void ResourceLoader::didFail(WebURLLoader*, const WebURLError& error) { | 245 void ResourceLoader::didFail(WebURLLoader*, |
| 246 const WebURLError& error, |
| 247 int64_t encodedDataLength) { |
| 248 m_resource->setEncodedDataLength(encodedDataLength); |
| 246 didFail(error); | 249 didFail(error); |
| 247 } | 250 } |
| 248 | 251 |
| 249 void ResourceLoader::didFail(const ResourceError& error) { | 252 void ResourceLoader::didFail(const ResourceError& error) { |
| 250 if (m_isCacheAwareLoadingActivated && error.isCacheMiss() && | 253 if (m_isCacheAwareLoadingActivated && error.isCacheMiss() && |
| 251 m_fetcher->context().shouldLoadNewResource(m_resource->getType())) { | 254 m_fetcher->context().shouldLoadNewResource(m_resource->getType())) { |
| 252 m_resource->willReloadAfterDiskCacheMiss(); | 255 m_resource->willReloadAfterDiskCacheMiss(); |
| 253 m_isCacheAwareLoadingActivated = false; | 256 m_isCacheAwareLoadingActivated = false; |
| 254 restart(m_resource->resourceRequest(), | 257 restart(m_resource->resourceRequest(), |
| 255 m_fetcher->context().loadingTaskRunner(), | 258 m_fetcher->context().loadingTaskRunner(), |
| (...skipping 17 matching lines...) Expand all Loading... |
| 273 WebData dataOut; | 276 WebData dataOut; |
| 274 int64_t encodedDataLength = WebURLLoaderClient::kUnknownEncodedDataLength; | 277 int64_t encodedDataLength = WebURLLoaderClient::kUnknownEncodedDataLength; |
| 275 m_loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut, | 278 m_loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut, |
| 276 encodedDataLength); | 279 encodedDataLength); |
| 277 | 280 |
| 278 // A message dispatched while synchronously fetching the resource | 281 // A message dispatched while synchronously fetching the resource |
| 279 // can bring about the cancellation of this load. | 282 // can bring about the cancellation of this load. |
| 280 if (!m_loader) | 283 if (!m_loader) |
| 281 return; | 284 return; |
| 282 if (errorOut.reason) { | 285 if (errorOut.reason) { |
| 283 didFail(0, errorOut); | 286 didFail(0, errorOut, encodedDataLength); |
| 284 return; | 287 return; |
| 285 } | 288 } |
| 286 didReceiveResponse(0, responseOut); | 289 didReceiveResponse(0, responseOut); |
| 287 if (!m_loader) | 290 if (!m_loader) |
| 288 return; | 291 return; |
| 289 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0); | 292 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0); |
| 290 | 293 |
| 291 // Follow the async case convention of not calling didReceiveData or | 294 // Follow the async case convention of not calling didReceiveData or |
| 292 // appending data to m_resource if the response body is empty. Copying the | 295 // appending data to m_resource if the response body is empty. Copying the |
| 293 // empty buffer is a noop in most cases, but is destructive in the case of | 296 // empty buffer is a noop in most cases, but is destructive in the case of |
| (...skipping 23 matching lines...) Expand all Loading... |
| 317 return; | 320 return; |
| 318 | 321 |
| 319 // Don't activate if cache policy is explicitly set. | 322 // Don't activate if cache policy is explicitly set. |
| 320 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) | 323 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) |
| 321 return; | 324 return; |
| 322 | 325 |
| 323 m_isCacheAwareLoadingActivated = true; | 326 m_isCacheAwareLoadingActivated = true; |
| 324 } | 327 } |
| 325 | 328 |
| 326 } // namespace blink | 329 } // namespace blink |
| OLD | NEW |