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

Side by Side Diff: Source/core/loader/DocumentThreadableLoader.cpp

Issue 643733003: DocumentThreadableLoader: Call clearResource() when rejecting redirect (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 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
« no previous file with comments | « no previous file | Source/web/tests/AssociatedURLLoaderTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013, Intel Corporation 3 * Copyright (C) 2013, Intel Corporation
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 are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 m_client = 0; 239 m_client = 0;
240 m_requestStartedSeconds = 0.0; 240 m_requestStartedSeconds = 0.0;
241 } 241 }
242 242
243 void DocumentThreadableLoader::setDefersLoading(bool value) 243 void DocumentThreadableLoader::setDefersLoading(bool value)
244 { 244 {
245 if (resource()) 245 if (resource())
246 resource()->setDefersLoading(value); 246 resource()->setDefersLoading(value);
247 } 247 }
248 248
249 // In this method, we can clear |request| to tell content::WebURLLoaderImpl of
250 // Chromium not to follow the redirect. This works only when this method is
251 // called by RawResource::willSendRequest(). If called by
252 // RawResource::didAddClient(), clearing |request| won't be propagated
253 // to content::WebURLLoaderImpl. So, this loader must also get detached from
254 // the resource by calling clearResource().
249 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse) 255 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse)
250 { 256 {
251 ASSERT(m_client); 257 ASSERT(m_client);
252 ASSERT_UNUSED(resource, resource == this->resource()); 258 ASSERT_UNUSED(resource, resource == this->resource());
253 ASSERT(m_async); 259 ASSERT(m_async);
254 260
255 RefPtr<DocumentThreadableLoader> protect(this); 261 RefPtr<DocumentThreadableLoader> protect(this);
256 262
257 // FIXME: Support redirect in Fetch API. 263 // FIXME: Support redirect in Fetch API.
258 if (resource->resourceRequest().requestContext() == blink::WebURLRequest::Re questContextFetch) { 264 if (resource->resourceRequest().requestContext() == blink::WebURLRequest::Re questContextFetch) {
259 m_client->didFailRedirectCheck(); 265 m_client->didFailRedirectCheck();
266
267 clearResource();
260 request = ResourceRequest(); 268 request = ResourceRequest();
269
261 return; 270 return;
262 } 271 }
263 272
264 if (!isAllowedByContentSecurityPolicy(request.url())) { 273 if (!isAllowedByContentSecurityPolicy(request.url())) {
265 m_client->didFailRedirectCheck(); 274 m_client->didFailRedirectCheck();
275
276 clearResource();
266 request = ResourceRequest(); 277 request = ResourceRequest();
278
267 m_requestStartedSeconds = 0.0; 279 m_requestStartedSeconds = 0.0;
268 return; 280 return;
269 } 281 }
270 282
271 // Allow same origin requests to continue after allowing clients to audit th e redirect. 283 // Allow same origin requests to continue after allowing clients to audit th e redirect.
272 if (isAllowedRedirect(request.url())) { 284 if (isAllowedRedirect(request.url())) {
273 if (m_client->isDocumentThreadableLoaderClient()) 285 if (m_client->isDocumentThreadableLoaderClient())
274 static_cast<DocumentThreadableLoaderClient*>(m_client)->willFollowRe direct(request, redirectResponse); 286 static_cast<DocumentThreadableLoaderClient*>(m_client)->willFollowRe direct(request, redirectResponse);
275 return; 287 return;
276 } 288 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 335 }
324 makeCrossOriginAccessRequest(request); 336 makeCrossOriginAccessRequest(request);
325 return; 337 return;
326 } 338 }
327 339
328 ResourceError error(errorDomainBlinkInternal, 0, redirectResponse.url(). string(), accessControlErrorDescription); 340 ResourceError error(errorDomainBlinkInternal, 0, redirectResponse.url(). string(), accessControlErrorDescription);
329 m_client->didFailAccessControlCheck(error); 341 m_client->didFailAccessControlCheck(error);
330 } else { 342 } else {
331 m_client->didFailRedirectCheck(); 343 m_client->didFailRedirectCheck();
332 } 344 }
345
346 clearResource();
333 request = ResourceRequest(); 347 request = ResourceRequest();
348
334 m_requestStartedSeconds = 0.0; 349 m_requestStartedSeconds = 0.0;
335 } 350 }
336 351
337 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b ytesSent, unsigned long long totalBytesToBeSent) 352 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b ytesSent, unsigned long long totalBytesToBeSent)
338 { 353 {
339 ASSERT(m_client); 354 ASSERT(m_client);
340 ASSERT_UNUSED(resource, resource == this->resource()); 355 ASSERT_UNUSED(resource, resource == this->resource());
341 ASSERT(m_async); 356 ASSERT(m_async);
342 357
343 m_client->didSendData(bytesSent, totalBytesToBeSent); 358 m_client->didSendData(bytesSent, totalBytesToBeSent);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return DoNotAllowStoredCredentials; 634 return DoNotAllowStoredCredentials;
620 return m_resourceLoaderOptions.allowCredentials; 635 return m_resourceLoaderOptions.allowCredentials;
621 } 636 }
622 637
623 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const 638 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
624 { 639 {
625 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); 640 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin ();
626 } 641 }
627 642
628 } // namespace blink 643 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/AssociatedURLLoaderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698