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 | 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All |
6 rights reserved. | 6 rights reserved. |
7 | 7 |
8 This library is free software; you can redistribute it and/or | 8 This library is free software; you can redistribute it and/or |
9 modify it under the terms of the GNU Library General Public | 9 modify it under the terms of the GNU Library General Public |
10 License as published by the Free Software Foundation; either | 10 License as published by the Free Software Foundation; either |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 kReloadAlways, | 109 kReloadAlways, |
110 }; | 110 }; |
111 | 111 |
112 virtual ~Resource(); | 112 virtual ~Resource(); |
113 | 113 |
114 DECLARE_VIRTUAL_TRACE(); | 114 DECLARE_VIRTUAL_TRACE(); |
115 | 115 |
116 virtual void setEncoding(const String&) {} | 116 virtual void setEncoding(const String&) {} |
117 virtual String encoding() const { return String(); } | 117 virtual String encoding() const { return String(); } |
118 virtual void appendData(const char*, size_t); | 118 virtual void appendData(const char*, size_t); |
119 virtual void error(const ResourceError&); | 119 // LoFi images can be reloaded using |fetcherForReload| (if non-null). |
120 virtual void error(const ResourceError&, | |
121 ResourceFetcher* fetcherForReload = nullptr); | |
120 virtual void setCORSFailed() {} | 122 virtual void setCORSFailed() {} |
121 | 123 |
122 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { | 124 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { |
123 m_needsSynchronousCacheHit = needsSynchronousCacheHit; | 125 m_needsSynchronousCacheHit = needsSynchronousCacheHit; |
124 } | 126 } |
125 | 127 |
126 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } | 128 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } |
127 bool isLinkPreload() const { return m_linkPreload; } | 129 bool isLinkPreload() const { return m_linkPreload; } |
128 | 130 |
129 void setPreloadDiscoveryTime(double preloadDiscoveryTime) { | 131 void setPreloadDiscoveryTime(double preloadDiscoveryTime) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 | 206 |
205 void setLoader(ResourceLoader*); | 207 void setLoader(ResourceLoader*); |
206 ResourceLoader* loader() const { return m_loader.get(); } | 208 ResourceLoader* loader() const { return m_loader.get(); } |
207 | 209 |
208 virtual bool isImage() const { return false; } | 210 virtual bool isImage() const { return false; } |
209 bool shouldBlockLoadEvent() const; | 211 bool shouldBlockLoadEvent() const; |
210 bool isLoadEventBlockingResourceType() const; | 212 bool isLoadEventBlockingResourceType() const; |
211 | 213 |
212 // Computes the status of an object after loading. Updates the expire date on | 214 // Computes the status of an object after loading. Updates the expire date on |
213 // the cache entry file | 215 // the cache entry file |
214 virtual void finish(double finishTime); | 216 // LoFi images can be reloaded using |fetcherForReload| (if non-null). |
217 virtual void finish(double finishTime, | |
218 ResourceFetcher* fetcherForReload = nullptr); | |
215 void finish() { finish(0.0); } | 219 void finish() { finish(0.0); } |
216 | 220 |
217 // FIXME: Remove the stringless variant once all the callsites' error messages | 221 // FIXME: Remove the stringless variant once all the callsites' error messages |
218 // are updated. | 222 // are updated. |
219 bool passesAccessControlCheck(SecurityOrigin*) const; | 223 bool passesAccessControlCheck(SecurityOrigin*) const; |
220 bool passesAccessControlCheck(SecurityOrigin*, | 224 bool passesAccessControlCheck(SecurityOrigin*, |
221 String& errorDescription) const; | 225 String& errorDescription) const; |
222 | 226 |
223 virtual PassRefPtr<const SharedBuffer> resourceBuffer() const { | 227 virtual PassRefPtr<const SharedBuffer> resourceBuffer() const { |
224 return m_data; | 228 return m_data; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 | 341 |
338 // Used by the MemoryCache to reduce the memory consumption of the entry. | 342 // Used by the MemoryCache to reduce the memory consumption of the entry. |
339 void prune(); | 343 void prune(); |
340 | 344 |
341 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, | 345 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, |
342 WebProcessMemoryDump*) const; | 346 WebProcessMemoryDump*) const; |
343 | 347 |
344 // If this Resource is ImageResource and has the Lo-Fi response headers or is | 348 // If this Resource is ImageResource and has the Lo-Fi response headers or is |
345 // a placeholder, reload the full original image with the Lo-Fi state set to | 349 // a placeholder, reload the full original image with the Lo-Fi state set to |
346 // off and optionally bypassing the cache. | 350 // off and optionally bypassing the cache. |
347 virtual void reloadIfLoFiOrPlaceholderImage(ResourceFetcher*, | 351 // If reloading is started, this method returns a new Resource that is used |
348 ReloadLoFiOrPlaceholderPolicy) {} | 352 // for reloading, and |this| should be no longer used. |
353 // Otherwise, this method returns nullptr. | |
354 virtual Resource* reloadIfLoFiOrPlaceholderImage( | |
Nate Chapin
2016/12/28 00:14:57
Can we delete this from Resource entirely? It seem
hiroshige
2016/12/28 01:04:21
This virtual method would remain after this CL for
| |
355 ResourceFetcher*, | |
356 ReloadLoFiOrPlaceholderPolicy) { | |
357 return nullptr; | |
358 } | |
349 | 359 |
350 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); | 360 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); |
351 | 361 |
352 protected: | 362 protected: |
353 Resource(const ResourceRequest&, Type, const ResourceLoaderOptions&); | 363 Resource(const ResourceRequest&, Type, const ResourceLoaderOptions&); |
354 | 364 |
355 virtual void checkNotify(); | 365 virtual void checkNotify(); |
356 | 366 |
357 void markClientFinished(ResourceClient*); | 367 void markClientFinished(ResourceClient*); |
358 | 368 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
394 | 404 |
395 virtual void destroyDecodedDataIfPossible() {} | 405 virtual void destroyDecodedDataIfPossible() {} |
396 | 406 |
397 // Returns the memory dump name used for tracing. See Resource::onMemoryDump. | 407 // Returns the memory dump name used for tracing. See Resource::onMemoryDump. |
398 String getMemoryDumpName() const; | 408 String getMemoryDumpName() const; |
399 | 409 |
400 const HeapHashCountedSet<WeakMember<ResourceClient>>& clients() const { | 410 const HeapHashCountedSet<WeakMember<ResourceClient>>& clients() const { |
401 return m_clients; | 411 return m_clients; |
402 } | 412 } |
403 | 413 |
404 void setCachePolicyBypassingCache(); | |
405 void setLoFiStateOff(); | |
406 void clearRangeRequestHeader(); | |
407 | |
408 SharedBuffer* data() const { return m_data.get(); } | 414 SharedBuffer* data() const { return m_data.get(); } |
409 void clearData(); | 415 void clearData(); |
410 | 416 |
411 class ProhibitAddRemoveClientInScope : public AutoReset<bool> { | 417 class ProhibitAddRemoveClientInScope : public AutoReset<bool> { |
412 public: | 418 public: |
413 ProhibitAddRemoveClientInScope(Resource* resource) | 419 ProhibitAddRemoveClientInScope(Resource* resource) |
414 : AutoReset(&resource->m_isAddRemoveClientProhibited, true) {} | 420 : AutoReset(&resource->m_isAddRemoveClientProhibited, true) {} |
415 }; | 421 }; |
416 | 422 |
417 private: | 423 private: |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 }; | 511 }; |
506 | 512 |
507 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 513 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
508 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ | 514 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, \ |
509 resource->getType() == Resource::typeName, \ | 515 resource->getType() == Resource::typeName, \ |
510 resource.getType() == Resource::typeName); | 516 resource.getType() == Resource::typeName); |
511 | 517 |
512 } // namespace blink | 518 } // namespace blink |
513 | 519 |
514 #endif | 520 #endif |
OLD | NEW |