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

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

Issue 2398733005: Reland of Cache SubResourceIntegrity checks at Resource (patchset #2 id:20001 of https://codereview… (Closed)
Patch Set: 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) 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 6 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All
7 rights reserved. 7 rights reserved.
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
11 License as published by the Free Software Foundation; either 11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version. 12 version 2 of the License, or (at your option) any later version.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. 22 Boston, MA 02110-1301, USA.
23 */ 23 */
24 24
25 #include "core/fetch/Resource.h" 25 #include "core/fetch/Resource.h"
26 26
27 #include "core/fetch/CachedMetadata.h" 27 #include "core/fetch/CachedMetadata.h"
28 #include "core/fetch/CrossOriginAccessControl.h" 28 #include "core/fetch/CrossOriginAccessControl.h"
29 #include "core/fetch/FetchInitiatorTypeNames.h" 29 #include "core/fetch/FetchInitiatorTypeNames.h"
30 #include "core/fetch/FetchRequest.h"
31 #include "core/fetch/IntegrityMetadata.h"
30 #include "core/fetch/MemoryCache.h" 32 #include "core/fetch/MemoryCache.h"
31 #include "core/fetch/ResourceClient.h" 33 #include "core/fetch/ResourceClient.h"
32 #include "core/fetch/ResourceClientWalker.h" 34 #include "core/fetch/ResourceClientWalker.h"
33 #include "core/fetch/ResourceLoader.h" 35 #include "core/fetch/ResourceLoader.h"
34 #include "core/inspector/InstanceCounters.h" 36 #include "core/inspector/InstanceCounters.h"
35 #include "platform/Histogram.h" 37 #include "platform/Histogram.h"
36 #include "platform/RuntimeEnabledFeatures.h" 38 #include "platform/RuntimeEnabledFeatures.h"
37 #include "platform/SharedBuffer.h" 39 #include "platform/SharedBuffer.h"
38 #include "platform/network/HTTPParsers.h" 40 #include "platform/network/HTTPParsers.h"
39 #include "platform/tracing/TraceEvent.h" 41 #include "platform/tracing/TraceEvent.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 m_preloadCount(0), 308 m_preloadCount(0),
307 m_preloadDiscoveryTime(0.0), 309 m_preloadDiscoveryTime(0.0),
308 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), 310 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()),
309 m_preloadResult(PreloadNotReferenced), 311 m_preloadResult(PreloadNotReferenced),
310 m_type(type), 312 m_type(type),
311 m_status(NotStarted), 313 m_status(NotStarted),
312 m_needsSynchronousCacheHit(false), 314 m_needsSynchronousCacheHit(false),
313 m_linkPreload(false), 315 m_linkPreload(false),
314 m_isRevalidating(false), 316 m_isRevalidating(false),
315 m_isAlive(false), 317 m_isAlive(false),
318 m_integrityDisposition(ResourceIntegrityDisposition::NotChecked),
316 m_isAddRemoveClientProhibited(false), 319 m_isAddRemoveClientProhibited(false),
317 m_options(options), 320 m_options(options),
318 m_responseTimestamp(currentTime()), 321 m_responseTimestamp(currentTime()),
319 m_cancelTimer(this, &Resource::cancelTimerFired), 322 m_cancelTimer(this, &Resource::cancelTimerFired),
320 m_resourceRequest(request) { 323 m_resourceRequest(request) {
321 // m_type is a bitfield, so this tests careless updates of the enum. 324 // m_type is a bitfield, so this tests careless updates of the enum.
322 DCHECK_EQ(m_type, unsigned(type)); 325 DCHECK_EQ(m_type, unsigned(type));
323 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); 326 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter);
324 327
325 // Currently we support the metadata caching only for HTTP family. 328 // Currently we support the metadata caching only for HTTP family.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 securityOrigin, errorDescription, lastResourceRequest().requestContext()); 445 securityOrigin, errorDescription, lastResourceRequest().requestContext());
443 } 446 }
444 447
445 bool Resource::isEligibleForIntegrityCheck( 448 bool Resource::isEligibleForIntegrityCheck(
446 SecurityOrigin* securityOrigin) const { 449 SecurityOrigin* securityOrigin) const {
447 String ignoredErrorDescription; 450 String ignoredErrorDescription;
448 return securityOrigin->canRequest(resourceRequest().url()) || 451 return securityOrigin->canRequest(resourceRequest().url()) ||
449 passesAccessControlCheck(securityOrigin, ignoredErrorDescription); 452 passesAccessControlCheck(securityOrigin, ignoredErrorDescription);
450 } 453 }
451 454
455 void Resource::setIntegrityDisposition(
456 ResourceIntegrityDisposition disposition) {
457 DCHECK_NE(disposition, ResourceIntegrityDisposition::NotChecked);
458 DCHECK(m_type == Resource::Script);
459 m_integrityDisposition = disposition;
460 }
461
462 bool Resource::mustRefetchDueToIntegrityMetadata(
463 const FetchRequest& request) const {
464 if (request.integrityMetadata().isEmpty())
465 return false;
466
467 return !IntegrityMetadata::setsEqual(m_integrityMetadata,
468 request.integrityMetadata());
469 }
470
452 static double currentAge(const ResourceResponse& response, 471 static double currentAge(const ResourceResponse& response,
453 double responseTimestamp) { 472 double responseTimestamp) {
454 // RFC2616 13.2.3 473 // RFC2616 13.2.3
455 // No compensation for latency as that is not terribly important in practice 474 // No compensation for latency as that is not terribly important in practice
456 double dateValue = response.date(); 475 double dateValue = response.date();
457 double apparentAge = std::isfinite(dateValue) 476 double apparentAge = std::isfinite(dateValue)
458 ? std::max(0., responseTimestamp - dateValue) 477 ? std::max(0., responseTimestamp - dateValue)
459 : 0; 478 : 0;
460 double ageValue = response.age(); 479 double ageValue = response.age();
461 double correctedReceivedAge = 480 double correctedReceivedAge =
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 case Resource::TextTrack: 1097 case Resource::TextTrack:
1079 case Resource::Media: 1098 case Resource::Media:
1080 case Resource::Manifest: 1099 case Resource::Manifest:
1081 return false; 1100 return false;
1082 } 1101 }
1083 NOTREACHED(); 1102 NOTREACHED();
1084 return false; 1103 return false;
1085 } 1104 }
1086 1105
1087 } // namespace blink 1106 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.h ('k') | third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698