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

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.cpp

Issue 2829043002: Move |is_static_data| check down in DetermineRevalidationPolicy (Closed)
Patch Set: rebase Created 3 years, 8 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
« no previous file with comments | « no previous file | no next file » | 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) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
6 rights reserved. 6 rights reserved.
7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 7 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 893
894 // Never reuse opaque responses from a service worker for requests that are 894 // Never reuse opaque responses from a service worker for requests that are
895 // not no-cors. https://crbug.com/625575 895 // not no-cors. https://crbug.com/625575
896 if (existing_resource->GetResponse().WasFetchedViaServiceWorker() && 896 if (existing_resource->GetResponse().WasFetchedViaServiceWorker() &&
897 existing_resource->GetResponse().ServiceWorkerResponseType() == 897 existing_resource->GetResponse().ServiceWorkerResponseType() ==
898 kWebServiceWorkerResponseTypeOpaque && 898 kWebServiceWorkerResponseTypeOpaque &&
899 request.GetFetchRequestMode() != WebURLRequest::kFetchRequestModeNoCORS) { 899 request.GetFetchRequestMode() != WebURLRequest::kFetchRequestModeNoCORS) {
900 return kReload; 900 return kReload;
901 } 901 }
902 902
903 // If resource was populated from a SubstituteData load or data: url, use it. 903 if (!is_static_data && !existing_resource->CanReuse(fetch_params))
904 if (is_static_data)
905 return kUse;
906
907 if (!existing_resource->CanReuse(fetch_params))
908 return kReload; 904 return kReload;
909 905
910 // Certain requests (e.g., XHRs) might have manually set headers that require 906 // Certain requests (e.g., XHRs) might have manually set headers that require
911 // revalidation. In theory, this should be a Revalidate case. In practice, the 907 // revalidation. In theory, this should be a Revalidate case. In practice, the
912 // MemoryCache revalidation path assumes a whole bunch of things about how 908 // MemoryCache revalidation path assumes a whole bunch of things about how
913 // revalidation works that manual headers violate, so punt to Reload instead. 909 // revalidation works that manual headers violate, so punt to Reload instead.
914 // 910 //
915 // Similarly, a request with manually added revalidation headers can lead to a 911 // Similarly, a request with manually added revalidation headers can lead to a
916 // 304 response for a request that wasn't flagged as a revalidation attempt. 912 // 304 response for a request that wasn't flagged as a revalidation attempt.
917 // Normally, successful revalidation will maintain the original response's 913 // Normally, successful revalidation will maintain the original response's
918 // status code, but for a manual revalidation the response code remains 304. 914 // status code, but for a manual revalidation the response code remains 304.
919 // In this case, the Resource likely has insufficient context to provide a 915 // In this case, the Resource likely has insufficient context to provide a
920 // useful cache hit or revalidation. See http://crbug.com/643659 916 // useful cache hit or revalidation. See http://crbug.com/643659
921 if (request.IsConditional() || 917 if (!is_static_data &&
922 existing_resource->GetResponse().HttpStatusCode() == 304) { 918 (request.IsConditional() ||
919 existing_resource->GetResponse().HttpStatusCode() == 304)) {
923 return kReload; 920 return kReload;
924 } 921 }
925 922
926 if (!fetch_params.Options().CanReuseRequest(existing_resource->Options())) 923 if (!is_static_data &&
924 !fetch_params.Options().CanReuseRequest(existing_resource->Options())) {
927 return kReload; 925 return kReload;
926 }
928 927
929 // Always use preloads. 928 // Always use preloads.
930 if (existing_resource->IsPreloaded()) 929 if (existing_resource->IsPreloaded())
931 return kUse; 930 return kUse;
932 931
932 // If resource was populated from a SubstituteData load or data: url, use it.
933 if (is_static_data)
934 return kUse;
935
933 // Don't reload resources while pasting. 936 // Don't reload resources while pasting.
934 if (allow_stale_resources_) 937 if (allow_stale_resources_)
935 return kUse; 938 return kUse;
936 939
937 // WebCachePolicy::ReturnCacheDataElseLoad uses the cache no matter what. 940 // WebCachePolicy::ReturnCacheDataElseLoad uses the cache no matter what.
938 if (request.GetCachePolicy() == WebCachePolicy::kReturnCacheDataElseLoad) 941 if (request.GetCachePolicy() == WebCachePolicy::kReturnCacheDataElseLoad)
939 return kUse; 942 return kUse;
940 943
941 // Don't reuse resources with Cache-control: no-store. 944 // Don't reuse resources with Cache-control: no-store.
942 if (existing_resource->HasCacheControlNoStoreHeader()) { 945 if (existing_resource->HasCacheControlNoStoreHeader()) {
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 visitor->Trace(context_); 1565 visitor->Trace(context_);
1563 visitor->Trace(archive_); 1566 visitor->Trace(archive_);
1564 visitor->Trace(loaders_); 1567 visitor->Trace(loaders_);
1565 visitor->Trace(non_blocking_loaders_); 1568 visitor->Trace(non_blocking_loaders_);
1566 visitor->Trace(document_resources_); 1569 visitor->Trace(document_resources_);
1567 visitor->Trace(preloads_); 1570 visitor->Trace(preloads_);
1568 visitor->Trace(resource_timing_info_map_); 1571 visitor->Trace(resource_timing_info_map_);
1569 } 1572 }
1570 1573
1571 } // namespace blink 1574 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698