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

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

Issue 2046923002: [Loader] Add asserts about revalidation and redirects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 539
540 const ResourceRequest& Resource::lastResourceRequest() const 540 const ResourceRequest& Resource::lastResourceRequest() const
541 { 541 {
542 if (!m_redirectChain.size()) 542 if (!m_redirectChain.size())
543 return m_resourceRequest; 543 return m_resourceRequest;
544 return m_redirectChain.last().m_request; 544 return m_redirectChain.last().m_request;
545 } 545 }
546 546
547 void Resource::setRevalidatingRequest(const ResourceRequest& request) 547 void Resource::setRevalidatingRequest(const ResourceRequest& request)
548 { 548 {
549 SECURITY_CHECK(m_redirectChain.isEmpty());
549 m_revalidatingRequest = request; 550 m_revalidatingRequest = request;
550 m_status = NotStarted; 551 m_status = NotStarted;
551 } 552 }
552 553
553 void Resource::willFollowRedirect(ResourceRequest& newRequest, const ResourceRes ponse& redirectResponse) 554 void Resource::willFollowRedirect(ResourceRequest& newRequest, const ResourceRes ponse& redirectResponse)
554 { 555 {
555 if (!m_revalidatingRequest.isNull()) 556 if (!m_revalidatingRequest.isNull())
556 revalidationFailed(); 557 revalidationFailed();
557 558
558 newRequest.setAllowStoredCredentials(m_options.allowCredentials == AllowStor edCredentials); 559 newRequest.setAllowStoredCredentials(m_options.allowCredentials == AllowStor edCredentials);
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k AllocatedObjectPoolName)); 894 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k AllocatedObjectPoolName));
894 } 895 }
895 896
896 String Resource::getMemoryDumpName() const 897 String Resource::getMemoryDumpName() const
897 { 898 {
898 return String::format("web_cache/%s_resources/%ld", resourceTypeToString(get Type(), options().initiatorInfo), m_identifier); 899 return String::format("web_cache/%s_resources/%ld", resourceTypeToString(get Type(), options().initiatorInfo), m_identifier);
899 } 900 }
900 901
901 void Resource::revalidationSucceeded(const ResourceResponse& validatingResponse) 902 void Resource::revalidationSucceeded(const ResourceResponse& validatingResponse)
902 { 903 {
904 SECURITY_CHECK(m_redirectChain.isEmpty());
905 SECURITY_CHECK(validatingResponse.url() == m_response.url());
903 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); 906 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming());
904 907
905 // RFC2616 10.3.5 908 // RFC2616 10.3.5
906 // Update cached headers from the 304 response 909 // Update cached headers from the 304 response
907 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); 910 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields();
908 for (const auto& header : newHeaders) { 911 for (const auto& header : newHeaders) {
909 // Entity headers should not be sent by servers when generating a 304 912 // Entity headers should not be sent by servers when generating a 304
910 // response; misconfigured servers send them anyway. We shouldn't allow 913 // response; misconfigured servers send them anyway. We shouldn't allow
911 // such headers to update the original request. We'll base this on the 914 // such headers to update the original request. We'll base this on the
912 // list defined by RFC2616 7.1, with a few additions for extension heade rs 915 // list defined by RFC2616 7.1, with a few additions for extension heade rs
913 // we care about. 916 // we care about.
914 if (!shouldUpdateHeaderAfterRevalidation(header.key)) 917 if (!shouldUpdateHeaderAfterRevalidation(header.key))
915 continue; 918 continue;
916 m_response.setHTTPHeaderField(header.key, header.value); 919 m_response.setHTTPHeaderField(header.key, header.value);
917 } 920 }
918 921
919 m_resourceRequest = m_revalidatingRequest; 922 m_resourceRequest = m_revalidatingRequest;
920 m_revalidatingRequest = ResourceRequest(); 923 m_revalidatingRequest = ResourceRequest();
921 } 924 }
922 925
923 void Resource::revalidationFailed() 926 void Resource::revalidationFailed()
924 { 927 {
925 m_resourceRequest = m_revalidatingRequest; 928 m_resourceRequest = m_revalidatingRequest;
926 m_revalidatingRequest = ResourceRequest(); 929 m_revalidatingRequest = ResourceRequest();
927 m_redirectChain.clear(); 930 SECURITY_CHECK(m_redirectChain.isEmpty());
928 m_data.clear(); 931 m_data.clear();
929 m_cacheHandler.clear(); 932 m_cacheHandler.clear();
930 destroyDecodedDataForFailedRevalidation(); 933 destroyDecodedDataForFailedRevalidation();
931 } 934 }
932 935
933 bool Resource::canReuseRedirectChain() 936 bool Resource::canReuseRedirectChain()
934 { 937 {
935 for (auto& redirect : m_redirectChain) { 938 for (auto& redirect : m_redirectChain) {
936 if (!canUseResponse(redirect.m_redirectResponse, m_responseTimestamp)) 939 if (!canUseResponse(redirect.m_redirectResponse, m_responseTimestamp))
937 return false; 940 return false;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 case Resource::Media: 1133 case Resource::Media:
1131 return "Media"; 1134 return "Media";
1132 case Resource::Manifest: 1135 case Resource::Manifest:
1133 return "Manifest"; 1136 return "Manifest";
1134 } 1137 }
1135 ASSERT_NOT_REACHED(); 1138 ASSERT_NOT_REACHED();
1136 return "Unknown"; 1139 return "Unknown";
1137 } 1140 }
1138 1141
1139 } // namespace blink 1142 } // 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