Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: third_party/WebKit/Source/platform/loader/fetch/ResourceFetcher.h

Issue 2834733003: Separate preaload matching from MemoryCache (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
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 21 matching lines...) Expand all
179 unsigned long identifier, 180 unsigned long identifier,
180 ResourceRequestBlockedReason&); 181 ResourceRequestBlockedReason&);
181 182
182 Resource* ResourceForStaticData(const FetchParameters&, 183 Resource* ResourceForStaticData(const FetchParameters&,
183 const ResourceFactory&, 184 const ResourceFactory&,
184 const SubstituteData&); 185 const SubstituteData&);
185 Resource* ResourceForBlockedRequest(const FetchParameters&, 186 Resource* ResourceForBlockedRequest(const FetchParameters&,
186 const ResourceFactory&, 187 const ResourceFactory&,
187 ResourceRequestBlockedReason); 188 ResourceRequestBlockedReason);
188 189
190 Resource* MatchPreload(const FetchParameters& params, Resource::Type);
191 void InsertAsPreloadIfNecessary(Resource*,
192 const FetchParameters& params,
193 Resource::Type);
194
195 bool IsReusableForPreloading(const FetchParameters&,
196 Resource*,
197 bool is_static_data) const;
189 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. 198 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496.
190 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad }; 199 enum RevalidationPolicy { kUse, kRevalidate, kReload, kLoad };
191 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type, 200 RevalidationPolicy DetermineRevalidationPolicy(Resource::Type,
192 const FetchParameters&, 201 const FetchParameters&,
193 Resource* existing_resource, 202 Resource* existing_resource,
194 bool is_static_data) const; 203 bool is_static_data) const;
195 204
196 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*, 205 void MakePreloadedResourceBlockOnloadIfNeeded(Resource*,
197 const FetchParameters&); 206 const FetchParameters&);
198 void MoveResourceLoaderToNonBlocking(ResourceLoader*); 207 void MoveResourceLoaderToNonBlocking(ResourceLoader*);
(...skipping 23 matching lines...) Expand all
222 RevalidationPolicy, 231 RevalidationPolicy,
223 const FetchParameters&, 232 const FetchParameters&,
224 const ResourceFactory&, 233 const ResourceFactory&,
225 bool is_static_data) const; 234 bool is_static_data) const;
226 235
227 Member<FetchContext> context_; 236 Member<FetchContext> context_;
228 237
229 HashSet<String> validated_urls_; 238 HashSet<String> validated_urls_;
230 mutable DocumentResourceMap document_resources_; 239 mutable DocumentResourceMap document_resources_;
231 240
232 HeapListHashSet<Member<Resource>> preloads_; 241 HeapHashMap<PreloadKey, Member<Resource>> preloads_;
233 Member<MHTMLArchive> archive_; 242 Member<MHTMLArchive> archive_;
234 243
235 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_; 244 TaskRunnerTimer<ResourceFetcher> resource_timing_report_timer_;
236 245
237 using ResourceTimingInfoMap = 246 using ResourceTimingInfoMap =
238 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>; 247 HeapHashMap<Member<Resource>, RefPtr<ResourceTimingInfo>>;
239 ResourceTimingInfoMap resource_timing_info_map_; 248 ResourceTimingInfoMap resource_timing_info_map_;
240 249
241 RefPtr<ResourceTimingInfo> navigation_timing_info_; 250 RefPtr<ResourceTimingInfo> navigation_timing_info_;
242 251
(...skipping 29 matching lines...) Expand all
272 } 281 }
273 282
274 private: 283 private:
275 Member<ResourceFetcher> loader_; 284 Member<ResourceFetcher> loader_;
276 bool previous_state_; 285 bool previous_state_;
277 }; 286 };
278 287
279 } // namespace blink 288 } // namespace blink
280 289
281 #endif // ResourceFetcher_h 290 #endif // ResourceFetcher_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698