OLD | NEW |
---|---|
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) 2006 Samuel Weinig (sam.weinig@gmail.com) | 4 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) |
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 rights reserved. | |
Yoav Weiss
2016/10/03 08:52:20
indentation?
Charlie Harrison
2016/10/03 12:36:54
Done.
| |
6 | 7 |
7 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
8 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
9 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
10 version 2 of the License, or (at your option) any later version. | 11 version 2 of the License, or (at your option) any later version. |
11 | 12 |
12 This library is distributed in the hope that it will be useful, | 13 This library is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 Library General Public License for more details. | 16 Library General Public License for more details. |
(...skipping 29 matching lines...) Expand all Loading... | |
45 namespace blink { | 46 namespace blink { |
46 | 47 |
47 struct FetchInitiatorInfo; | 48 struct FetchInitiatorInfo; |
48 class CachedMetadata; | 49 class CachedMetadata; |
49 class FetchRequest; | 50 class FetchRequest; |
50 class ResourceClient; | 51 class ResourceClient; |
51 class ResourceTimingInfo; | 52 class ResourceTimingInfo; |
52 class ResourceLoader; | 53 class ResourceLoader; |
53 class SecurityOrigin; | 54 class SecurityOrigin; |
54 | 55 |
55 // A resource that is held in the cache. Classes who want to use this object sho uld derive | 56 // A resource that is held in the cache. Classes who want to use this object |
56 // from ResourceClient, to get the function calls in case the requested data has arrived. | 57 // should derive from ResourceClient, to get the function calls in case the |
57 // This class also does the actual communication with the loader to obtain the r esource from the network. | 58 // requested data has arrived. This class also does the actual communication |
59 // with the loader to obtain the resource from the network. | |
58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource>, | 60 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource>, |
59 public MemoryCoordinatorClient { | 61 public MemoryCoordinatorClient { |
60 USING_GARBAGE_COLLECTED_MIXIN(Resource); | 62 USING_GARBAGE_COLLECTED_MIXIN(Resource); |
61 WTF_MAKE_NONCOPYABLE(Resource); | 63 WTF_MAKE_NONCOPYABLE(Resource); |
62 | 64 |
63 public: | 65 public: |
64 // |Type| enum values are used in UMAs, so do not change the values of | 66 // |Type| enum values are used in UMAs, so do not change the values of |
65 // existing |Type|. When adding a new |Type|, append it at the end and | 67 // existing |Type|. When adding a new |Type|, append it at the end and update |
66 // update |kLastResourceType|. | 68 // |kLastResourceType|. |
67 enum Type { | 69 enum Type { |
68 MainResource, | 70 MainResource, |
69 Image, | 71 Image, |
70 CSSStyleSheet, | 72 CSSStyleSheet, |
71 Script, | 73 Script, |
72 Font, | 74 Font, |
73 Raw, | 75 Raw, |
74 SVGDocument, | 76 SVGDocument, |
75 XSLStyleSheet, | 77 XSLStyleSheet, |
76 LinkPrefetch, | 78 LinkPrefetch, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
133 | 135 |
134 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } | 136 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } |
135 const ResourceRequest& lastResourceRequest() const; | 137 const ResourceRequest& lastResourceRequest() const; |
136 | 138 |
137 virtual void setRevalidatingRequest(const ResourceRequest&); | 139 virtual void setRevalidatingRequest(const ResourceRequest&); |
138 | 140 |
139 void setFetcherSecurityOrigin(SecurityOrigin* origin) { | 141 void setFetcherSecurityOrigin(SecurityOrigin* origin) { |
140 m_fetcherSecurityOrigin = origin; | 142 m_fetcherSecurityOrigin = origin; |
141 } | 143 } |
142 | 144 |
143 // This url can have a fragment, but it can match resources that differ by the fragment only. | 145 // This url can have a fragment, but it can match resources that differ by the |
146 // fragment only. | |
144 const KURL& url() const { return m_resourceRequest.url(); } | 147 const KURL& url() const { return m_resourceRequest.url(); } |
145 Type getType() const { return static_cast<Type>(m_type); } | 148 Type getType() const { return static_cast<Type>(m_type); } |
146 const ResourceLoaderOptions& options() const { return m_options; } | 149 const ResourceLoaderOptions& options() const { return m_options; } |
147 ResourceLoaderOptions& mutableOptions() { return m_options; } | 150 ResourceLoaderOptions& mutableOptions() { return m_options; } |
148 | 151 |
149 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 152 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
150 virtual ResourcePriority priorityFromObservers() { | 153 virtual ResourcePriority priorityFromObservers() { |
151 return ResourcePriority(); | 154 return ResourcePriority(); |
152 } | 155 } |
153 | 156 |
(...skipping 26 matching lines...) Expand all Loading... | |
180 bool isLoading() const { return m_status == Pending; } | 183 bool isLoading() const { return m_status == Pending; } |
181 bool stillNeedsLoad() const { return m_status < Pending; } | 184 bool stillNeedsLoad() const { return m_status < Pending; } |
182 | 185 |
183 void setLoader(ResourceLoader*); | 186 void setLoader(ResourceLoader*); |
184 ResourceLoader* loader() const { return m_loader.get(); } | 187 ResourceLoader* loader() const { return m_loader.get(); } |
185 | 188 |
186 virtual bool isImage() const { return false; } | 189 virtual bool isImage() const { return false; } |
187 bool shouldBlockLoadEvent() const; | 190 bool shouldBlockLoadEvent() const; |
188 bool isLoadEventBlockingResourceType() const; | 191 bool isLoadEventBlockingResourceType() const; |
189 | 192 |
190 // Computes the status of an object after loading. | 193 // Computes the status of an object after loading. Updates the expire date on |
191 // Updates the expire date on the cache entry file | 194 // the cache entry file |
192 virtual void finish(double finishTime); | 195 virtual void finish(double finishTime); |
193 void finish() { finish(0.0); } | 196 void finish() { finish(0.0); } |
194 | 197 |
195 // FIXME: Remove the stringless variant once all the callsites' error messages are updated. | 198 // FIXME: Remove the stringless variant once all the callsites' error messages |
199 // are updated. | |
196 bool passesAccessControlCheck(SecurityOrigin*) const; | 200 bool passesAccessControlCheck(SecurityOrigin*) const; |
197 bool passesAccessControlCheck(SecurityOrigin*, | 201 bool passesAccessControlCheck(SecurityOrigin*, |
198 String& errorDescription) const; | 202 String& errorDescription) const; |
199 | 203 |
200 bool isEligibleForIntegrityCheck(SecurityOrigin*) const; | 204 bool isEligibleForIntegrityCheck(SecurityOrigin*) const; |
201 | 205 |
202 virtual PassRefPtr<const SharedBuffer> resourceBuffer() const { | 206 virtual PassRefPtr<const SharedBuffer> resourceBuffer() const { |
203 return m_data; | 207 return m_data; |
204 } | 208 } |
205 void setResourceBuffer(PassRefPtr<SharedBuffer>); | 209 void setResourceBuffer(PassRefPtr<SharedBuffer>); |
206 | 210 |
207 virtual void willFollowRedirect(ResourceRequest&, const ResourceResponse&); | 211 virtual void willFollowRedirect(ResourceRequest&, const ResourceResponse&); |
208 | 212 |
209 // Called when a redirect response was received but a decision has | 213 // Called when a redirect response was received but a decision has already |
210 // already been made to not follow it. | 214 // been made to not follow it. |
211 virtual void willNotFollowRedirect() {} | 215 virtual void willNotFollowRedirect() {} |
212 | 216 |
213 virtual void responseReceived(const ResourceResponse&, | 217 virtual void responseReceived(const ResourceResponse&, |
214 std::unique_ptr<WebDataConsumerHandle>); | 218 std::unique_ptr<WebDataConsumerHandle>); |
215 void setResponse(const ResourceResponse&); | 219 void setResponse(const ResourceResponse&); |
216 const ResourceResponse& response() const { return m_response; } | 220 const ResourceResponse& response() const { return m_response; } |
217 | 221 |
218 virtual void reportResourceTimingToClients(const ResourceTimingInfo&) {} | 222 virtual void reportResourceTimingToClients(const ResourceTimingInfo&) {} |
219 | 223 |
220 // Sets the serialized metadata retrieved from the platform's cache. | 224 // Sets the serialized metadata retrieved from the platform's cache. |
221 virtual void setSerializedCachedMetadata(const char*, size_t); | 225 virtual void setSerializedCachedMetadata(const char*, size_t); |
222 | 226 |
223 // This may return nullptr when the resource isn't cacheable. | 227 // This may return nullptr when the resource isn't cacheable. |
224 CachedMetadataHandler* cacheHandler(); | 228 CachedMetadataHandler* cacheHandler(); |
225 | 229 |
226 AtomicString httpContentType() const; | 230 AtomicString httpContentType() const; |
227 | 231 |
228 bool wasCanceled() const { return m_error.isCancellation(); } | 232 bool wasCanceled() const { return m_error.isCancellation(); } |
229 bool errorOccurred() const { | 233 bool errorOccurred() const { |
230 return m_status == LoadError || m_status == DecodeError; | 234 return m_status == LoadError || m_status == DecodeError; |
231 } | 235 } |
232 bool loadFailedOrCanceled() { return !m_error.isNull(); } | 236 bool loadFailedOrCanceled() { return !m_error.isNull(); } |
233 | 237 |
234 DataBufferingPolicy getDataBufferingPolicy() const { | 238 DataBufferingPolicy getDataBufferingPolicy() const { |
235 return m_options.dataBufferingPolicy; | 239 return m_options.dataBufferingPolicy; |
236 } | 240 } |
237 void setDataBufferingPolicy(DataBufferingPolicy); | 241 void setDataBufferingPolicy(DataBufferingPolicy); |
238 | 242 |
239 // The isPreloaded() flag is using a counter in order to make sure that even w hen | 243 // The isPreloaded() flag is using a counter in order to make sure that even |
240 // multiple ResourceFetchers are preloading the resource, it will remain marke d as | 244 // when multiple ResourceFetchers are preloading the resource, it will remain |
241 // preloaded until *all* of them have used it. | 245 // marked as preloaded until *all* of them have used it. |
242 bool isUnusedPreload() const { | 246 bool isUnusedPreload() const { |
243 return isPreloaded() && getPreloadResult() == PreloadNotReferenced; | 247 return isPreloaded() && getPreloadResult() == PreloadNotReferenced; |
244 } | 248 } |
245 bool isPreloaded() const { return m_preloadCount; } | 249 bool isPreloaded() const { return m_preloadCount; } |
246 void increasePreloadCount() { ++m_preloadCount; } | 250 void increasePreloadCount() { ++m_preloadCount; } |
247 void decreasePreloadCount() { | 251 void decreasePreloadCount() { |
248 DCHECK(m_preloadCount); | 252 DCHECK(m_preloadCount); |
249 --m_preloadCount; | 253 --m_preloadCount; |
250 } | 254 } |
251 | 255 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 }; | 449 }; |
446 | 450 |
447 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 451 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
448 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ | 452 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ |
449 resource->getType() == Resource::typeName, \ | 453 resource->getType() == Resource::typeName, \ |
450 resource.getType() == Resource::typeName); | 454 resource.getType() == Resource::typeName); |
451 | 455 |
452 } // namespace blink | 456 } // namespace blink |
453 | 457 |
454 #endif | 458 #endif |
OLD | NEW |