// FIXME(crbug.com/352043): This is temporarily enabled even on RELEASE to diagnose a wild crash.
#define ENABLE_RESOURCE_IS_DELETED_CHECK
-namespace WebCore {
+namespace blink {
struct FetchInitiatorInfo;
class MemoryCache;
// A resource that is held in the cache. Classes who want to use this object should derive
// from ResourceClient, to get the function calls in case the requested data has arrived.
// This class also does the actual communication with the loader to obtain the resource from the network.
-class Resource {
- WTF_MAKE_NONCOPYABLE(Resource); WTF_MAKE_FAST_ALLOCATED;
+class Resource : public NoBaseWillBeGarbageCollectedFinalized<Resource> {
+ WTF_MAKE_NONCOPYABLE(Resource); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
friend class InspectorResource;
public:
};
Resource(const ResourceRequest&, Type);
+#if ENABLE(OILPAN)
virtual ~Resource();
+#else
+protected:
+ // Only deleteIfPossible should delete this.
+ virtual ~Resource();
+public:
+#endif
+ virtual void dispose();
+ virtual void trace(Visitor*);
+ static unsigned instanceCount() { return s_instanceCount; }
virtual void load(ResourceFetcher*, const ResourceLoaderOptions&);
virtual bool shouldIgnoreHTTPStatusCodeErrors() const { return false; }
- ResourceRequest& resourceRequest() { return m_resourceRequest; }
- const ResourceRequest& lastResourceRequest();
+ ResourceRequest& mutableResourceRequest() { return m_resourceRequest; }
+ const ResourceRequest& resourceRequest() const { return m_resourceRequest; }
+ const ResourceRequest& lastResourceRequest() const;
+
const KURL& url() const { return m_resourceRequest.url();}
Type type() const { return static_cast<Type>(m_type); }
const ResourceLoaderOptions& options() const { return m_options; }
// identifier that is used to distinguish data generated by the caller.
void setCachedMetadata(unsigned dataTypeID, const char*, size_t);
+ // Reset existing metadata, to allow setting new data.
+ void clearCachedMetadata();
+
// Returns cached metadata of the given type associated with this resource.
CachedMetadata* cachedMetadata(unsigned dataTypeID) const;
DataBufferingPolicy dataBufferingPolicy() const { return m_options.dataBufferingPolicy; }
void setDataBufferingPolicy(DataBufferingPolicy);
+ bool isUnusedPreload() const { return isPreloaded() && preloadResult() == PreloadNotReferenced; }
bool isPreloaded() const { return m_preloadCount; }
void increasePreloadCount() { ++m_preloadCount; }
void decreasePreloadCount() { ASSERT(m_preloadCount); --m_preloadCount; }
ResourceRequest m_resourceRequest;
AtomicString m_accept;
- RefPtr<ResourceLoader> m_loader;
+ RefPtrWillBeMember<ResourceLoader> m_loader;
ResourceLoaderOptions m_options;
ResourceResponse m_response;
// using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
// to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
// resources becomes normal resource load.
- Resource* m_resourceToRevalidate;
+ RawPtrWillBeMember<Resource> m_resourceToRevalidate;
// If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
- Resource* m_proxyResource;
+ RawPtrWillBeMember<Resource> m_proxyResource;
// These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
HashSet<ResourcePtrBase*> m_handlesToRevalidate;
// Ordered list of all redirects followed while fetching this resource.
Vector<RedirectPair> m_redirectChain;
+
+ static unsigned s_instanceCount;
};
#if !LOG_DISABLED