| 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
rights reserved. |
| 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. |
| 11 | 11 |
| 12 This library is distributed in the hope that it will be useful, | 12 This library is distributed in the hope that it will be useful, |
| 13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 Library General Public License for more details. | 15 Library General Public License for more details. |
| 16 | 16 |
| 17 You should have received a copy of the GNU Library General Public License | 17 You should have received a copy of the GNU Library General Public License |
| 18 along with this library; see the file COPYING.LIB. If not, write to | 18 along with this library; see the file COPYING.LIB. If not, write to |
| 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 20 Boston, MA 02110-1301, USA. | 20 Boston, MA 02110-1301, USA. |
| 21 */ | 21 */ |
| 22 | 22 |
| 23 #ifndef Resource_h | 23 #ifndef Resource_h |
| 24 #define Resource_h | 24 #define Resource_h |
| 25 | 25 |
| 26 #include "core/CoreExport.h" | 26 #include "core/CoreExport.h" |
| 27 #include "core/fetch/CachedMetadataHandler.h" | 27 #include "core/fetch/CachedMetadataHandler.h" |
| 28 #include "core/fetch/MultipartImageResourceParser.h" | |
| 29 #include "core/fetch/ResourceLoaderOptions.h" | 28 #include "core/fetch/ResourceLoaderOptions.h" |
| 30 #include "platform/Timer.h" | 29 #include "platform/Timer.h" |
| 31 #include "platform/network/ResourceError.h" | 30 #include "platform/network/ResourceError.h" |
| 32 #include "platform/network/ResourceLoadPriority.h" | 31 #include "platform/network/ResourceLoadPriority.h" |
| 33 #include "platform/network/ResourceRequest.h" | 32 #include "platform/network/ResourceRequest.h" |
| 34 #include "platform/network/ResourceResponse.h" | 33 #include "platform/network/ResourceResponse.h" |
| 35 #include "platform/scheduler/CancellableTaskFactory.h" | 34 #include "platform/scheduler/CancellableTaskFactory.h" |
| 36 #include "public/platform/WebDataConsumerHandle.h" | 35 #include "public/platform/WebDataConsumerHandle.h" |
| 37 #include "public/platform/WebMemoryDumpProvider.h" | 36 #include "public/platform/WebMemoryDumpProvider.h" |
| 38 #include "wtf/Allocator.h" | 37 #include "wtf/Allocator.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 class ResourceFetcher; | 52 class ResourceFetcher; |
| 54 class ResourceTimingInfo; | 53 class ResourceTimingInfo; |
| 55 class InspectorResource; | 54 class InspectorResource; |
| 56 class ResourceLoader; | 55 class ResourceLoader; |
| 57 class SecurityOrigin; | 56 class SecurityOrigin; |
| 58 class SharedBuffer; | 57 class SharedBuffer; |
| 59 | 58 |
| 60 // A resource that is held in the cache. Classes who want to use this object sho
uld derive | 59 // A resource that is held in the cache. Classes who want to use this object sho
uld derive |
| 61 // from ResourceClient, to get the function calls in case the requested data has
arrived. | 60 // from ResourceClient, to get the function calls in case the requested data has
arrived. |
| 62 // This class also does the actual communication with the loader to obtain the r
esource from the network. | 61 // This class also does the actual communication with the loader to obtain the r
esource from the network. |
| 63 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re
source>, public MultipartImageResourceParser::Client { | 62 class CORE_EXPORT Resource : public RefCountedWillBeGarbageCollectedFinalized<Re
source> { |
| 64 WTF_MAKE_NONCOPYABLE(Resource); | 63 WTF_MAKE_NONCOPYABLE(Resource); |
| 65 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource); | 64 USING_FAST_MALLOC_WITH_TYPE_NAME_WILL_BE_REMOVED(blink::Resource); |
| 66 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Resource); | |
| 67 friend class InspectorResource; | 65 friend class InspectorResource; |
| 68 | 66 |
| 69 public: | 67 public: |
| 70 enum Type { | 68 enum Type { |
| 71 MainResource, | 69 MainResource, |
| 72 Image, | 70 Image, |
| 73 CSSStyleSheet, | 71 CSSStyleSheet, |
| 74 Script, | 72 Script, |
| 75 Font, | 73 Font, |
| 76 Raw, | 74 Raw, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 99 } | 97 } |
| 100 virtual ~Resource(); | 98 virtual ~Resource(); |
| 101 | 99 |
| 102 virtual void removedFromMemoryCache(); | 100 virtual void removedFromMemoryCache(); |
| 103 DECLARE_VIRTUAL_TRACE(); | 101 DECLARE_VIRTUAL_TRACE(); |
| 104 | 102 |
| 105 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); | 103 virtual void load(ResourceFetcher*, const ResourceLoaderOptions&); |
| 106 | 104 |
| 107 virtual void setEncoding(const String&) { } | 105 virtual void setEncoding(const String&) { } |
| 108 virtual String encoding() const { return String(); } | 106 virtual String encoding() const { return String(); } |
| 109 void appendData(const char*, size_t); | 107 virtual void appendData(const char*, size_t); |
| 110 virtual void error(Resource::Status); | 108 virtual void error(Resource::Status); |
| 111 virtual void setCORSFailed() { } | 109 virtual void setCORSFailed() { } |
| 112 | 110 |
| 113 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn
chronousCacheHit = needsSynchronousCacheHit; } | 111 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn
chronousCacheHit = needsSynchronousCacheHit; } |
| 114 | 112 |
| 115 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } | 113 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } |
| 116 bool isLinkPreload() const { return m_linkPreload; } | 114 bool isLinkPreload() const { return m_linkPreload; } |
| 117 | 115 |
| 118 void setResourceError(const ResourceError& error) { m_error = error; } | 116 void setResourceError(const ResourceError& error) { m_error = error; } |
| 119 const ResourceError& resourceError() const { return m_error; } | 117 const ResourceError& resourceError() const { return m_error; } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 168 |
| 171 ResourceLoader* loader() const { return m_loader.get(); } | 169 ResourceLoader* loader() const { return m_loader.get(); } |
| 172 | 170 |
| 173 virtual bool isImage() const { return false; } | 171 virtual bool isImage() const { return false; } |
| 174 bool shouldBlockLoadEvent() const; | 172 bool shouldBlockLoadEvent() const; |
| 175 bool isLoadEventBlockingResourceType() const; | 173 bool isLoadEventBlockingResourceType() const; |
| 176 | 174 |
| 177 // Computes the status of an object after loading. | 175 // Computes the status of an object after loading. |
| 178 // Updates the expire date on the cache entry file | 176 // Updates the expire date on the cache entry file |
| 179 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } | 177 void setLoadFinishTime(double finishTime) { m_loadFinishTime = finishTime; } |
| 180 void finish(); | 178 virtual void finish(); |
| 181 | 179 |
| 182 // FIXME: Remove the stringless variant once all the callsites' error messag
es are updated. | 180 // FIXME: Remove the stringless variant once all the callsites' error messag
es are updated. |
| 183 bool passesAccessControlCheck(SecurityOrigin*) const; | 181 bool passesAccessControlCheck(SecurityOrigin*) const; |
| 184 bool passesAccessControlCheck(SecurityOrigin*, String& errorDescription) con
st; | 182 bool passesAccessControlCheck(SecurityOrigin*, String& errorDescription) con
st; |
| 185 | 183 |
| 186 bool isEligibleForIntegrityCheck(SecurityOrigin*) const; | 184 bool isEligibleForIntegrityCheck(SecurityOrigin*) const; |
| 187 | 185 |
| 188 void clearLoader(); | 186 void clearLoader(); |
| 189 | 187 |
| 190 SharedBuffer* resourceBuffer() const { return m_data.get(); } | 188 SharedBuffer* resourceBuffer() const { return m_data.get(); } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 void prune(); | 253 void prune(); |
| 256 | 254 |
| 257 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*)
const; | 255 virtual void onMemoryDump(WebMemoryDumpLevelOfDetail, WebProcessMemoryDump*)
const; |
| 258 | 256 |
| 259 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); | 257 static const char* resourceTypeToString(Type, const FetchInitiatorInfo&); |
| 260 static const char* resourceTypeName(Type); | 258 static const char* resourceTypeName(Type); |
| 261 | 259 |
| 262 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. | 260 // TODO(japhet): Remove once oilpan ships, it doesn't need the WeakPtr. |
| 263 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); | 261 WeakPtrWillBeRawPtr<Resource> asWeakPtr(); |
| 264 | 262 |
| 265 bool isMultipartImage() const; | |
| 266 | |
| 267 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK | 263 #ifdef ENABLE_RESOURCE_IS_DELETED_CHECK |
| 268 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } | 264 void assertAlive() const { RELEASE_ASSERT(!m_deleted); } |
| 269 #else | 265 #else |
| 270 void assertAlive() const { } | 266 void assertAlive() const { } |
| 271 #endif | 267 #endif |
| 272 | 268 |
| 273 // MultipartImageResourceParser::Client | |
| 274 void onePartInMultipartReceived(const ResourceResponse&) final; | |
| 275 void multipartDataReceived(const char*, size_t) final; | |
| 276 | |
| 277 protected: | 269 protected: |
| 278 Resource(const ResourceRequest&, Type); | 270 Resource(const ResourceRequest&, Type); |
| 279 | 271 |
| 280 virtual void checkNotify(); | 272 virtual void checkNotify(); |
| 281 virtual void finishOnePart(); | |
| 282 | 273 |
| 283 virtual void destroyDecodedDataForFailedRevalidation() { } | 274 virtual void destroyDecodedDataForFailedRevalidation() { } |
| 284 virtual void appendDataInternal(const char*, size_t); | |
| 285 | 275 |
| 286 void setEncodedSize(size_t); | 276 void setEncodedSize(size_t); |
| 287 void setDecodedSize(size_t); | 277 void setDecodedSize(size_t); |
| 288 void didAccessDecodedData(); | 278 void didAccessDecodedData(); |
| 289 | 279 |
| 290 void finishPendingClients(); | 280 void finishPendingClients(); |
| 291 | 281 |
| 292 HashCountedSet<ResourceClient*> m_clients; | 282 HashCountedSet<ResourceClient*> m_clients; |
| 293 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; | 283 HashCountedSet<ResourceClient*> m_clientsAwaitingCallback; |
| 294 HashCountedSet<ResourceClient*> m_finishedClients; | 284 HashCountedSet<ResourceClient*> m_finishedClients; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; | 347 CachedMetadata* cachedMetadata(unsigned dataTypeID) const; |
| 358 | 348 |
| 359 String m_fragmentIdentifierForRequest; | 349 String m_fragmentIdentifierForRequest; |
| 360 | 350 |
| 361 #if !ENABLE(OILPAN) | 351 #if !ENABLE(OILPAN) |
| 362 WeakPtrFactory<Resource> m_weakPtrFactory; | 352 WeakPtrFactory<Resource> m_weakPtrFactory; |
| 363 #endif | 353 #endif |
| 364 | 354 |
| 365 RefPtr<CachedMetadata> m_cachedMetadata; | 355 RefPtr<CachedMetadata> m_cachedMetadata; |
| 366 OwnPtrWillBeMember<CacheHandler> m_cacheHandler; | 356 OwnPtrWillBeMember<CacheHandler> m_cacheHandler; |
| 367 PersistentWillBeMember<MultipartImageResourceParser> m_multipartParser; | |
| 368 | 357 |
| 369 ResourceError m_error; | 358 ResourceError m_error; |
| 370 | 359 |
| 371 double m_loadFinishTime; | 360 double m_loadFinishTime; |
| 372 | 361 |
| 373 unsigned long m_identifier; | 362 unsigned long m_identifier; |
| 374 | 363 |
| 375 size_t m_encodedSize; | 364 size_t m_encodedSize; |
| 376 size_t m_decodedSize; | 365 size_t m_decodedSize; |
| 377 unsigned m_preloadCount; | 366 unsigned m_preloadCount; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 Resource::Type m_type; | 398 Resource::Type m_type; |
| 410 }; | 399 }; |
| 411 | 400 |
| 412 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 401 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 413 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ | 402 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); \ |
| 414 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } | 403 inline typeName##Resource* to##typeName##Resource(const RefPtrWillBeRawPtr<R
esource>& ptr) { return to##typeName##Resource(ptr.get()); } |
| 415 | 404 |
| 416 } // namespace blink | 405 } // namespace blink |
| 417 | 406 |
| 418 #endif | 407 #endif |
| OLD | NEW |