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

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

Issue 1428383002: Make ResourceFetcher::m_documentResources use WeakPtr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add TODOs Created 5 years 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 WILL_BE_USING_PRE_FINALIZER(ResourceFetcher, clearPreloads); 71 WILL_BE_USING_PRE_FINALIZER(ResourceFetcher, clearPreloads);
72 public: 72 public:
73 static ResourceFetcher* create(FetchContext* context) { return new ResourceF etcher(context); } 73 static ResourceFetcher* create(FetchContext* context) { return new ResourceF etcher(context); }
74 virtual ~ResourceFetcher(); 74 virtual ~ResourceFetcher();
75 DECLARE_VIRTUAL_TRACE(); 75 DECLARE_VIRTUAL_TRACE();
76 76
77 ResourcePtr<Resource> requestResource(FetchRequest&, const ResourceFactory&, const SubstituteData& = SubstituteData()); 77 ResourcePtr<Resource> requestResource(FetchRequest&, const ResourceFactory&, const SubstituteData& = SubstituteData());
78 78
79 Resource* cachedResource(const KURL&) const; 79 Resource* cachedResource(const KURL&) const;
80 80
81 typedef HashMap<String, ResourcePtr<Resource>> DocumentResourceMap; 81 typedef WillBeHeapHashMap<String, WeakPtrWillBeWeakMember<Resource>> Documen tResourceMap;
82 const DocumentResourceMap& allResources() const { return m_documentResources ; } 82 const DocumentResourceMap& allResources() const { return m_documentResources ; }
83 83
84 bool autoLoadImages() const { return m_autoLoadImages; } 84 bool autoLoadImages() const { return m_autoLoadImages; }
85 void setAutoLoadImages(bool); 85 void setAutoLoadImages(bool);
86 86
87 void setImagesEnabled(bool); 87 void setImagesEnabled(bool);
88 88
89 bool shouldDeferImageLoad(const KURL&) const; 89 bool shouldDeferImageLoad(const KURL&) const;
90 90
91 FetchContext& context() const { return m_context ? *m_context.get() : FetchC ontext::nullInstance(); } 91 FetchContext& context() const { return m_context ? *m_context.get() : FetchC ontext::nullInstance(); }
92 void clearContext() { m_context.clear(); } 92 void clearContext() { m_context.clear(); }
93 93
94 void garbageCollectDocumentResources();
95
96 int requestCount() const; 94 int requestCount() const;
97 95
98 bool isPreloaded(const KURL&) const; 96 bool isPreloaded(const KURL&) const;
99 void clearPreloads(); 97 void clearPreloads();
100 void preloadStarted(Resource*); 98 void preloadStarted(Resource*);
101 void printPreloadStats(); 99 void printPreloadStats();
102 100
103 void addAllArchiveResources(MHTMLArchive*); 101 void addAllArchiveResources(MHTMLArchive*);
104 ArchiveResourceCollection* archiveResourceCollection() const { return m_arch iveResourceCollection.get(); } 102 ArchiveResourceCollection* archiveResourceCollection() const { return m_arch iveResourceCollection.get(); }
105 103
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 165
168 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; 166 enum RevalidationPolicy { Use, Revalidate, Reload, Load };
169 RevalidationPolicy determineRevalidationPolicy(Resource::Type, const FetchRe quest&, Resource* existingResource, bool isStaticData) const; 167 RevalidationPolicy determineRevalidationPolicy(Resource::Type, const FetchRe quest&, Resource* existingResource, bool isStaticData) const;
170 168
171 void moveCachedNonBlockingResourceToBlocking(Resource*); 169 void moveCachedNonBlockingResourceToBlocking(Resource*);
172 170
173 void initializeResourceRequest(ResourceRequest&, Resource::Type); 171 void initializeResourceRequest(ResourceRequest&, Resource::Type);
174 172
175 static bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPo licy); 173 static bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPo licy);
176 174
177 void garbageCollectDocumentResourcesTimerFired(Timer<ResourceFetcher>*);
178
179 void resourceTimingReportTimerFired(Timer<ResourceFetcher>*); 175 void resourceTimingReportTimerFired(Timer<ResourceFetcher>*);
180 176
181 void reloadImagesIfNotDeferred(); 177 void reloadImagesIfNotDeferred();
182 178
183 void willTerminateResourceLoader(ResourceLoader*); 179 void willTerminateResourceLoader(ResourceLoader*);
184 180
185 ResourceLoadPriority modifyPriorityForExperiments(ResourceLoadPriority, Reso urce::Type, const FetchRequest&); 181 ResourceLoadPriority modifyPriorityForExperiments(ResourceLoadPriority, Reso urce::Type, const FetchRequest&);
186 182
187 Member<FetchContext> m_context; 183 Member<FetchContext> m_context;
188 184
189 HashSet<String> m_validatedURLs; 185 HashSet<String> m_validatedURLs;
190 mutable DocumentResourceMap m_documentResources; 186 mutable DocumentResourceMap m_documentResources;
191 187
192 // We intentionally use a Member instead of a ResourcePtr. 188 // We intentionally use a Member instead of a ResourcePtr.
193 // Using a ResourcePtrs can lead to a wrong behavior because 189 // Using a ResourcePtrs can lead to a wrong behavior because
194 // the underlying Resource of the ResourcePtr is updated when the Resource 190 // the underlying Resource of the ResourcePtr is updated when the Resource
195 // is revalidated. What we really want to hold here is not the ResourcePtr 191 // is revalidated. What we really want to hold here is not the ResourcePtr
196 // but the underlying Resource. 192 // but the underlying Resource.
197 OwnPtrWillBeMember<WillBeHeapListHashSet<RawPtrWillBeMember<Resource>>> m_pr eloads; 193 OwnPtrWillBeMember<WillBeHeapListHashSet<RawPtrWillBeMember<Resource>>> m_pr eloads;
198 OwnPtrWillBeMember<ArchiveResourceCollection> m_archiveResourceCollection; 194 OwnPtrWillBeMember<ArchiveResourceCollection> m_archiveResourceCollection;
199 195
200 Timer<ResourceFetcher> m_garbageCollectDocumentResourcesTimer;
201 Timer<ResourceFetcher> m_resourceTimingReportTimer; 196 Timer<ResourceFetcher> m_resourceTimingReportTimer;
202 197
203 // We intentionally use a Member instead of a ResourcePtr. 198 // We intentionally use a Member instead of a ResourcePtr.
204 // See the comment on m_preloads. 199 // See the comment on m_preloads.
205 typedef WillBeHeapHashMap<RawPtrWillBeMember<Resource>, OwnPtr<ResourceTimin gInfo>> ResourceTimingInfoMap; 200 typedef WillBeHeapHashMap<RawPtrWillBeMember<Resource>, OwnPtr<ResourceTimin gInfo>> ResourceTimingInfoMap;
206 ResourceTimingInfoMap m_resourceTimingInfoMap; 201 ResourceTimingInfoMap m_resourceTimingInfoMap;
207 202
208 Vector<OwnPtr<ResourceTimingInfo>> m_scheduledResourceTimingReports; 203 Vector<OwnPtr<ResourceTimingInfo>> m_scheduledResourceTimingReports;
209 204
210 Member<ResourceLoaderSet> m_loaders; 205 Member<ResourceLoaderSet> m_loaders;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 m_loader->m_allowStaleResources = m_previousState; 246 m_loader->m_allowStaleResources = m_previousState;
252 } 247 }
253 private: 248 private:
254 Member<ResourceFetcher> m_loader; 249 Member<ResourceFetcher> m_loader;
255 bool m_previousState; 250 bool m_previousState;
256 }; 251 };
257 252
258 } // namespace blink 253 } // namespace blink
259 254
260 #endif // ResourceFetcher_h 255 #endif // ResourceFetcher_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/Resource.cpp ('k') | third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698