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
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 21 matching lines...) Expand all Loading... |
32 #include "core/fetch/ResourceLoader.h" | 32 #include "core/fetch/ResourceLoader.h" |
33 #include "core/inspector/InstanceCounters.h" | 33 #include "core/inspector/InstanceCounters.h" |
34 #include "platform/Histogram.h" | 34 #include "platform/Histogram.h" |
35 #include "platform/Logging.h" | 35 #include "platform/Logging.h" |
36 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
37 #include "platform/SharedBuffer.h" | 37 #include "platform/SharedBuffer.h" |
38 #include "platform/TraceEvent.h" | 38 #include "platform/TraceEvent.h" |
39 #include "platform/network/HTTPParsers.h" | 39 #include "platform/network/HTTPParsers.h" |
40 #include "platform/weborigin/KURL.h" | 40 #include "platform/weborigin/KURL.h" |
41 #include "public/platform/Platform.h" | 41 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebCachePolicy.h" |
42 #include "public/platform/WebScheduler.h" | 43 #include "public/platform/WebScheduler.h" |
43 #include "public/platform/WebSecurityOrigin.h" | 44 #include "public/platform/WebSecurityOrigin.h" |
44 #include "wtf/CurrentTime.h" | 45 #include "wtf/CurrentTime.h" |
45 #include "wtf/MathExtras.h" | 46 #include "wtf/MathExtras.h" |
46 #include "wtf/StdLibExtras.h" | 47 #include "wtf/StdLibExtras.h" |
47 #include "wtf/Vector.h" | 48 #include "wtf/Vector.h" |
48 #include "wtf/text/CString.h" | 49 #include "wtf/text/CString.h" |
49 #include "wtf/text/StringBuilder.h" | 50 #include "wtf/text/StringBuilder.h" |
50 #include <algorithm> | 51 #include <algorithm> |
51 #include <memory> | 52 #include <memory> |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 HeapVector<Member<Resource>> resources; | 288 HeapVector<Member<Resource>> resources; |
288 for (const Member<Resource>& resource : m_resourcesWithPendingClients) | 289 for (const Member<Resource>& resource : m_resourcesWithPendingClients) |
289 resources.append(resource.get()); | 290 resources.append(resource.get()); |
290 m_resourcesWithPendingClients.clear(); | 291 m_resourcesWithPendingClients.clear(); |
291 | 292 |
292 for (const auto& resource : resources) | 293 for (const auto& resource : resources) |
293 resource->finishPendingClients(); | 294 resource->finishPendingClients(); |
294 } | 295 } |
295 | 296 |
296 Resource::Resource(const ResourceRequest& request, Type type, const ResourceLoad
erOptions& options) | 297 Resource::Resource(const ResourceRequest& request, Type type, const ResourceLoad
erOptions& options) |
297 : m_resourceRequest(request) | 298 : m_loadFinishTime(0) |
298 , m_loadFinishTime(0) | |
299 , m_identifier(0) | 299 , m_identifier(0) |
300 , m_encodedSize(0) | 300 , m_encodedSize(0) |
301 , m_decodedSize(0) | 301 , m_decodedSize(0) |
302 , m_overheadSize(calculateOverheadSize()) | 302 , m_overheadSize(calculateOverheadSize()) |
303 , m_preloadCount(0) | 303 , m_preloadCount(0) |
304 , m_preloadDiscoveryTime(0.0) | 304 , m_preloadDiscoveryTime(0.0) |
305 , m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()) | 305 , m_cacheIdentifier(MemoryCache::defaultCacheIdentifier()) |
306 , m_preloadResult(PreloadNotReferenced) | 306 , m_preloadResult(PreloadNotReferenced) |
307 , m_type(type) | 307 , m_type(type) |
308 , m_status(NotStarted) | 308 , m_status(NotStarted) |
309 , m_needsSynchronousCacheHit(false) | 309 , m_needsSynchronousCacheHit(false) |
310 , m_linkPreload(false) | 310 , m_linkPreload(false) |
311 , m_isRevalidating(false) | 311 , m_isRevalidating(false) |
312 , m_options(options) | 312 , m_options(options) |
313 , m_responseTimestamp(currentTime()) | 313 , m_responseTimestamp(currentTime()) |
314 , m_cancelTimer(this, &Resource::cancelTimerFired) | 314 , m_cancelTimer(this, &Resource::cancelTimerFired) |
| 315 , m_resourceRequest(request) |
315 { | 316 { |
316 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car
eless updates of the enum. | 317 ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests car
eless updates of the enum. |
317 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); | 318 InstanceCounters::incrementCounter(InstanceCounters::ResourceCounter); |
318 | 319 |
319 // Currently we support the metadata caching only for HTTP family. | 320 // Currently we support the metadata caching only for HTTP family. |
320 if (m_resourceRequest.url().protocolIsInHTTPFamily()) | 321 if (m_resourceRequest.url().protocolIsInHTTPFamily()) |
321 m_cacheHandler = CachedMetadataHandlerImpl::create(this); | 322 m_cacheHandler = CachedMetadataHandlerImpl::create(this); |
322 } | 323 } |
323 | 324 |
324 Resource::~Resource() | 325 Resource::~Resource() |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump
(overheadName); | 894 WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump
(overheadName); |
894 overheadDump->addScalar("size", "bytes", overheadSize()); | 895 overheadDump->addScalar("size", "bytes", overheadSize()); |
895 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k
AllocatedObjectPoolName)); | 896 memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::k
AllocatedObjectPoolName)); |
896 } | 897 } |
897 | 898 |
898 String Resource::getMemoryDumpName() const | 899 String Resource::getMemoryDumpName() const |
899 { | 900 { |
900 return String::format("web_cache/%s_resources/%ld", resourceTypeToString(get
Type(), options().initiatorInfo), m_identifier); | 901 return String::format("web_cache/%s_resources/%ld", resourceTypeToString(get
Type(), options().initiatorInfo), m_identifier); |
901 } | 902 } |
902 | 903 |
| 904 void Resource::setCachePolicyBypassingCache() |
| 905 { |
| 906 m_resourceRequest.setCachePolicy(WebCachePolicy::BypassingCache); |
| 907 } |
| 908 |
| 909 void Resource::setLoFiStateOff() |
| 910 { |
| 911 m_resourceRequest.setLoFiState(WebURLRequest::LoFiOff); |
| 912 } |
| 913 |
903 void Resource::revalidationSucceeded(const ResourceResponse& validatingResponse) | 914 void Resource::revalidationSucceeded(const ResourceResponse& validatingResponse) |
904 { | 915 { |
905 SECURITY_CHECK(m_redirectChain.isEmpty()); | 916 SECURITY_CHECK(m_redirectChain.isEmpty()); |
906 SECURITY_CHECK(equalIgnoringFragmentIdentifier(validatingResponse.url(), m_r
esponse.url())); | 917 SECURITY_CHECK(equalIgnoringFragmentIdentifier(validatingResponse.url(), m_r
esponse.url())); |
907 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); | 918 m_response.setResourceLoadTiming(validatingResponse.resourceLoadTiming()); |
908 | 919 |
909 // RFC2616 10.3.5 | 920 // RFC2616 10.3.5 |
910 // Update cached headers from the 304 response | 921 // Update cached headers from the 304 response |
911 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); | 922 const HTTPHeaderMap& newHeaders = validatingResponse.httpHeaderFields(); |
912 for (const auto& header : newHeaders) { | 923 for (const auto& header : newHeaders) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 case Resource::TextTrack: | 1112 case Resource::TextTrack: |
1102 case Resource::Media: | 1113 case Resource::Media: |
1103 case Resource::Manifest: | 1114 case Resource::Manifest: |
1104 return false; | 1115 return false; |
1105 } | 1116 } |
1106 ASSERT_NOT_REACHED(); | 1117 ASSERT_NOT_REACHED(); |
1107 return false; | 1118 return false; |
1108 } | 1119 } |
1109 | 1120 |
1110 } // namespace blink | 1121 } // namespace blink |
OLD | NEW |