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

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

Issue 2230173002: Change WebURLLoaderClient::willFollowRedirect() API to return bool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed #32 Created 4 years, 3 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 { 116 {
117 if (m_loader) 117 if (m_loader)
118 m_loader->didChangePriority(static_cast<WebURLRequest::Priority>(loadPri ority), intraPriorityValue); 118 m_loader->didChangePriority(static_cast<WebURLRequest::Priority>(loadPri ority), intraPriorityValue);
119 } 119 }
120 120
121 void ResourceLoader::cancel() 121 void ResourceLoader::cancel()
122 { 122 {
123 didFail(nullptr, ResourceError::cancelledError(m_resource->lastResourceReque st().url())); 123 didFail(nullptr, ResourceError::cancelledError(m_resource->lastResourceReque st().url()));
124 } 124 }
125 125
126 void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR equest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength) 126 bool ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR equest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength)
127 { 127 {
128 ASSERT(!passedNewRequest.isNull()); 128 ASSERT(!passedNewRequest.isNull());
129 ASSERT(!passedRedirectResponse.isNull()); 129 ASSERT(!passedRedirectResponse.isNull());
130 130
131 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); 131 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
132 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse()); 132 const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceRe sponse());
133 newRequest.setRedirectStatus(ResourceRequest::RedirectStatus::FollowedRedire ct); 133 newRequest.setRedirectStatus(ResourceRequest::RedirectStatus::FollowedRedire ct);
134 134
135 const KURL originalURL = newRequest.url();
135 if (m_fetcher->willFollowRedirect(m_resource.get(), newRequest, redirectResp onse, encodedDataLength)) { 136 if (m_fetcher->willFollowRedirect(m_resource.get(), newRequest, redirectResp onse, encodedDataLength)) {
Nate Chapin 2016/09/07 17:05:45 This nesting is a bit difficult to reason about, i
tyoshino (SeeGerritForStatus) 2016/09/14 14:53:47 Nice suggestion. Reorganized.
136 m_resource->willFollowRedirect(newRequest, redirectResponse); 137 if (m_resource->willFollowRedirect(newRequest, redirectResponse)) {
138 // ResourceFetcher::willFollowRedirect() may rewrite the URL to
139 // something else not for rejecting redirect but for other reasons.
140 // E.g. WebFrameTestClient::willSendRequest() and
141 // RenderFrameImpl::willSendRequest(). We should reflect the
142 // rewriting but currently we cannot. So, return false to make the
143 // redirect fail.
144 return newRequest.url() == originalURL;
145 }
146
147 return false;
137 } else { 148 } else {
138 m_resource->willNotFollowRedirect(); 149 m_resource->willNotFollowRedirect();
139 if (m_loader) 150 if (m_loader)
140 didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(newRe quest.url())); 151 didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(newRe quest.url()));
152 return false;
141 } 153 }
142 } 154 }
143 155
144 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length) 156 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, const char* data, i nt length)
145 { 157 {
146 m_resource->setSerializedCachedMetadata(data, length); 158 m_resource->setSerializedCachedMetadata(data, length);
147 } 159 }
148 160
149 void ResourceLoader::didSendData(WebURLLoader*, unsigned long long bytesSent, un signed long long totalBytesToBeSent) 161 void ResourceLoader::didSendData(WebURLLoader*, unsigned long long bytesSent, un signed long long totalBytesToBeSent)
150 { 162 {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // empty buffer is a noop in most cases, but is destructive in the case of 232 // empty buffer is a noop in most cases, but is destructive in the case of
221 // a 304, where it will overwrite the cached data we should be reusing. 233 // a 304, where it will overwrite the cached data we should be reusing.
222 if (dataOut.size()) { 234 if (dataOut.size()) {
223 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength); 235 m_fetcher->didReceiveData(m_resource.get(), dataOut.data(), dataOut.size (), encodedDataLength);
224 m_resource->setResourceBuffer(dataOut); 236 m_resource->setResourceBuffer(dataOut);
225 } 237 }
226 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength); 238 didFinishLoading(0, monotonicallyIncreasingTime(), encodedDataLength);
227 } 239 }
228 240
229 } // namespace blink 241 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.h ('k') | third_party/WebKit/Source/core/loader/DocumentLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698