| 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) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All | 4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
| 5 rights reserved. | 5 rights reserved. |
| 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ | 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ |
| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 #ifndef ResourceFetcher_h | 27 #ifndef ResourceFetcher_h |
| 28 #define ResourceFetcher_h | 28 #define ResourceFetcher_h |
| 29 | 29 |
| 30 #include <memory> | 30 #include <memory> |
| 31 #include "platform/PlatformExport.h" | 31 #include "platform/PlatformExport.h" |
| 32 #include "platform/Timer.h" | 32 #include "platform/Timer.h" |
| 33 #include "platform/loader/fetch/FetchContext.h" | 33 #include "platform/loader/fetch/FetchContext.h" |
| 34 #include "platform/loader/fetch/FetchInitiatorInfo.h" | 34 #include "platform/loader/fetch/FetchInitiatorInfo.h" |
| 35 #include "platform/loader/fetch/FetchParameters.h" | 35 #include "platform/loader/fetch/FetchParameters.h" |
| 36 #include "platform/loader/fetch/PreloadKey.h" |
| 36 #include "platform/loader/fetch/Resource.h" | 37 #include "platform/loader/fetch/Resource.h" |
| 37 #include "platform/loader/fetch/ResourceError.h" | 38 #include "platform/loader/fetch/ResourceError.h" |
| 38 #include "platform/loader/fetch/ResourceLoadPriority.h" | 39 #include "platform/loader/fetch/ResourceLoadPriority.h" |
| 39 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 40 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 40 #include "platform/loader/fetch/SubstituteData.h" | 41 #include "platform/loader/fetch/SubstituteData.h" |
| 41 #include "platform/wtf/HashMap.h" | 42 #include "platform/wtf/HashMap.h" |
| 42 #include "platform/wtf/HashSet.h" | 43 #include "platform/wtf/HashSet.h" |
| 43 #include "platform/wtf/ListHashSet.h" | 44 #include "platform/wtf/ListHashSet.h" |
| 44 #include "platform/wtf/text/StringHash.h" | 45 #include "platform/wtf/text/StringHash.h" |
| 45 | 46 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 enum ClearPreloadsPolicy { | 100 enum ClearPreloadsPolicy { |
| 100 kClearAllPreloads, | 101 kClearAllPreloads, |
| 101 kClearSpeculativeMarkupPreloads | 102 kClearSpeculativeMarkupPreloads |
| 102 }; | 103 }; |
| 103 | 104 |
| 104 void EnableIsPreloadedForTest(); | 105 void EnableIsPreloadedForTest(); |
| 105 bool IsPreloadedForTest(const KURL&) const; | 106 bool IsPreloadedForTest(const KURL&) const; |
| 106 | 107 |
| 107 int CountPreloads() const { return preloads_.size(); } | 108 int CountPreloads() const { return preloads_.size(); } |
| 108 void ClearPreloads(ClearPreloadsPolicy = kClearAllPreloads); | 109 void ClearPreloads(ClearPreloadsPolicy = kClearAllPreloads); |
| 109 void PreloadStarted(Resource*); | |
| 110 void LogPreloadStats(ClearPreloadsPolicy); | 110 void LogPreloadStats(ClearPreloadsPolicy); |
| 111 void WarnUnusedPreloads(); | 111 void WarnUnusedPreloads(); |
| 112 | 112 |
| 113 MHTMLArchive* Archive() const { return archive_.Get(); } | 113 MHTMLArchive* Archive() const { return archive_.Get(); } |
| 114 ArchiveResource* CreateArchive(Resource*); | 114 ArchiveResource* CreateArchive(Resource*); |
| 115 | 115 |
| 116 void SetDefersLoading(bool); | 116 void SetDefersLoading(bool); |
| 117 void StopFetching(); | 117 void StopFetching(); |
| 118 bool IsFetching() const; | 118 bool IsFetching() const; |
| 119 | 119 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 138 Resource::Type, | 138 Resource::Type, |
| 139 IsImageSet) const; | 139 IsImageSet) const; |
| 140 | 140 |
| 141 void UpdateAllImageResourcePriorities(); | 141 void UpdateAllImageResourcePriorities(); |
| 142 | 142 |
| 143 void ReloadLoFiImages(); | 143 void ReloadLoFiImages(); |
| 144 | 144 |
| 145 // Calling this method before main document resource is fetched is invalid. | 145 // Calling this method before main document resource is fetched is invalid. |
| 146 ResourceTimingInfo* GetNavigationTimingInfo(); | 146 ResourceTimingInfo* GetNavigationTimingInfo(); |
| 147 | 147 |
| 148 bool ContainsAsPreloadForTesting(Resource* resource) const { | 148 // Returns whether the given resource is contained as a preloaded resource. |
| 149 return preloads_.Contains(resource); | 149 bool ContainsAsPreload(Resource*) const; |
| 150 } | 150 |
| 151 void RemovePreload(Resource*); |
| 151 | 152 |
| 152 // Workaround for https://crbug.com/666214. | 153 // Workaround for https://crbug.com/666214. |
| 153 // TODO(hiroshige): Remove this hack. | 154 // TODO(hiroshige): Remove this hack. |
| 154 void EmulateLoadStartedForInspector(Resource*, | 155 void EmulateLoadStartedForInspector(Resource*, |
| 155 const KURL&, | 156 const KURL&, |
| 156 WebURLRequest::RequestContext, | 157 WebURLRequest::RequestContext, |
| 157 const AtomicString& initiator_name); | 158 const AtomicString& initiator_name); |
| 158 | 159 |
| 159 private: | 160 private: |
| 160 friend class ResourceCacheValidationSuppressor; | 161 friend class ResourceCacheValidationSuppressor; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 183 unsigned long identifier, | 184 unsigned long identifier, |
| 184 ResourceRequestBlockedReason&); | 185 ResourceRequestBlockedReason&); |
| 185 | 186 |
| 186 Resource* ResourceForStaticData(const FetchParameters&, | 187 Resource* ResourceForStaticData(const FetchParameters&, |
| 187 const ResourceFactory&, | 188 const ResourceFactory&, |
| 188 const SubstituteData&); | 189 const SubstituteData&); |
| 189 Resource* ResourceForBlockedRequest(const FetchParameters&, | 190 Resource* ResourceForBlockedRequest(const FetchParameters&, |
| 190 const ResourceFactory&, | 191 const ResourceFactory&, |
| 191 ResourceRequestBlockedReason); | 192 ResourceRequestBlockedReason); |
| 192 | 193 |
| 194 Resource* MatchPreload(const FetchParameters& params, Resource::Type); |
| 195 void InsertAsPreloadIfNecessary(Resource*, |
| 196 const FetchParameters& params, |
| 197 Resource::Type); |
| 198 |
| 199 bool IsReusableAlsoForPreloading(const FetchParameters&, |
| 200 Resource*, |
| 201 bool is_static_data) const; |
| 193 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. | 202 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. |
| 194 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; | 203 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; |
| 195 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, | 204 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, |
| 196 const FetchParameters&, | 205 const FetchParameters&, |
| 197 Resource* existing_resource, | 206 Resource* existing_resource, |
| 198 bool is_static_data) const; | 207 bool is_static_data) const; |
| 199 | 208 |
| 200 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, | 209 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, |
| 201 const FetchParameters&); | 210 const FetchParameters&); |
| 202 void MoveResourceLoaderToNonBlocking(ResourceLoader*); | 211 void MoveResourceLoaderToNonBlocking(ResourceLoader*); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 226 RevalidationPolicy, | 235 RevalidationPolicy, |
| 227 const FetchParameters&, | 236 const FetchParameters&, |
| 228 const ResourceFactory&, | 237 const ResourceFactory&, |
| 229 bool is_static_data) const; | 238 bool is_static_data) const; |
| 230 | 239 |
| 231 Member<FetchContext> context_; | 240 Member<FetchContext> context_; |
| 232 | 241 |
| 233 HashSet<String> validated_urls_; | 242 HashSet<String> validated_urls_; |
| 234 mutable DocumentResourceMap document_resources_; | 243 mutable DocumentResourceMap document_resources_; |
| 235 | 244 |
| 236 HeapListHashSet<Member<Resource>> preloads_; | 245 HeapHashMap<PreloadKey, Member<Resource>> preloads_; |
| 246 HeapVector<Member<Resource>> matched_preloads_; |
| 237 Member<MHTMLArchive> archive_; | 247 Member<MHTMLArchive> archive_; |
| 238 | 248 |
| 239 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; | 249 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; |
| 240 | 250 |
| 241 using ResourceTimingInfoMap = | 251 using ResourceTimingInfoMap = |
| 242 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; | 252 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; |
| 243 ResourceTimingInfoMap resource_timing_info_map_; | 253 ResourceTimingInfoMap resource_timing_info_map_; |
| 244 | 254 |
| 245 RefPtr<ResourceTimingInfo> navigation_timing_info_; | 255 RefPtr<ResourceTimingInfo> navigation_timing_info_; |
| 246 | 256 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 276 } | 286 } |
| 277 | 287 |
| 278 private: | 288 private: |
| 279 Member<ResourceFetcher> loader_; | 289 Member<ResourceFetcher> loader_; |
| 280 bool previous_state_; | 290 bool previous_state_; |
| 281 }; | 291 }; |
| 282 | 292 |
| 283 } // namespace blink | 293 } // namespace blink |
| 284 | 294 |
| 285 #endif // ResourceFetcher_h | 295 #endif // ResourceFetcher_h |
| OLD | NEW |