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

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: Fix lint error: ASSERT -> DCHECK 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors()) 191 if (m_resource->response().httpStatusCode() < 400 || m_resource->shouldIgnor eHTTPStatusCodeErrors())
192 return; 192 return;
193 didFail(nullptr, ResourceError::cancelledError(resourceResponse.url())); 193 didFail(nullptr, ResourceError::cancelledError(resourceResponse.url()));
194 } 194 }
195 195
196 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response) 196 void ResourceLoader::didReceiveResponse(WebURLLoader* loader, const WebURLRespon se& response)
197 { 197 {
198 didReceiveResponse(loader, response, nullptr); 198 didReceiveResponse(loader, response, nullptr);
199 } 199 }
200 200
201 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength) 201 void ResourceLoader::didReceiveData(WebURLLoader*, const char* data, int length, int encodedDataLength, int encodedBodyLength)
202 { 202 {
203 RELEASE_ASSERT(length >= 0); 203 RELEASE_ASSERT(length >= 0);
204 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength) ; 204 m_fetcher->didReceiveData(m_resource.get(), data, length, encodedDataLength) ;
205 m_resource->addToEncodedBodyLength(encodedBodyLength);
206 m_resource->addToDecodedBodyLength(length);
205 m_resource->appendData(data, length); 207 m_resource->appendData(data, length);
206 } 208 }
207 209
208 void ResourceLoader::didFinishLoadingFirstPartInMultipart() 210 void ResourceLoader::didFinishLoadingFirstPartInMultipart()
209 { 211 {
210 m_fetcher->didFinishLoading(m_resource.get(), 0, WebURLLoaderClient::kUnknow nEncodedDataLength, ResourceFetcher::DidFinishFirstPartInMultipart); 212 m_fetcher->didFinishLoading(m_resource.get(), 0, WebURLLoaderClient::kUnknow nEncodedDataLength, ResourceFetcher::DidFinishFirstPartInMultipart);
211 } 213 }
212 214
213 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength) 215 void ResourceLoader::didFinishLoading(WebURLLoader*, double finishTime, int64_t encodedDataLength)
214 { 216 {
(...skipping 27 matching lines...) Expand all
242 return; 244 return;
243 if (errorOut.reason) { 245 if (errorOut.reason) {
244 didFail(0, errorOut); 246 didFail(0, errorOut);
245 return; 247 return;
246 } 248 }
247 didReceiveResponse(0, responseOut); 249 didReceiveResponse(0, responseOut);
248 if (!m_loader) 250 if (!m_loader)
249 return; 251 return;
250 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo(); 252 RefPtr<ResourceLoadInfo> resourceLoadInfo = responseOut.toResourceResponse() .resourceLoadInfo();
251 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength; 253 int64_t encodedDataLength = resourceLoadInfo ? resourceLoadInfo->encodedData Length : WebURLLoaderClient::kUnknownEncodedDataLength;
254 DCHECK_GE(responseOut.toResourceResponse().encodedBodyLength(), 0);
252 255
253 // Follow the async case convention of not calling didReceiveData or 256 // Follow the async case convention of not calling didReceiveData or
254 // appending data to m_resource if the response body is empty. Copying the 257 // appending data to m_resource if the response body is empty. Copying the
255 // empty buffer is a noop in most cases, but is destructive in the case of 258 // empty buffer is a noop in most cases, but is destructive in the case of
256 // a 304, where it will overwrite the cached data we should be reusing. 259 // a 304, where it will overwrite the cached data we should be reusing.
257 if (dataOut.size()) { 260 if (dataOut.size()) {
258 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength); 261 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength);
259 m_resource->setResourceBuffer(dataOut); 262 m_resource->setResourceBuffer(dataOut);
260 } 263 }
261 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 264 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
262 } 265 }
263 266
264 } // namespace blink 267 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698