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

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

Issue 2400723005: Revert 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"
32 #include "core/fetch/MemoryCache.h" 30 #include "core/fetch/MemoryCache.h"
33 #include "core/fetch/ResourceClient.h" 31 #include "core/fetch/ResourceClient.h"
34 #include "core/fetch/ResourceClientWalker.h" 32 #include "core/fetch/ResourceClientWalker.h"
35 #include "core/fetch/ResourceLoader.h" 33 #include "core/fetch/ResourceLoader.h"
36 #include "core/inspector/InstanceCounters.h" 34 #include "core/inspector/InstanceCounters.h"
37 #include "platform/Histogram.h" 35 #include "platform/Histogram.h"
38 #include "platform/RuntimeEnabledFeatures.h" 36 #include "platform/RuntimeEnabledFeatures.h"
39 #include "platform/SharedBuffer.h" 37 #include "platform/SharedBuffer.h"
40 #include "platform/network/HTTPParsers.h" 38 #include "platform/network/HTTPParsers.h"
41 #include "platform/tracing/TraceEvent.h" 39 #include "platform/tracing/TraceEvent.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 m_preloadCount(0), 306 m_preloadCount(0),
309 m_preloadDiscoveryTime(0.0), 307 m_preloadDiscoveryTime(0.0),
310 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()), 308 m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()),
311 m_preloadResult(PreloadNotReferenced), 309 m_preloadResult(PreloadNotReferenced),
312 m_type(type), 310 m_type(type),
313 m_status(NotStarted), 311 m_status(NotStarted),
314 m_needsSynchronousCacheHit(false), 312 m_needsSynchronousCacheHit(false),
315 m_linkPreload(false), 313 m_linkPreload(false),
316 m_isRevalidating(false), 314 m_isRevalidating(false),
317 m_isAlive(false), 315 m_isAlive(false),
318 m_integrityDisposition(ResourceIntegrityDisposition::NotChecked),
319 m_isAddRemoveClientProhibited(false), 316 m_isAddRemoveClientProhibited(false),
320 m_options(options), 317 m_options(options),
321 m_responseTimestamp(currentTime()), 318 m_responseTimestamp(currentTime()),
322 m_cancelTimer(this, &Resource::cancelTimerFired), 319 m_cancelTimer(this, &Resource::cancelTimerFired),
323 m_resourceRequest(request) { 320 m_resourceRequest(request) {
324 // m_type is a bitfield, so this tests careless updates of the enum. 321 // m_type is a bitfield, so this tests careless updates of the enum.
325 DCHECK_EQ(m_type, unsigned(type)); 322 DCHECK_EQ(m_type, unsigned(type));
326 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); 323 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter);
327 324
328 // Currently we support the metadata caching only for HTTP family. 325 // Currently we support the metadata caching only for HTTP family.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 securityOrigin, errorDescription, lastResourceRequest().requestContext()); 442 securityOrigin, errorDescription, lastResourceRequest().requestContext());
446 } 443 }
447 444
448 bool Resource::isEligibleForIntegrityCheck( 445 bool Resource::isEligibleForIntegrityCheck(
449 SecurityOrigin* securityOrigin) const { 446 SecurityOrigin* securityOrigin) const {
450 String ignoredErrorDescription; 447 String ignoredErrorDescription;
451 return securityOrigin->canRequest(resourceRequest().url()) || 448 return securityOrigin->canRequest(resourceRequest().url()) ||
452 passesAccessControlCheck(securityOrigin, ignoredErrorDescription); 449 passesAccessControlCheck(securityOrigin, ignoredErrorDescription);
453 } 450 }
454 451
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
471 static double currentAge(const ResourceResponse& response, 452 static double currentAge(const ResourceResponse& response,
472 double responseTimestamp) { 453 double responseTimestamp) {
473 // RFC2616 13.2.3 454 // RFC2616 13.2.3
474 // No compensation for latency as that is not terribly important in practice 455 // No compensation for latency as that is not terribly important in practice
475 double dateValue = response.date(); 456 double dateValue = response.date();
476 double apparentAge = std::isfinite(dateValue) 457 double apparentAge = std::isfinite(dateValue)
477 ? std::max(0., responseTimestamp - dateValue) 458 ? std::max(0., responseTimestamp - dateValue)
478 : 0; 459 : 0;
479 double ageValue = response.age(); 460 double ageValue = response.age();
480 double correctedReceivedAge = 461 double correctedReceivedAge =
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 case Resource::TextTrack: 1078 case Resource::TextTrack:
1098 case Resource::Media: 1079 case Resource::Media:
1099 case Resource::Manifest: 1080 case Resource::Manifest:
1100 return false; 1081 return false;
1101 } 1082 }
1102 NOTREACHED(); 1083 NOTREACHED();
1103 return false; 1084 return false;
1104 } 1085 }
1105 1086
1106 } // namespace blink 1087 } // 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