Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 m_client = 0; | 229 m_client = 0; |
| 230 m_requestStartedSeconds = 0.0; | 230 m_requestStartedSeconds = 0.0; |
| 231 } | 231 } |
| 232 | 232 |
| 233 void DocumentThreadableLoader::setDefersLoading(bool value) | 233 void DocumentThreadableLoader::setDefersLoading(bool value) |
| 234 { | 234 { |
| 235 if (resource()) | 235 if (resource()) |
| 236 resource()->setDefersLoading(value); | 236 resource()->setDefersLoading(value); |
| 237 } | 237 } |
| 238 | 238 |
| 239 // In this method, we can clear |request| to tell content::WebURLLoaderImpl of | |
| 240 // Chromium not to follow the redirect. This works only when this method is | |
| 241 // called by RawResource::willSendRequest(). If called by | |
| 242 // RawResource::didAddClient(), clearing |request| won't be propagated | |
| 243 // to content::WebURLLoaderImpl. So, this loader must also get detached from | |
| 244 // the resource by calling clearResource(). | |
| 239 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse) | 245 void DocumentThreadableLoader::redirectReceived(Resource* resource, ResourceRequ est& request, const ResourceResponse& redirectResponse) |
| 240 { | 246 { |
| 241 ASSERT(m_client); | 247 ASSERT(m_client); |
| 242 ASSERT_UNUSED(resource, resource == this->resource()); | 248 ASSERT_UNUSED(resource, resource == this->resource()); |
| 243 | 249 |
| 244 RefPtr<DocumentThreadableLoader> protect(this); | 250 RefPtr<DocumentThreadableLoader> protect(this); |
| 245 | 251 |
| 246 // FIXME: Support redirect in Fetch API. | 252 // FIXME: Support redirect in Fetch API. |
| 247 if (resource->resourceRequest().requestContext() == blink::WebURLRequest::Re questContextFetch) { | 253 if (resource->resourceRequest().requestContext() == blink::WebURLRequest::Re questContextFetch) { |
| 248 m_client->didFailRedirectCheck(); | 254 m_client->didFailRedirectCheck(); |
| 255 | |
| 256 clearResource(); | |
|
Nate Chapin
2014/10/24 17:09:31
If we call clearResource(), can we get ride of cle
tyoshino (SeeGerritForStatus)
2014/10/27 09:04:08
If the resource has only one client (this loader),
Nate Chapin
2014/10/29 23:37:25
I think it's probably ok to let the request contin
tyoshino (SeeGerritForStatus)
2014/11/05 13:36:09
canReuseRequest() currently check only corsEnabled
| |
| 249 request = ResourceRequest(); | 257 request = ResourceRequest(); |
| 258 | |
| 250 return; | 259 return; |
| 251 } | 260 } |
| 252 | 261 |
| 253 if (!isAllowedByPolicy(request.url())) { | 262 if (!isAllowedByPolicy(request.url())) { |
| 254 m_client->didFailRedirectCheck(); | 263 m_client->didFailRedirectCheck(); |
| 264 | |
| 265 clearResource(); | |
| 255 request = ResourceRequest(); | 266 request = ResourceRequest(); |
| 267 | |
| 256 m_requestStartedSeconds = 0.0; | 268 m_requestStartedSeconds = 0.0; |
| 257 return; | 269 return; |
| 258 } | 270 } |
| 259 | 271 |
| 260 // Allow same origin requests to continue after allowing clients to audit th e redirect. | 272 // Allow same origin requests to continue after allowing clients to audit th e redirect. |
| 261 if (isAllowedRedirect(request.url())) { | 273 if (isAllowedRedirect(request.url())) { |
| 262 if (m_client->isDocumentThreadableLoaderClient()) | 274 if (m_client->isDocumentThreadableLoaderClient()) |
| 263 static_cast<DocumentThreadableLoaderClient*>(m_client)->willSendRequ est(request, redirectResponse); | 275 static_cast<DocumentThreadableLoaderClient*>(m_client)->willSendRequ est(request, redirectResponse); |
| 264 return; | 276 return; |
| 265 } | 277 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 312 } | 324 } |
| 313 makeCrossOriginAccessRequest(request); | 325 makeCrossOriginAccessRequest(request); |
| 314 return; | 326 return; |
| 315 } | 327 } |
| 316 | 328 |
| 317 ResourceError error(errorDomainBlinkInternal, 0, redirectResponse.url(). string(), accessControlErrorDescription); | 329 ResourceError error(errorDomainBlinkInternal, 0, redirectResponse.url(). string(), accessControlErrorDescription); |
| 318 m_client->didFailAccessControlCheck(error); | 330 m_client->didFailAccessControlCheck(error); |
| 319 } else { | 331 } else { |
| 320 m_client->didFailRedirectCheck(); | 332 m_client->didFailRedirectCheck(); |
| 321 } | 333 } |
| 334 | |
| 335 clearResource(); | |
| 322 request = ResourceRequest(); | 336 request = ResourceRequest(); |
| 337 | |
| 323 m_requestStartedSeconds = 0.0; | 338 m_requestStartedSeconds = 0.0; |
| 324 } | 339 } |
| 325 | 340 |
| 326 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b ytesSent, unsigned long long totalBytesToBeSent) | 341 void DocumentThreadableLoader::dataSent(Resource* resource, unsigned long long b ytesSent, unsigned long long totalBytesToBeSent) |
| 327 { | 342 { |
| 328 ASSERT(m_client); | 343 ASSERT(m_client); |
| 329 ASSERT_UNUSED(resource, resource == this->resource()); | 344 ASSERT_UNUSED(resource, resource == this->resource()); |
| 330 m_client->didSendData(bytesSent, totalBytesToBeSent); | 345 m_client->didSendData(bytesSent, totalBytesToBeSent); |
| 331 } | 346 } |
| 332 | 347 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 return DoNotAllowStoredCredentials; | 611 return DoNotAllowStoredCredentials; |
| 597 return m_resourceLoaderOptions.allowCredentials; | 612 return m_resourceLoaderOptions.allowCredentials; |
| 598 } | 613 } |
| 599 | 614 |
| 600 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const | 615 SecurityOrigin* DocumentThreadableLoader::securityOrigin() const |
| 601 { | 616 { |
| 602 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); | 617 return m_securityOrigin ? m_securityOrigin.get() : m_document.securityOrigin (); |
| 603 } | 618 } |
| 604 | 619 |
| 605 } // namespace blink | 620 } // namespace blink |
| OLD | NEW |