| 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // request to the SW. https://crbug.com/604583 | 386 // request to the SW. https://crbug.com/604583 |
| 387 // Similarly we don't want any requests that could involve a CORS preflight | 387 // Similarly we don't want any requests that could involve a CORS preflight |
| 388 // to get intercepted by a foreign fetch service worker, even if we have the | 388 // to get intercepted by a foreign fetch service worker, even if we have the |
| 389 // result of the preflight cached already. https://crbug.com/674370 | 389 // result of the preflight cached already. https://crbug.com/674370 |
| 390 cross_origin_request.SetServiceWorkerMode( | 390 cross_origin_request.SetServiceWorkerMode( |
| 391 WebURLRequest::ServiceWorkerMode::kNone); | 391 WebURLRequest::ServiceWorkerMode::kNone); |
| 392 | 392 |
| 393 bool should_force_preflight = request.IsExternalRequest(); | 393 bool should_force_preflight = request.IsExternalRequest(); |
| 394 if (!should_force_preflight) | 394 if (!should_force_preflight) |
| 395 probe::shouldForceCORSPreflight(GetDocument(), &should_force_preflight); | 395 probe::shouldForceCORSPreflight(GetDocument(), &should_force_preflight); |
| 396 // TODO(horo): Move CrossOriginPreflightResultCache to |
| 397 // ThreadableLoadingContext |
| 396 bool can_skip_preflight = | 398 bool can_skip_preflight = |
| 399 IsMainThread() && |
| 397 CrossOriginPreflightResultCache::Shared().CanSkipPreflight( | 400 CrossOriginPreflightResultCache::Shared().CanSkipPreflight( |
| 398 GetSecurityOrigin()->ToString(), cross_origin_request.Url(), | 401 GetSecurityOrigin()->ToString(), cross_origin_request.Url(), |
| 399 EffectiveAllowCredentials(), cross_origin_request.HttpMethod(), | 402 EffectiveAllowCredentials(), cross_origin_request.HttpMethod(), |
| 400 cross_origin_request.HttpHeaderFields()); | 403 cross_origin_request.HttpHeaderFields()); |
| 401 if (can_skip_preflight && !should_force_preflight) { | 404 if (can_skip_preflight && !should_force_preflight) { |
| 402 PrepareCrossOriginRequest(cross_origin_request); | 405 PrepareCrossOriginRequest(cross_origin_request); |
| 403 LoadRequest(cross_origin_request, cross_origin_options); | 406 LoadRequest(cross_origin_request, cross_origin_options); |
| 404 } else { | 407 } else { |
| 405 ResourceRequest preflight_request = | 408 ResourceRequest preflight_request = |
| 406 CreateAccessControlPreflightRequest(cross_origin_request); | 409 CreateAccessControlPreflightRequest(cross_origin_request); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 !preflight_result->AllowsCrossOriginMethod( | 765 !preflight_result->AllowsCrossOriginMethod( |
| 763 actual_request_.HttpMethod(), access_control_error_description) || | 766 actual_request_.HttpMethod(), access_control_error_description) || |
| 764 !preflight_result->AllowsCrossOriginHeaders( | 767 !preflight_result->AllowsCrossOriginHeaders( |
| 765 actual_request_.HttpHeaderFields(), | 768 actual_request_.HttpHeaderFields(), |
| 766 access_control_error_description)) { | 769 access_control_error_description)) { |
| 767 HandlePreflightFailure(response.Url().GetString(), | 770 HandlePreflightFailure(response.Url().GetString(), |
| 768 access_control_error_description); | 771 access_control_error_description); |
| 769 return; | 772 return; |
| 770 } | 773 } |
| 771 | 774 |
| 772 CrossOriginPreflightResultCache::Shared().AppendEntry( | 775 if (IsMainThread()) { |
| 773 GetSecurityOrigin()->ToString(), actual_request_.Url(), | 776 // TODO(horo): Move CrossOriginPreflightResultCache to |
| 774 std::move(preflight_result)); | 777 // ThreadableLoadingContext |
| 778 CrossOriginPreflightResultCache::Shared().AppendEntry( |
| 779 GetSecurityOrigin()->ToString(), actual_request_.Url(), |
| 780 std::move(preflight_result)); |
| 781 } |
| 775 } | 782 } |
| 776 | 783 |
| 777 void DocumentThreadableLoader::ReportResponseReceived( | 784 void DocumentThreadableLoader::ReportResponseReceived( |
| 778 unsigned long identifier, | 785 unsigned long identifier, |
| 779 const ResourceResponse& response) { | 786 const ResourceResponse& response) { |
| 780 LocalFrame* frame = GetDocument() ? GetDocument()->GetFrame() : nullptr; | 787 LocalFrame* frame = GetDocument() ? GetDocument()->GetFrame() : nullptr; |
| 781 if (!frame) | 788 if (!frame) |
| 782 return; | 789 return; |
| 783 DocumentLoader* loader = frame->Loader().GetDocumentLoader(); | 790 DocumentLoader* loader = frame->Loader().GetDocumentLoader(); |
| 784 probe::didReceiveResourceResponse(frame, identifier, loader, response, | 791 probe::didReceiveResourceResponse(GetDocument(), identifier, loader, response, |
| 785 GetResource()); | 792 GetResource()); |
| 786 frame->Console().ReportResourceResponseReceived(loader, identifier, response); | 793 frame->Console().ReportResourceResponseReceived(loader, identifier, response); |
| 787 } | 794 } |
| 788 | 795 |
| 789 void DocumentThreadableLoader::HandleResponse( | 796 void DocumentThreadableLoader::HandleResponse( |
| 790 unsigned long identifier, | 797 unsigned long identifier, |
| 791 const ResourceResponse& response, | 798 const ResourceResponse& response, |
| 792 std::unique_ptr<WebDataConsumerHandle> handle) { | 799 std::unique_ptr<WebDataConsumerHandle> handle) { |
| 793 DCHECK(client_); | 800 DCHECK(client_); |
| 794 | 801 |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 } | 1163 } |
| 1157 | 1164 |
| 1158 DEFINE_TRACE(DocumentThreadableLoader) { | 1165 DEFINE_TRACE(DocumentThreadableLoader) { |
| 1159 visitor->Trace(resource_); | 1166 visitor->Trace(resource_); |
| 1160 visitor->Trace(loading_context_); | 1167 visitor->Trace(loading_context_); |
| 1161 ThreadableLoader::Trace(visitor); | 1168 ThreadableLoader::Trace(visitor); |
| 1162 RawResourceClient::Trace(visitor); | 1169 RawResourceClient::Trace(visitor); |
| 1163 } | 1170 } |
| 1164 | 1171 |
| 1165 } // namespace blink | 1172 } // namespace blink |
| OLD | NEW |