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

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

Issue 2540023003: Dispatch encoded_data_length separately in content/child (Closed)
Patch Set: fix Created 4 years 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 std::unique_ptr<WebDataConsumerHandle> handle) { 200 std::unique_ptr<WebDataConsumerHandle> handle) {
201 DCHECK(!response.isNull()); 201 DCHECK(!response.isNull());
202 m_fetcher->didReceiveResponse(m_resource.get(), response.toResourceResponse(), 202 m_fetcher->didReceiveResponse(m_resource.get(), response.toResourceResponse(),
203 std::move(handle)); 203 std::move(handle));
204 } 204 }
205 205
206 void ResourceLoader::didReceiveResponse(const WebURLResponse& response) { 206 void ResourceLoader::didReceiveResponse(const WebURLResponse& response) {
207 didReceiveResponse(response, nullptr); 207 didReceiveResponse(response, nullptr);
208 } 208 }
209 209
210 void ResourceLoader::didReceiveData(const char* data, 210 void ResourceLoader::didReceiveData(const char* data, int length) {
211 int length,
212 int encodedDataLength) {
213 CHECK_GE(length, 0); 211 CHECK_GE(length, 0);
214 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength); 212 m_fetcher->didReceiveData(m_resource.get(), data, length);
215 m_resource->addToDecodedBodyLength(length); 213 m_resource->addToDecodedBodyLength(length);
216 m_resource->appendData(data, length); 214 m_resource->appendData(data, length);
217 } 215 }
218 216
217 void ResourceLoader::didReceiveTransferSizeUpdate(int transferSizeDiff) {
218 DCHECK_GT(transferSizeDiff, 0);
219 m_fetcher->didReceiveTransferSizeUpdate(m_resource.get(), transferSizeDiff);
220 }
221
219 void ResourceLoader::didFinishLoadingFirstPartInMultipart() { 222 void ResourceLoader::didFinishLoadingFirstPartInMultipart() {
220 m_fetcher->didFinishLoading(m_resource.get(), 0, 223 m_fetcher->didFinishLoading(m_resource.get(), 0,
221 ResourceFetcher::DidFinishFirstPartInMultipart); 224 ResourceFetcher::DidFinishFirstPartInMultipart);
222 } 225 }
223 226
224 void ResourceLoader::didFinishLoading(double finishTime, 227 void ResourceLoader::didFinishLoading(double finishTime,
225 int64_t encodedDataLength, 228 int64_t encodedDataLength,
226 int64_t encodedBodyLength) { 229 int64_t encodedBodyLength) {
227 m_resource->setEncodedDataLength(encodedDataLength); 230 m_resource->setEncodedDataLength(encodedDataLength);
228 m_resource->addToEncodedBodyLength(encodedBodyLength); 231 m_resource->addToEncodedBodyLength(encodedBodyLength);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 didReceiveResponse(responseOut); 283 didReceiveResponse(responseOut);
281 if (!m_loader) 284 if (!m_loader)
282 return; 285 return;
283 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0); 286 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0);
284 287
285 // Follow the async case convention of not calling didReceiveData or 288 // Follow the async case convention of not calling didReceiveData or
286 // appending data to m_resource if the response body is empty. Copying the 289 // appending data to m_resource if the response body is empty. Copying the
287 // empty buffer is a noop in most cases, but is destructive in the case of 290 // empty buffer is a noop in most cases, but is destructive in the case of
288 // a 304, where it will overwrite the cached data we should be reusing. 291 // a 304, where it will overwrite the cached data we should be reusing.
289 if (dataOut.size()) { 292 if (dataOut.size()) {
290 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size(), 293 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size());
291 encodedDataLength);
292 m_resource->setResourceBuffer(dataOut); 294 m_resource->setResourceBuffer(dataOut);
293 } 295 }
294 didFinishLoading(monotonicallyIncreasingTime(), encodedDataLength, 296 didFinishLoading(monotonicallyIncreasingTime(), encodedDataLength,
295 encodedBodyLength); 297 encodedBodyLength);
296 } 298 }
297 299
298 void ResourceLoader::activateCacheAwareLoadingIfNeeded( 300 void ResourceLoader::activateCacheAwareLoadingIfNeeded(
299 const ResourceRequest& request) { 301 const ResourceRequest& request) {
300 DCHECK(!m_isCacheAwareLoadingActivated); 302 DCHECK(!m_isCacheAwareLoadingActivated);
301 303
(...skipping 10 matching lines...) Expand all
312 return; 314 return;
313 315
314 // Don't activate if cache policy is explicitly set. 316 // Don't activate if cache policy is explicitly set.
315 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) 317 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy)
316 return; 318 return;
317 319
318 m_isCacheAwareLoadingActivated = true; 320 m_isCacheAwareLoadingActivated = true;
319 } 321 }
320 322
321 } // namespace blink 323 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698