[Webkit-unassigned] [Bug 82287] MemoryCache should adopt our standard RefCounted model for object lifetime

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu May 24 10:33:56 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=82287





--- Comment #20 from Antti Koivisto <koivisto at iki.fi>  2012-05-24 10:32:59 PST ---
(From update of attachment 143386)
View in context: https://bugs.webkit.org/attachment.cgi?id=143386&action=review

CachedResourceHandles are needed because the pointed CachedResource may change. When revalidating resources (using HTTP If-modified-since/If-none-match headers) we create a CachedResource for the validation request. If the validation fails those resources continue loading as normal. If it succeeds we switch all registered CachedResourceHandles to point to the existing CachedResource and throw the validation resource away.

A better way to do this would be to split the memory cache into data storage backend and front end resource parts. Then we could just switch the validated resource to point to the existing data (which would be shared) and CachedResourceHandles could become regular RefPtrs.

> Source/WebCore/loader/cache/CachedResourceHandle.h:77
>      template <class R> class CachedResourceHandle : public CachedResourceHandleBase {
>      public: 
>          CachedResourceHandle() { }
>          CachedResourceHandle(R* res) : CachedResourceHandleBase(res) { }
> +        CachedResourceHandle(PassRefPtr<R> res) : CachedResourceHandleBase(res) { }
>          CachedResourceHandle(const CachedResourceHandle<R>& o) : CachedResourceHandleBase(o) { }
>          template<typename U> CachedResourceHandle(const CachedResourceHandle<U>& o) : CachedResourceHandleBase(o.get()) { }
>  
>          R* get() const { return reinterpret_cast<R*>(CachedResourceHandleBase::get()); }
>          R* operator->() const { return get(); }
> -               
> +
> +        CachedResourceHandle& operator=(PassRefPtr<R> res) { setResource(res); return *this; } 
>          CachedResourceHandle& operator=(R* res) { setResource(res); return *this; } 

As long as we have CachedResourceHandle it would be safer to have a special type for passing around CachedResources. Basically we should have PassCachedResource that acts exactly like PassRefPtr but is only compatible with CachedResourceHandle constructor and operator=.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list