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

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

Issue 2105713002: Render process changes for ResourceTiming sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resource_timing_sizes_browser_process
Patch Set: Initialise encoded_body_length for sync XHR to data: URLs Created 4 years, 5 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 { 109 {
110 if (m_loader) 110 if (m_loader)
111 m_loader->didChangePriority(static_cast<WebURLRequest::Priority>(loadPri ority), intraPriorityValue); 111 m_loader->didChangePriority(static_cast<WebURLRequest::Priority>(loadPri ority), intraPriorityValue);
112 } 112 }
113 113
114 void ResourceLoader::cancel() 114 void ResourceLoader::cancel()
115 { 115 {
116 didFail(nullptr, ResourceError::cancelledError(m_resource->lastResourceReque st().url())); 116 didFail(nullptr, ResourceError::cancelledError(m_resource->lastResourceReque st().url()));
117 } 117 }
118 118
119 void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR equest, const WebURLResponse& passedRedirectResponse) 119 void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR equest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength)
120 { 120 {
121 ASSERT(!passedNewRequest.isNull()); 121 ASSERT(!passedNewRequest.isNull());
122 ASSERT(!passedRedirectResponse.isNull()); 122 ASSERT(!passedRedirectResponse.isNull());
123 123
124 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); 124 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
125 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse()); 125 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse());
126 newRequest.setRedirectStatus(ResourceRequest::RedirectStatus::FollowedRedire ct); 126 newRequest.setRedirectStatus(ResourceRequest::RedirectStatus::FollowedRedire ct);
127 127
128 if (m_fetcher->willFollowRedirect(m_resource.get(), newRequest, redirectResp onse)) { 128 if (m_fetcher->willFollowRedirect(m_resource.get(), newRequest, redirectResp onse, encodedDataLength)) {
129 m_resource->willFollowRedirect(newRequest, redirectResponse); 129 m_resource->willFollowRedirect(newRequest, redirectResponse);
130 } else { 130 } else {
131 m_resource->willNotFollowRedirect(); 131 m_resource->willNotFollowRedirect();
132 if (m_loader) 132 if (m_loader)
133 didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(newRe quest.url())); 133 didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(newRe quest.url()));
134 } 134 }
135 } 135 }
136 136
137 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length) 137 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length)
138 { 138 {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) 198 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors())
199 return; 199 return;
200 didFail(nullptr, ResourceError::cancelledError(resourceResponse.url())); 200 didFail(nullptr, ResourceError::cancelledError(resourceResponse.url()));
201 } 201 }
202 202
203 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response) 203 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response)
204 { 204 {
205 didReceiveResponse(loader, response, nullptr); 205 didReceiveResponse(loader, response, nullptr);
206 } 206 }
207 207
208 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength) 208 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength, int encodedBodyLength)
209 { 209 {
210 RELEASE_ASSERT(length >= 0); 210 RELEASE_ASSERT(length >= 0);
211 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength) ; 211 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength) ;
212 m_resource->addToEncodedBodyLength(encodedBodyLength);
213 m_resource->addToDecodedBodyLength(length);
212 m_resource->appendData(data, length); 214 m_resource->appendData(data, length);
213 } 215 }
214 216
215 void ResourceLoader::didFinishLoadingFirstPartInMultipart() 217 void ResourceLoader::didFinishLoadingFirstPartInMultipart()
216 { 218 {
217 m_fetcher->didFinishLoading(m_resource.get(), 0, WebURLLoaderClient::kUnknow nEncodedDataLength, ResourceFetcher::DidFinishFirstPartInMultipart); 219 m_fetcher->didFinishLoading(m_resource.get(), 0, WebURLLoaderClient::kUnknow nEncodedDataLength, ResourceFetcher::DidFinishFirstPartInMultipart);
218 } 220 }
219 221
220 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength) 222 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength)
221 { 223 {
(...skipping 26 matching lines...) Expand all
248 return; 250 return;
249 if (errorOut.reason) { 251 if (errorOut.reason) {
250 didFail(0, errorOut); 252 didFail(0, errorOut);
251 return; 253 return;
252 } 254 }
253 didReceiveResponse(0, responseOut); 255 didReceiveResponse(0, responseOut);
254 if (!m_loader) 256 if (!m_loader)
255 return; 257 return;
256 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 258 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
257 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength; 259 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength;
260 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0);
258 261
259 // Follow the async case convention of not calling didReceiveData or 262 // Follow the async case convention of not calling didReceiveData or
260 // appending data to m_resource if the response body is empty. Copying the 263 // appending data to m_resource if the response body is empty. Copying the
261 // empty buffer is a noop in most cases, but is destructive in the case of 264 // empty buffer is a noop in most cases, but is destructive in the case of
262 // a 304, where it will overwrite the cached data we should be reusing. 265 // a 304, where it will overwrite the cached data we should be reusing.
263 if (dataOut.size()) { 266 if (dataOut.size()) {
264 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength); 267 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength);
265 m_resource->setResourceBuffer(dataOut); 268 m_resource->setResourceBuffer(dataOut);
266 } 269 }
267 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 270 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
268 } 271 }
269 272
270 } // namespace blink 273 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.h ('k') | third_party/WebKit/Source/core/loader/BeaconLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698