Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / fetch / Resource.h
index 829cd67..1574438 100644 (file)
@@ -37,7 +37,7 @@
 // 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;
@@ -53,8 +53,8 @@ class SharedBuffer;
 // 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:
@@ -83,7 +83,17 @@ 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&);
 
@@ -102,8 +112,10 @@ public:
 
     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; }
@@ -185,6 +197,9 @@ public:
     // 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;
 
@@ -203,6 +218,7 @@ public:
     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; }
@@ -316,7 +332,7 @@ protected:
 
     ResourceRequest m_resourceRequest;
     AtomicString m_accept;
-    RefPtr<ResourceLoader> m_loader;
+    RefPtrWillBeMember<ResourceLoader> m_loader;
     ResourceLoaderOptions m_options;
 
     ResourceResponse m_response;
@@ -376,16 +392,18 @@ private:
     // 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