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

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

Issue 1889973002: Refactoring starting a resource load (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix a browser_test Created 4 years, 6 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 virtual ~ResourceFetcher(); 73 virtual ~ResourceFetcher();
74 DECLARE_VIRTUAL_TRACE(); 74 DECLARE_VIRTUAL_TRACE();
75 75
76 Resource* requestResource(FetchRequest&, const ResourceFactory&, const Subst ituteData& = SubstituteData()); 76 Resource* requestResource(FetchRequest&, const ResourceFactory&, const Subst ituteData& = SubstituteData());
77 77
78 Resource* cachedResource(const KURL&) const; 78 Resource* cachedResource(const KURL&) const;
79 79
80 using DocumentResourceMap = HeapHashMap<String, WeakMember<Resource>>; 80 using DocumentResourceMap = HeapHashMap<String, WeakMember<Resource>>;
81 const DocumentResourceMap& allResources() const { return m_documentResources ; } 81 const DocumentResourceMap& allResources() const { return m_documentResources ; }
82 82
83 // Actually starts loading a Resource if it wasn't started during requestRes ource().
84 bool startLoad(Resource*);
85
83 void setAutoLoadImages(bool); 86 void setAutoLoadImages(bool);
84 void setImagesEnabled(bool); 87 void setImagesEnabled(bool);
85 88
86 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(); }
87 void clearContext() { m_context.clear(); } 90 void clearContext() { m_context.clear(); }
88 91
89 int requestCount() const; 92 int requestCount() const;
90 93
91 enum ClearPreloadsPolicy { ClearAllPreloads, ClearSpeculativeMarkupPreloads }; 94 enum ClearPreloadsPolicy { ClearAllPreloads, ClearSpeculativeMarkupPreloads };
92 95
(...skipping 13 matching lines...) Expand all
106 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse& ); 109 bool willFollowRedirect(Resource*, ResourceRequest&, const ResourceResponse& );
107 enum DidFinishLoadingReason { 110 enum DidFinishLoadingReason {
108 DidFinishLoading, 111 DidFinishLoading,
109 DidFinishFirstPartInMultipart 112 DidFinishFirstPartInMultipart
110 }; 113 };
111 void didFinishLoading(Resource*, double finishTime, int64_t encodedDataLengt h, DidFinishLoadingReason); 114 void didFinishLoading(Resource*, double finishTime, int64_t encodedDataLengt h, DidFinishLoadingReason);
112 void didFailLoading(Resource*, const ResourceError&); 115 void didFailLoading(Resource*, const ResourceError&);
113 void didReceiveResponse(Resource*, const ResourceResponse&); 116 void didReceiveResponse(Resource*, const ResourceResponse&);
114 void didReceiveData(const Resource*, const char* data, int dataLength, int e ncodedDataLength); 117 void didReceiveData(const Resource*, const char* data, int dataLength, int e ncodedDataLength);
115 void didDownloadData(const Resource*, int dataLength, int encodedDataLength) ; 118 void didDownloadData(const Resource*, int dataLength, int encodedDataLength) ;
116 void willStartLoadingResource(Resource*, ResourceLoader*, ResourceRequest&);
117 bool defersLoading() const; 119 bool defersLoading() const;
118 120
119 enum AccessControlLoggingDecision { 121 enum AccessControlLoggingDecision {
120 ShouldLogAccessControlErrors, 122 ShouldLogAccessControlErrors,
121 ShouldNotLogAccessControlErrors 123 ShouldNotLogAccessControlErrors
122 }; 124 };
123 bool canAccessResource(Resource*, SecurityOrigin*, const KURL&, AccessContro lLoggingDecision) const; 125 bool canAccessResource(Resource*, SecurityOrigin*, const KURL&, AccessContro lLoggingDecision) const;
124 bool isControlledByServiceWorker() const; 126 bool isControlledByServiceWorker() const;
125 127
126 void acceptDataFromThreadedReceiver(unsigned long identifier, const char* da ta, int dataLength, int encodedDataLength); 128 void acceptDataFromThreadedReceiver(unsigned long identifier, const char* da ta, int dataLength, int encodedDataLength);
127 129
128 ResourceLoadPriority loadPriority(Resource::Type, const FetchRequest&, Resou rcePriority::VisibilityStatus = ResourcePriority::NotVisible); 130 ResourceLoadPriority loadPriority(Resource::Type, const FetchRequest&, Resou rcePriority::VisibilityStatus = ResourcePriority::NotVisible);
129 131
130 enum ResourceLoadStartType { 132 enum ResourceLoadStartType {
131 ResourceLoadingFromNetwork, 133 ResourceLoadingFromNetwork,
132 ResourceLoadingFromCache 134 ResourceLoadingFromCache
133 }; 135 };
134 void requestLoadStarted(Resource*, const FetchRequest&, ResourceLoadStartTyp e, bool isStaticData = false); 136 void requestLoadStarted(unsigned long identifier, Resource*, const FetchRequ est&, ResourceLoadStartType, bool isStaticData = false);
135 static const ResourceLoaderOptions& defaultResourceOptions(); 137 static const ResourceLoaderOptions& defaultResourceOptions();
136 138
137 String getCacheIdentifier() const; 139 String getCacheIdentifier() const;
138 140
139 static void determineRequestContext(ResourceRequest&, Resource::Type, bool i sMainFrame); 141 static void determineRequestContext(ResourceRequest&, Resource::Type, bool i sMainFrame);
140 void determineRequestContext(ResourceRequest&, Resource::Type); 142 void determineRequestContext(ResourceRequest&, Resource::Type);
141 143
142 WebTaskRunner* loadingTaskRunner();
143
144 void updateAllImageResourcePriorities(); 144 void updateAllImageResourcePriorities();
145 145
146 void reloadLoFiImages(); 146 void reloadLoFiImages();
147 147
148 // This is only exposed for testing purposes. 148 // This is only exposed for testing purposes.
149 HeapListHashSet<Member<Resource>>* preloads() { return m_preloads.get(); } 149 HeapListHashSet<Member<Resource>>* preloads() { return m_preloads.get(); }
150 150
151 private: 151 private:
152 friend class ResourceCacheValidationSuppressor; 152 friend class ResourceCacheValidationSuppressor;
153 153
154 explicit ResourceFetcher(FetchContext*); 154 explicit ResourceFetcher(FetchContext*);
155 155
156 void initializeRevalidation(const FetchRequest&, Resource*); 156 void initializeRevalidation(ResourceRequest&, Resource*);
157 Resource* createResourceForLoading(FetchRequest&, const String& charset, con st ResourceFactory&); 157 Resource* createResourceForLoading(FetchRequest&, const String& charset, con st ResourceFactory&);
158 void storeResourceTimingInitiatorInformation(Resource*); 158 void storeResourceTimingInitiatorInformation(Resource*);
159 159
160 Resource* resourceForStaticData(const FetchRequest&, const ResourceFactory&, const SubstituteData&); 160 Resource* resourceForStaticData(const FetchRequest&, const ResourceFactory&, const SubstituteData&);
161 161
162 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496. 162 // RevalidationPolicy enum values are used in UMAs https://crbug.com/579496.
163 enum RevalidationPolicy { Use, Revalidate, Reload, Load }; 163 enum RevalidationPolicy { Use, Revalidate, Reload, Load };
164 RevalidationPolicy determineRevalidationPolicy(Resource::Type, const FetchRe quest&, Resource* existingResource, bool isStaticData) const; 164 RevalidationPolicy determineRevalidationPolicy(Resource::Type, const FetchRe quest&, Resource* existingResource, bool isStaticData) const;
165 165
166 void moveCachedNonBlockingResourceToBlocking(Resource*, const FetchRequest&) ; 166 void moveCachedNonBlockingResourceToBlocking(Resource*, const FetchRequest&) ;
167 void moveResourceLoaderToNonBlocking(ResourceLoader*); 167 void moveResourceLoaderToNonBlocking(ResourceLoader*);
168 void removeResourceLoader(ResourceLoader*); 168 void removeResourceLoader(ResourceLoader*);
169 169
170 void initializeResourceRequest(ResourceRequest&, Resource::Type, FetchReques t::DeferOption); 170 void initializeResourceRequest(ResourceRequest&, Resource::Type, FetchReques t::DeferOption);
171 void willSendRequest(unsigned long identifier, ResourceRequest&, const Resou rceResponse&, const ResourceLoaderOptions&);
171 172
172 bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPolicy); 173 bool resourceNeedsLoad(Resource*, const FetchRequest&, RevalidationPolicy);
173 bool shouldDeferImageLoad(const KURL&) const; 174 bool shouldDeferImageLoad(const KURL&) const;
174 175
175 void resourceTimingReportTimerFired(Timer<ResourceFetcher>*); 176 void resourceTimingReportTimerFired(Timer<ResourceFetcher>*);
176 177
177 void reloadImagesIfNotDeferred(); 178 void reloadImagesIfNotDeferred();
178 179
179 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques t&, const ResourceFactory&, bool isStaticData) const; 180 void updateMemoryCacheStats(Resource*, RevalidationPolicy, const FetchReques t&, const ResourceFactory&, bool isStaticData) const;
180 181
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 m_loader->m_allowStaleResources = m_previousState; 239 m_loader->m_allowStaleResources = m_previousState;
239 } 240 }
240 private: 241 private:
241 Member<ResourceFetcher> m_loader; 242 Member<ResourceFetcher> m_loader;
242 bool m_previousState; 243 bool m_previousState;
243 }; 244 };
244 245
245 } // namespace blink 246 } // namespace blink
246 247
247 #endif // ResourceFetcher_h 248 #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