Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(641)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp

Issue 2163183002: Fix PerformanceResourceTiming transferSize field for sync XHR (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_worker_tests
Patch Set: Rebase Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698