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

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

Issue 2398733003: Cache SubResourceIntegrity checks at Resource (Closed)
Patch Set: add include Created 4 years, 2 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
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 758 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 ResourceFetcher::determineRevalidationPolicy(Resource::Type type, 769 ResourceFetcher::determineRevalidationPolicy(Resource::Type type,
770 const FetchRequest& fetchRequest, 770 const FetchRequest& fetchRequest,
771 Resource* existingResource, 771 Resource* existingResource,
772 bool isStaticData) const { 772 bool isStaticData) const {
773 const ResourceRequest& request = fetchRequest.resourceRequest(); 773 const ResourceRequest& request = fetchRequest.resourceRequest();
774 774
775 if (!existingResource) 775 if (!existingResource)
776 return Load; 776 return Load;
777 777
778 // Checks if the resource has an explicit policy about integrity metadata. 778 // Checks if the resource has an explicit policy about integrity metadata.
779 // Currently only applies to ScriptResources.
780 // 779 //
781 // This is necessary because ScriptResource objects do not keep the raw data 780 // This is necessary because ScriptResource and CSSStyleSheetResource objects
782 // around after the source is accessed once, so if the resource is accessed 781 // do not keep the raw data around after the source is accessed once, so if
783 // from the MemoryCache for a second time, there is no way to redo an 782 // the resource is accessed from the MemoryCache for a second time, there is
784 // integrity check. 783 // no way to redo an integrity check.
785 // 784 //
786 // Thus, Blink implements a scheme where it caches the integrity information 785 // Thus, Blink implements a scheme where it caches the integrity information
787 // for a ScriptResource after the first time it is checked, and if there is 786 // for those resources after the first time it is checked, and if there is
788 // another request for that resource, with the same integrity metadata, Blink 787 // another request for that resource, with the same integrity metadata, Blink
789 // skips the integrity calculation. However, if the integrity metadata is a 788 // skips the integrity calculation. However, if the integrity metadata is a
790 // mismatch, the MemoryCache must be skipped here, and a new request for the 789 // mismatch, the MemoryCache must be skipped here, and a new request for the
791 // resource must be made to get the raw data. This is expected to be an 790 // resource must be made to get the raw data. This is expected to be an
792 // uncommon case, however, as it implies two same-origin requests to the same 791 // uncommon case, however, as it implies two same-origin requests to the same
793 // resource, but with different integrity metadata. 792 // resource, but with different integrity metadata.
794 RecordSriResourceIntegrityMismatchEvent(CheckingForIntegrityMismatch); 793 RecordSriResourceIntegrityMismatchEvent(CheckingForIntegrityMismatch);
795 if (existingResource->mustRefetchDueToIntegrityMetadata(fetchRequest)) { 794 if (existingResource->mustRefetchDueToIntegrityMetadata(fetchRequest)) {
796 RecordSriResourceIntegrityMismatchEvent(RefetchDueToIntegrityMismatch); 795 RecordSriResourceIntegrityMismatchEvent(RefetchDueToIntegrityMismatch);
797 return Reload; 796 return Reload;
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 visitor->trace(m_context); 1603 visitor->trace(m_context);
1605 visitor->trace(m_archive); 1604 visitor->trace(m_archive);
1606 visitor->trace(m_loaders); 1605 visitor->trace(m_loaders);
1607 visitor->trace(m_nonBlockingLoaders); 1606 visitor->trace(m_nonBlockingLoaders);
1608 visitor->trace(m_documentResources); 1607 visitor->trace(m_documentResources);
1609 visitor->trace(m_preloads); 1608 visitor->trace(m_preloads);
1610 visitor->trace(m_resourceTimingInfoMap); 1609 visitor->trace(m_resourceTimingInfoMap);
1611 } 1610 }
1612 1611
1613 } // namespace blink 1612 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.cpp ('k') | third_party/WebKit/Source/core/fetch/ScriptResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698