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

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: Added failing unit tests 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 void enableIsPreloadedForTest(); 97 void enableIsPreloadedForTest();
98 bool isPreloadedForTest(const KURL&) const; 98 bool isPreloadedForTest(const KURL&) const;
99 99
100 int countPreloads() const { return m_preloads ? m_preloads->size() : 0; } 100 int countPreloads() const { return m_preloads ? m_preloads->size() : 0; }
101 bool hasUnusedLinkPreloads() { return m_unusedLinkPreloadCounter > 0; }
101 void clearPreloads(ClearPreloadsPolicy = ClearAllPreloads); 102 void clearPreloads(ClearPreloadsPolicy = ClearAllPreloads);
102 void preloadStarted(Resource*); 103 void preloadStarted(Resource*);
103 void logPreloadStats(); 104 void logPreloadStats();
105 void warnUnusedPreloads();
104 106
105 MHTMLArchive* archive() const { return m_archive.get(); } 107 MHTMLArchive* archive() const { return m_archive.get(); }
106 ArchiveResource* createArchive(Resource*); 108 ArchiveResource* createArchive(Resource*);
107 109
108 void setDefersLoading(bool); 110 void setDefersLoading(bool);
109 void stopFetching(); 111 void stopFetching();
110 bool isFetching() const; 112 bool isFetching() const;
111 113
112 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse& , int64_t encodedDataLength); 114 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse& , int64_t encodedDataLength);
113 enum DidFinishLoadingReason { 115 enum DidFinishLoadingReason {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void reloadImagesIfNotDeferred(); 177 void reloadImagesIfNotDeferred();
176 178
177 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques t&, const ResourceFactory&, bool isStaticData) const; 179 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques t&, const ResourceFactory&, bool isStaticData) const;
178 180
179 Member<FetchContext> m_context; 181 Member<FetchContext> m_context;
180 182
181 HashSet<String> m_validatedURLs; 183 HashSet<String> m_validatedURLs;
182 mutable DocumentResourceMap m_documentResources; 184 mutable DocumentResourceMap m_documentResources;
183 185
184 Member<HeapListHashSet<Member<Resource>>> m_preloads; 186 Member<HeapListHashSet<Member<Resource>>> m_preloads;
187 unsigned m_unusedLinkPreloadCounter;
185 Member<MHTMLArchive> m_archive; 188 Member<MHTMLArchive> m_archive;
186 189
187 Timer<ResourceFetcher> m_resourceTimingReportTimer; 190 Timer<ResourceFetcher> m_resourceTimingReportTimer;
188 191
189 using ResourceTimingInfoMap = HeapHashMap<Member<Resource>, std::unique_ptr< ResourceTimingInfo>>; 192 using ResourceTimingInfoMap = HeapHashMap<Member<Resource>, std::unique_ptr< ResourceTimingInfo>>;
190 ResourceTimingInfoMap m_resourceTimingInfoMap; 193 ResourceTimingInfoMap m_resourceTimingInfoMap;
191 194
192 Vector<std::unique_ptr<ResourceTimingInfo>> m_scheduledResourceTimingReports ; 195 Vector<std::unique_ptr<ResourceTimingInfo>> m_scheduledResourceTimingReports ;
193 196
194 HeapHashSet<Member<ResourceLoader>> m_loaders; 197 HeapHashSet<Member<ResourceLoader>> m_loaders;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 m_loader->m_allowStaleResources = m_previousState; 241 m_loader->m_allowStaleResources = m_previousState;
239 } 242 }
240 private: 243 private:
241 Member<ResourceFetcher> m_loader; 244 Member<ResourceFetcher> m_loader;
242 bool m_previousState; 245 bool m_previousState;
243 }; 246 };
244 247
245 } // namespace blink 248 } // namespace blink
246 249
247 #endif // ResourceFetcher_h 250 #endif // ResourceFetcher_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698