| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 { | 235 { |
| 236 // downloadToFile is not supported for synchronous requests. | 236 // downloadToFile is not supported for synchronous requests. |
| 237 ASSERT(!request.downloadToFile()); | 237 ASSERT(!request.downloadToFile()); |
| 238 ASSERT(m_loader); | 238 ASSERT(m_loader); |
| 239 DCHECK(request.priority() == ResourceLoadPriorityHighest); | 239 DCHECK(request.priority() == ResourceLoadPriorityHighest); |
| 240 | 240 |
| 241 WrappedResourceRequest requestIn(request); | 241 WrappedResourceRequest requestIn(request); |
| 242 WebURLResponse responseOut; | 242 WebURLResponse responseOut; |
| 243 WebURLError errorOut; | 243 WebURLError errorOut; |
| 244 WebData dataOut; | 244 WebData dataOut; |
| 245 m_loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut); | 245 int64_t encodedDataLength = WebURLLoaderClient::kUnknownEncodedDataLength; |
| 246 m_loader->loadSynchronously(requestIn, responseOut, errorOut, dataOut, encod
edDataLength); |
| 246 | 247 |
| 247 // A message dispatched while synchronously fetching the resource | 248 // A message dispatched while synchronously fetching the resource |
| 248 // can bring about the cancellation of this load. | 249 // can bring about the cancellation of this load. |
| 249 if (!m_loader) | 250 if (!m_loader) |
| 250 return; | 251 return; |
| 251 if (errorOut.reason) { | 252 if (errorOut.reason) { |
| 252 didFail(0, errorOut); | 253 didFail(0, errorOut); |
| 253 return; | 254 return; |
| 254 } | 255 } |
| 255 didReceiveResponse(0, responseOut); | 256 didReceiveResponse(0, responseOut); |
| 256 if (!m_loader) | 257 if (!m_loader) |
| 257 return; | 258 return; |
| 258 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse()
.resourceLoadInfo(); | |
| 259 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData
Length : WebURLLoaderClient::kUnknownEncodedDataLength; | |
| 260 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0); | 259 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0); |
| 261 | 260 |
| 262 // Follow the async case convention of not calling didReceiveData or | 261 // Follow the async case convention of not calling didReceiveData or |
| 263 // appending data to m_resource if the response body is empty. Copying the | 262 // appending data to m_resource if the response body is empty. Copying the |
| 264 // empty buffer is a noop in most cases, but is destructive in the case of | 263 // empty buffer is a noop in most cases, but is destructive in the case of |
| 265 // a 304, where it will overwrite the cached data we should be reusing. | 264 // a 304, where it will overwrite the cached data we should be reusing. |
| 266 if (dataOut.size()) { | 265 if (dataOut.size()) { |
| 267 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size
(), encodedDataLength); | 266 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size
(), encodedDataLength); |
| 268 m_resource->setResourceBuffer(dataOut); | 267 m_resource->setResourceBuffer(dataOut); |
| 269 } | 268 } |
| 270 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); | 269 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); |
| 271 } | 270 } |
| 272 | 271 |
| 273 } // namespace blink | 272 } // namespace blink |
| OLD | NEW |