OLD | NEW |
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 Loading... |
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_options(options), | 316 m_options(options), |
320 m_responseTimestamp(currentTime()), | 317 m_responseTimestamp(currentTime()), |
321 m_cancelTimer(this, &Resource::cancelTimerFired), | 318 m_cancelTimer(this, &Resource::cancelTimerFired), |
322 m_resourceRequest(request) { | 319 m_resourceRequest(request) { |
323 // m_type is a bitfield, so this tests careless updates of the enum. | 320 // m_type is a bitfield, so this tests careless updates of the enum. |
324 DCHECK_EQ(m_type, unsigned(type)); | 321 DCHECK_EQ(m_type, unsigned(type)); |
325 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); | 322 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); |
326 | 323 |
327 // Currently we support the metadata caching only for HTTP family. | 324 // Currently we support the metadata caching only for HTTP family. |
328 if (m_resourceRequest.url().protocolIsInHTTPFamily()) | 325 if (m_resourceRequest.url().protocolIsInHTTPFamily()) |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 securityOrigin, errorDescription, lastResourceRequest().requestContext()); | 441 securityOrigin, errorDescription, lastResourceRequest().requestContext()); |
445 } | 442 } |
446 | 443 |
447 bool Resource::isEligibleForIntegrityCheck( | 444 bool Resource::isEligibleForIntegrityCheck( |
448 SecurityOrigin* securityOrigin) const { | 445 SecurityOrigin* securityOrigin) const { |
449 String ignoredErrorDescription; | 446 String ignoredErrorDescription; |
450 return securityOrigin->canRequest(resourceRequest().url()) || | 447 return securityOrigin->canRequest(resourceRequest().url()) || |
451 passesAccessControlCheck(securityOrigin, ignoredErrorDescription); | 448 passesAccessControlCheck(securityOrigin, ignoredErrorDescription); |
452 } | 449 } |
453 | 450 |
454 void Resource::setIntegrityDisposition( | |
455 ResourceIntegrityDisposition disposition) { | |
456 DCHECK_NE(disposition, ResourceIntegrityDisposition::NotChecked); | |
457 DCHECK(m_type == Resource::Script); | |
458 m_integrityDisposition = disposition; | |
459 } | |
460 | |
461 bool Resource::mustRefetchDueToIntegrityMetadata( | |
462 const FetchRequest& request) const { | |
463 if (request.integrityMetadata().isEmpty()) | |
464 return false; | |
465 | |
466 return !IntegrityMetadata::setsEqual(m_integrityMetadata, | |
467 request.integrityMetadata()); | |
468 } | |
469 | |
470 static double currentAge(const ResourceResponse& response, | 451 static double currentAge(const ResourceResponse& response, |
471 double responseTimestamp) { | 452 double responseTimestamp) { |
472 // RFC2616 13.2.3 | 453 // RFC2616 13.2.3 |
473 // No compensation for latency as that is not terribly important in practice | 454 // No compensation for latency as that is not terribly important in practice |
474 double dateValue = response.date(); | 455 double dateValue = response.date(); |
475 double apparentAge = std::isfinite(dateValue) | 456 double apparentAge = std::isfinite(dateValue) |
476 ? std::max(0., responseTimestamp - dateValue) | 457 ? std::max(0., responseTimestamp - dateValue) |
477 : 0; | 458 : 0; |
478 double ageValue = response.age(); | 459 double ageValue = response.age(); |
479 double correctedReceivedAge = | 460 double correctedReceivedAge = |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1091 case Resource::TextTrack: | 1072 case Resource::TextTrack: |
1092 case Resource::Media: | 1073 case Resource::Media: |
1093 case Resource::Manifest: | 1074 case Resource::Manifest: |
1094 return false; | 1075 return false; |
1095 } | 1076 } |
1096 NOTREACHED(); | 1077 NOTREACHED(); |
1097 return false; | 1078 return false; |
1098 } | 1079 } |
1099 | 1080 |
1100 } // namespace blink | 1081 } // namespace blink |
OLD | NEW |