| 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" | |
| 37 #include "platform/loader/fetch/Resource.h" | 36 #include "platform/loader/fetch/Resource.h" |
| 38 #include "platform/loader/fetch/ResourceError.h" | 37 #include "platform/loader/fetch/ResourceError.h" |
| 39 #include "platform/loader/fetch/ResourceLoadPriority.h" | 38 #include "platform/loader/fetch/ResourceLoadPriority.h" |
| 40 #include "platform/loader/fetch/ResourceLoaderOptions.h" | 39 #include "platform/loader/fetch/ResourceLoaderOptions.h" |
| 41 #include "platform/loader/fetch/SubstituteData.h" | 40 #include "platform/loader/fetch/SubstituteData.h" |
| 42 #include "platform/wtf/HashMap.h" | 41 #include "platform/wtf/HashMap.h" |
| 43 #include "platform/wtf/HashSet.h" | 42 #include "platform/wtf/HashSet.h" |
| 44 #include "platform/wtf/ListHashSet.h" | 43 #include "platform/wtf/ListHashSet.h" |
| 45 #include "platform/wtf/text/StringHash.h" | 44 #include "platform/wtf/text/StringHash.h" |
| 46 | 45 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 enum ClearPreloadsPolicy { | 99 enum ClearPreloadsPolicy { |
| 101 kClearAllPreloads, | 100 kClearAllPreloads, |
| 102 kClearSpeculativeMarkupPreloads | 101 kClearSpeculativeMarkupPreloads |
| 103 }; | 102 }; |
| 104 | 103 |
| 105 void EnableIsPreloadedForTest(); | 104 void EnableIsPreloadedForTest(); |
| 106 bool IsPreloadedForTest(const KURL&) const; | 105 bool IsPreloadedForTest(const KURL&) const; |
| 107 | 106 |
| 108 int CountPreloads() const { return preloads_.size(); } | 107 int CountPreloads() const { return preloads_.size(); } |
| 109 void ClearPreloads(ClearPreloadsPolicy = kClearAllPreloads); | 108 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 // Returns whether the given resource is contained as a preloaded resource. | 148 bool ContainsAsPreloadForTesting(Resource* resource) const { |
| 149 bool ContainsAsPreload(Resource*) const; | 149 return preloads_.Contains(resource); |
| 150 | 150 } |
| 151 void RemovePreload(Resource*); | |
| 152 | 151 |
| 153 // Workaround for https://crbug.com/666214. | 152 // Workaround for https://crbug.com/666214. |
| 154 // TODO(hiroshige): Remove this hack. | 153 // TODO(hiroshige): Remove this hack. |
| 155 void EmulateLoadStartedForInspector(Resource*, | 154 void EmulateLoadStartedForInspector(Resource*, |
| 156 const KURL&, | 155 const KURL&, |
| 157 WebURLRequest::RequestContext, | 156 WebURLRequest::RequestContext, |
| 158 const AtomicString& initiator_name); | 157 const AtomicString& initiator_name); |
| 159 | 158 |
| 160 private: | 159 private: |
| 161 friend class ResourceCacheValidationSuppressor; | 160 friend class ResourceCacheValidationSuppressor; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 184 unsigned long identifier, | 183 unsigned long identifier, |
| 185 ResourceRequestBlockedReason&); | 184 ResourceRequestBlockedReason&); |
| 186 | 185 |
| 187 Resource* ResourceForStaticData(const FetchParameters&, | 186 Resource* ResourceForStaticData(const FetchParameters&, |
| 188 const ResourceFactory&, | 187 const ResourceFactory&, |
| 189 const SubstituteData&); | 188 const SubstituteData&); |
| 190 Resource* ResourceForBlockedRequest(const FetchParameters&, | 189 Resource* ResourceForBlockedRequest(const FetchParameters&, |
| 191 const ResourceFactory&, | 190 const ResourceFactory&, |
| 192 ResourceRequestBlockedReason); | 191 ResourceRequestBlockedReason); |
| 193 | 192 |
| 194 Resource* MatchPreload(const FetchParameters& params, Resource::Type); | |
| 195 void InsertAsPreloadIfNecessary(Resource*, | |
| 196 const FetchParameters& params, | |
| 197 Resource::Type); | |
| 198 | |
| 199 bool IsReusableForPreloading(const FetchParameters&, | |
| 200 Resource*, | |
| 201 bool is_static_data) const; | |
| 202 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. | 193 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. |
| 203 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; | 194 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; |
| 204 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, | 195 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, |
| 205 const FetchParameters&, | 196 const FetchParameters&, |
| 206 Resource* existing_resource, | 197 Resource* existing_resource, |
| 207 bool is_static_data) const; | 198 bool is_static_data) const; |
| 208 | 199 |
| 209 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, | 200 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, |
| 210 const FetchParameters&); | 201 const FetchParameters&); |
| 211 void MoveResourceLoaderToNonBlocking(ResourceLoader*); | 202 void MoveResourceLoaderToNonBlocking(ResourceLoader*); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 235 RevalidationPolicy, | 226 RevalidationPolicy, |
| 236 const FetchParameters&, | 227 const FetchParameters&, |
| 237 const ResourceFactory&, | 228 const ResourceFactory&, |
| 238 bool is_static_data) const; | 229 bool is_static_data) const; |
| 239 | 230 |
| 240 Member<FetchContext> context_; | 231 Member<FetchContext> context_; |
| 241 | 232 |
| 242 HashSet<String> validated_urls_; | 233 HashSet<String> validated_urls_; |
| 243 mutable DocumentResourceMap document_resources_; | 234 mutable DocumentResourceMap document_resources_; |
| 244 | 235 |
| 245 HeapHashMap<PreloadKey, Member<Resource>> preloads_; | 236 HeapListHashSet<Member<Resource>> preloads_; |
| 246 Member<MHTMLArchive> archive_; | 237 Member<MHTMLArchive> archive_; |
| 247 | 238 |
| 248 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; | 239 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; |
| 249 | 240 |
| 250 using ResourceTimingInfoMap = | 241 using ResourceTimingInfoMap = |
| 251 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; | 242 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; |
| 252 ResourceTimingInfoMap resource_timing_info_map_; | 243 ResourceTimingInfoMap resource_timing_info_map_; |
| 253 | 244 |
| 254 RefPtr<ResourceTimingInfo> navigation_timing_info_; | 245 RefPtr<ResourceTimingInfo> navigation_timing_info_; |
| 255 | 246 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 285 } | 276 } |
| 286 | 277 |
| 287 private: | 278 private: |
| 288 Member<ResourceFetcher> loader_; | 279 Member<ResourceFetcher> loader_; |
| 289 bool previous_state_; | 280 bool previous_state_; |
| 290 }; | 281 }; |
| 291 | 282 |
| 292 } // namespace blink | 283 } // namespace blink |
| 293 | 284 |
| 294 #endif // ResourceFetcher_h | 285 #endif // ResourceFetcher_h |
| OLD | NEW |