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

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

Issue 2343623002: Add a warning whenever link preloads are not used (Closed)
Patch Set: more comments Created 4 years, 3 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 rights reserved. 4 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 5 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 FetchContext& context() const { return m_context ? *m_context.get() : FetchC ontext::nullInstance(); } 89 FetchContext& context() const { return m_context ? *m_context.get() : FetchC ontext::nullInstance(); }
90 void clearContext(); 90 void clearContext();
91 91
92 int requestCount() const; 92 int requestCount() const;
93 bool hasPendingRequest() const; 93 bool hasPendingRequest() const;
94 94
95 enum ClearPreloadsPolicy { ClearAllPreloads, ClearSpeculativeMarkupPreloads }; 95 enum ClearPreloadsPolicy { ClearAllPreloads, ClearSpeculativeMarkupPreloads };
96 96
97 bool isPreloaded(const KURL&) const; 97 bool isPreloaded(const KURL&) const;
98 int countPreloads() const { return m_preloads ? m_preloads->size() : 0; } 98 int countPreloads() const { return m_preloads ? m_preloads->size() : 0; }
99 bool hasUnusedLinkPreloads() { return m_unusedLinkPreloadCounter > 0; }
99 void clearPreloads(ClearPreloadsPolicy = ClearAllPreloads); 100 void clearPreloads(ClearPreloadsPolicy = ClearAllPreloads);
100 void preloadStarted(Resource*); 101 void preloadStarted(Resource*);
101 void logPreloadStats(); 102 void logPreloadStats();
103 void warnUnusedPreloads();
102 104
103 MHTMLArchive* archive() const { return m_archive.get(); } 105 MHTMLArchive* archive() const { return m_archive.get(); }
104 ArchiveResource* createArchive(Resource*); 106 ArchiveResource* createArchive(Resource*);
105 107
106 void setDefersLoading(bool); 108 void setDefersLoading(bool);
107 void stopFetching(); 109 void stopFetching();
108 bool isFetching() const; 110 bool isFetching() const;
109 111
110 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse& , int64_t encodedDataLength); 112 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse& , int64_t encodedDataLength);
111 enum DidFinishLoadingReason { 113 enum DidFinishLoadingReason {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void reloadImagesIfNotDeferred(); 175 void reloadImagesIfNotDeferred();
174 176
175 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques t&, const ResourceFactory&, bool isStaticData) const; 177 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques t&, const ResourceFactory&, bool isStaticData) const;
176 178
177 Member<FetchContext> m_context; 179 Member<FetchContext> m_context;
178 180
179 HashSet<String> m_validatedURLs; 181 HashSet<String> m_validatedURLs;
180 mutable DocumentResourceMap m_documentResources; 182 mutable DocumentResourceMap m_documentResources;
181 183
182 Member<HeapListHashSet<Member<Resource>>> m_preloads; 184 Member<HeapListHashSet<Member<Resource>>> m_preloads;
185 unsigned m_unusedLinkPreloadCounter;
183 Member<MHTMLArchive> m_archive; 186 Member<MHTMLArchive> m_archive;
184 187
185 Timer<ResourceFetcher> m_resourceTimingReportTimer; 188 Timer<ResourceFetcher> m_resourceTimingReportTimer;
186 189
187 using ResourceTimingInfoMap = HeapHashMap<Member<Resource>, std::unique_ptr< ResourceTimingInfo>>; 190 using ResourceTimingInfoMap = HeapHashMap<Member<Resource>, std::unique_ptr< ResourceTimingInfo>>;
188 ResourceTimingInfoMap m_resourceTimingInfoMap; 191 ResourceTimingInfoMap m_resourceTimingInfoMap;
189 192
190 Vector<std::unique_ptr<ResourceTimingInfo>> m_scheduledResourceTimingReports ; 193 Vector<std::unique_ptr<ResourceTimingInfo>> m_scheduledResourceTimingReports ;
191 194
192 HeapHashSet<Member<ResourceLoader>> m_loaders; 195 HeapHashSet<Member<ResourceLoader>> m_loaders;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 m_loader->m_allowStaleResources = m_previousState; 237 m_loader->m_allowStaleResources = m_previousState;
235 } 238 }
236 private: 239 private:
237 Member<ResourceFetcher> m_loader; 240 Member<ResourceFetcher> m_loader;
238 bool m_previousState; 241 bool m_previousState;
239 }; 242 };
240 243
241 } // namespace blink 244 } // namespace blink
242 245
243 #endif // ResourceFetcher_h 246 #endif // ResourceFetcher_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698