| 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. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "wtf/HashSet.h" | 39 #include "wtf/HashSet.h" |
| 40 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
| 41 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 struct FetchInitiatorInfo; | 45 struct FetchInitiatorInfo; |
| 46 class CachedMetadata; | 46 class CachedMetadata; |
| 47 class FetchRequest; | 47 class FetchRequest; |
| 48 class ResourceClient; | 48 class ResourceClient; |
| 49 class ResourceFetcher; | |
| 50 class ResourceTimingInfo; | 49 class ResourceTimingInfo; |
| 51 class ResourceLoader; | 50 class ResourceLoader; |
| 52 class SecurityOrigin; | 51 class SecurityOrigin; |
| 53 class SharedBuffer; | 52 class SharedBuffer; |
| 54 | 53 |
| 55 // A resource that is held in the cache. Classes who want to use this object sho
uld derive | 54 // A resource that is held in the cache. Classes who want to use this object sho
uld derive |
| 56 // from ResourceClient, to get the function calls in case the requested data has
arrived. | 55 // from ResourceClient, to get the function calls in case the requested data has
arrived. |
| 57 // This class also does the actual communication with the loader to obtain the r
esource from the network. | 56 // This class also does the actual communication with the loader to obtain the r
esource from the network. |
| 58 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> { | 57 class CORE_EXPORT Resource : public GarbageCollectedFinalized<Resource> { |
| 59 WTF_MAKE_NONCOPYABLE(Resource); | 58 WTF_MAKE_NONCOPYABLE(Resource); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 | 84 |
| 86 // Exposed for testing. | 85 // Exposed for testing. |
| 87 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) | 86 static Resource* create(const ResourceRequest& request, Type type, const Res
ourceLoaderOptions& options = ResourceLoaderOptions()) |
| 88 { | 87 { |
| 89 return new Resource(request, type, options); | 88 return new Resource(request, type, options); |
| 90 } | 89 } |
| 91 virtual ~Resource(); | 90 virtual ~Resource(); |
| 92 | 91 |
| 93 DECLARE_VIRTUAL_TRACE(); | 92 DECLARE_VIRTUAL_TRACE(); |
| 94 | 93 |
| 95 void load(ResourceFetcher*); | |
| 96 | |
| 97 virtual void setEncoding(const String&) { } | 94 virtual void setEncoding(const String&) { } |
| 98 virtual String encoding() const { return String(); } | 95 virtual String encoding() const { return String(); } |
| 99 virtual void appendData(const char*, size_t); | 96 virtual void appendData(const char*, size_t); |
| 100 virtual void error(const ResourceError&); | 97 virtual void error(const ResourceError&); |
| 101 virtual void setCORSFailed() { } | 98 virtual void setCORSFailed() { } |
| 102 | 99 |
| 103 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn
chronousCacheHit = needsSynchronousCacheHit; } | 100 void setNeedsSynchronousCacheHit(bool needsSynchronousCacheHit) { m_needsSyn
chronousCacheHit = needsSynchronousCacheHit; } |
| 104 | 101 |
| 105 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } | 102 void setLinkPreload(bool isLinkPreload) { m_linkPreload = isLinkPreload; } |
| 106 bool isLinkPreload() const { return m_linkPreload; } | 103 bool isLinkPreload() const { return m_linkPreload; } |
| 107 | 104 |
| 108 void setPreloadDiscoveryTime(double preloadDiscoveryTime) { m_preloadDiscove
ryTime = preloadDiscoveryTime; } | 105 void setPreloadDiscoveryTime(double preloadDiscoveryTime) { m_preloadDiscove
ryTime = preloadDiscoveryTime; } |
| 109 | 106 |
| 110 const ResourceError& resourceError() const { return m_error; } | 107 const ResourceError& resourceError() const { return m_error; } |
| 111 | 108 |
| 112 void setIdentifier(unsigned long identifier) { m_identifier = identifier; } | 109 void setIdentifier(unsigned long identifier) { m_identifier = identifier; } |
| 113 unsigned long identifier() const { return m_identifier; } | 110 unsigned long identifier() const { return m_identifier; } |
| 114 | 111 |
| 115 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } | 112 virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; } |
| 116 | 113 |
| 117 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } | 114 const ResourceRequest& resourceRequest() const { return m_resourceRequest; } |
| 118 const ResourceRequest& lastResourceRequest() const; | 115 const ResourceRequest& lastResourceRequest() const; |
| 119 | 116 |
| 120 virtual void setRevalidatingRequest(const ResourceRequest&); | 117 virtual void setRevalidatingRequest(const ResourceRequest&); |
| 121 | 118 |
| 119 void setFetcherSecurityOrigin(SecurityOrigin* origin) { m_fetcherSecurityOri
gin = origin; } |
| 120 |
| 122 // This url can have a fragment, but it can match resources that differ by t
he fragment only. | 121 // This url can have a fragment, but it can match resources that differ by t
he fragment only. |
| 123 const KURL& url() const { return m_resourceRequest.url();} | 122 const KURL& url() const { return m_resourceRequest.url();} |
| 124 Type getType() const { return static_cast<Type>(m_type); } | 123 Type getType() const { return static_cast<Type>(m_type); } |
| 125 const ResourceLoaderOptions& options() const { return m_options; } | 124 const ResourceLoaderOptions& options() const { return m_options; } |
| 126 ResourceLoaderOptions& mutableOptions() { return m_options; } | 125 ResourceLoaderOptions& mutableOptions() { return m_options; } |
| 127 | 126 |
| 128 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); | 127 void didChangePriority(ResourceLoadPriority, int intraPriorityValue); |
| 129 virtual ResourcePriority priorityFromObservers() { return ResourcePriority()
; } | 128 virtual ResourcePriority priorityFromObservers() { return ResourcePriority()
; } |
| 130 | 129 |
| 131 void addClient(ResourceClient*); | 130 void addClient(ResourceClient*); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 148 size_t size() const { return encodedSize() + decodedSize() + overheadSize();
} | 147 size_t size() const { return encodedSize() + decodedSize() + overheadSize();
} |
| 149 size_t encodedSize() const { return m_encodedSize; } | 148 size_t encodedSize() const { return m_encodedSize; } |
| 150 size_t decodedSize() const { return m_decodedSize; } | 149 size_t decodedSize() const { return m_decodedSize; } |
| 151 size_t overheadSize() const { return m_overheadSize; } | 150 size_t overheadSize() const { return m_overheadSize; } |
| 152 | 151 |
| 153 bool isLoaded() const { return m_status > Pending; } | 152 bool isLoaded() const { return m_status > Pending; } |
| 154 | 153 |
| 155 bool isLoading() const { return m_status == Pending; } | 154 bool isLoading() const { return m_status == Pending; } |
| 156 bool stillNeedsLoad() const { return m_status < Pending; } | 155 bool stillNeedsLoad() const { return m_status < Pending; } |
| 157 | 156 |
| 157 void setLoader(ResourceLoader*); |
| 158 ResourceLoader* loader() const { return m_loader.get(); } | 158 ResourceLoader* loader() const { return m_loader.get(); } |
| 159 | 159 |
| 160 virtual bool isImage() const { return false; } | 160 virtual bool isImage() const { return false; } |
| 161 bool shouldBlockLoadEvent() const; | 161 bool shouldBlockLoadEvent() const; |
| 162 bool isLoadEventBlockingResourceType() const; | 162 bool isLoadEventBlockingResourceType() const; |
| 163 | 163 |
| 164 // Computes the status of an object after loading. | 164 // Computes the status of an object after loading. |
| 165 // Updates the expire date on the cache entry file | 165 // Updates the expire date on the cache entry file |
| 166 virtual void finish(double finishTime); | 166 virtual void finish(double finishTime); |
| 167 void finish() { finish(0.0); } | 167 void finish() { finish(0.0); } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 361 |
| 362 Resource::Type m_type; | 362 Resource::Type m_type; |
| 363 }; | 363 }; |
| 364 | 364 |
| 365 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ | 365 #define DEFINE_RESOURCE_TYPE_CASTS(typeName) \ |
| 366 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); | 366 DEFINE_TYPE_CASTS(typeName##Resource, Resource, resource, resource->getType(
) == Resource::typeName, resource.getType() == Resource::typeName); |
| 367 | 367 |
| 368 } // namespace blink | 368 } // namespace blink |
| 369 | 369 |
| 370 #endif | 370 #endif |
| OLD | NEW |