| 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 15 matching lines...) Expand all Loading... |
| 135 WARN_UNUSED_RESULT WebURLRequest::RequestContext DetermineRequestContext( | 135 WARN_UNUSED_RESULT WebURLRequest::RequestContext DetermineRequestContext( |
| 136 Resource::Type) const; | 136 Resource::Type) const; |
| 137 | 137 |
| 138 void UpdateAllImageResourcePriorities(); | 138 void UpdateAllImageResourcePriorities(); |
| 139 | 139 |
| 140 void ReloadLoFiImages(); | 140 void ReloadLoFiImages(); |
| 141 | 141 |
| 142 // Calling this method before main document resource is fetched is invalid. | 142 // Calling this method before main document resource is fetched is invalid. |
| 143 ResourceTimingInfo* GetNavigationTimingInfo(); | 143 ResourceTimingInfo* GetNavigationTimingInfo(); |
| 144 | 144 |
| 145 bool ContainsAsPreloadForTesting(Resource* resource) const { | 145 // Returns whether the given resource is contained as a preloaded resource. |
| 146 return preloads_.Contains(resource); | 146 bool ContainsAsPreload(Resource*) const; |
| 147 } | 147 |
| 148 void RemovePreload(Resource*); |
| 148 | 149 |
| 149 // Workaround for https://crbug.com/666214. | 150 // Workaround for https://crbug.com/666214. |
| 150 // TODO(hiroshige): Remove this hack. | 151 // TODO(hiroshige): Remove this hack. |
| 151 void EmulateLoadStartedForInspector(Resource*, | 152 void EmulateLoadStartedForInspector(Resource*, |
| 152 const KURL&, | 153 const KURL&, |
| 153 WebURLRequest::RequestContext, | 154 WebURLRequest::RequestContext, |
| 154 const AtomicString& initiator_name); | 155 const AtomicString& initiator_name); |
| 155 | 156 |
| 156 private: | 157 private: |
| 157 friend class ResourceCacheValidationSuppressor; | 158 friend class ResourceCacheValidationSuppressor; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 180 unsigned long identifier, | 181 unsigned long identifier, |
| 181 ResourceRequestBlockedReason&); | 182 ResourceRequestBlockedReason&); |
| 182 | 183 |
| 183 Resource* ResourceForStaticData(const FetchParameters&, | 184 Resource* ResourceForStaticData(const FetchParameters&, |
| 184 const ResourceFactory&, | 185 const ResourceFactory&, |
| 185 const SubstituteData&); | 186 const SubstituteData&); |
| 186 Resource* ResourceForBlockedRequest(const FetchParameters&, | 187 Resource* ResourceForBlockedRequest(const FetchParameters&, |
| 187 const ResourceFactory&, | 188 const ResourceFactory&, |
| 188 ResourceRequestBlockedReason); | 189 ResourceRequestBlockedReason); |
| 189 | 190 |
| 191 Resource* MatchPreload(const FetchParameters& params, Resource::Type); |
| 192 void InsertAsPreloadIfNecessary(Resource*, |
| 193 const FetchParameters& params, |
| 194 Resource::Type); |
| 195 |
| 196 bool IsReusableForPreloading(const FetchParameters&, |
| 197 Resource*, |
| 198 bool is_static_data) const; |
| 190 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. | 199 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. |
| 191 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; | 200 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; |
| 192 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, | 201 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, |
| 193 const FetchParameters&, | 202 const FetchParameters&, |
| 194 Resource* existing_resource, | 203 Resource* existing_resource, |
| 195 bool is_static_data) const; | 204 bool is_static_data) const; |
| 196 | 205 |
| 197 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, | 206 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, |
| 198 const FetchParameters&); | 207 const FetchParameters&); |
| 199 void MoveResourceLoaderToNonBlocking(ResourceLoader*); | 208 void MoveResourceLoaderToNonBlocking(ResourceLoader*); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 223 RevalidationPolicy, | 232 RevalidationPolicy, |
| 224 const FetchParameters&, | 233 const FetchParameters&, |
| 225 const ResourceFactory&, | 234 const ResourceFactory&, |
| 226 bool is_static_data) const; | 235 bool is_static_data) const; |
| 227 | 236 |
| 228 Member<FetchContext> context_; | 237 Member<FetchContext> context_; |
| 229 | 238 |
| 230 HashSet<String> validated_urls_; | 239 HashSet<String> validated_urls_; |
| 231 mutable DocumentResourceMap document_resources_; | 240 mutable DocumentResourceMap document_resources_; |
| 232 | 241 |
| 233 HeapListHashSet<Member<Resource>> preloads_; | 242 HeapHashMap<PreloadKey, Member<Resource>> preloads_; |
| 234 Member<MHTMLArchive> archive_; | 243 Member<MHTMLArchive> archive_; |
| 235 | 244 |
| 236 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; | 245 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; |
| 237 | 246 |
| 238 using ResourceTimingInfoMap = | 247 using ResourceTimingInfoMap = |
| 239 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; | 248 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; |
| 240 ResourceTimingInfoMap resource_timing_info_map_; | 249 ResourceTimingInfoMap resource_timing_info_map_; |
| 241 | 250 |
| 242 RefPtr<ResourceTimingInfo> navigation_timing_info_; | 251 RefPtr<ResourceTimingInfo> navigation_timing_info_; |
| 243 | 252 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 273 } | 282 } |
| 274 | 283 |
| 275 private: | 284 private: |
| 276 Member<ResourceFetcher> loader_; | 285 Member<ResourceFetcher> loader_; |
| 277 bool previous_state_; | 286 bool previous_state_; |
| 278 }; | 287 }; |
| 279 | 288 |
| 280 } // namespace blink | 289 } // namespace blink |
| 281 | 290 |
| 282 #endif // ResourceFetcher_h | 291 #endif // ResourceFetcher_h |
| OLD | NEW |