Chromium Code Reviews| Index: third_party/WebKit/Source/core/fetch/ResourceOwner.h |
| diff --git a/third_party/WebKit/Source/core/fetch/ResourceOwner.h b/third_party/WebKit/Source/core/fetch/ResourceOwner.h |
| index 20a464cfb347ff4b3a6d84617f3cd8bc2de6263c..f4b4dd3ff95a536615cae51ccc2453816ab09283 100644 |
| --- a/third_party/WebKit/Source/core/fetch/ResourceOwner.h |
| +++ b/third_party/WebKit/Source/core/fetch/ResourceOwner.h |
| @@ -37,7 +37,8 @@ namespace blink { |
| template<class R, class C = typename R::ClientType> |
| -class ResourceOwner : public C { |
| +class ResourceOwner : public WillBeGarbageCollectedMixin, public C { |
| + WILL_BE_USING_PRE_FINALIZER(ResourceOwner, clearResource); |
| public: |
| using ResourceType = R; |
| @@ -46,13 +47,9 @@ public: |
| protected: |
| ResourceOwner(); |
| - ResourceOwner(const ResourceOwner& other) { setResource(other.resource()); } |
| - explicit ResourceOwner(const ResourcePtr<ResourceType>&); |
| void setResource(const ResourcePtr<ResourceType>&); |
| - void clearResource(); |
| - |
| - ResourceOwner& operator=(const ResourceOwner& other); |
| + void clearResource() { setResource(nullptr); } |
| private: |
| ResourcePtr<ResourceType> m_resource; |
| @@ -61,20 +58,17 @@ private: |
| template<class R, class C> |
| inline ResourceOwner<R, C>::ResourceOwner() |
| { |
| +#if ENABLE(OILPAN) |
| + ThreadState::current()->registerPreFinalizer(this); |
| +#endif |
| } |
| template<class R, class C> |
| inline ResourceOwner<R, C>::~ResourceOwner() |
| { |
| +#if !ENABLE(OILPAN) |
| clearResource(); |
| -} |
| - |
| -template<class R, class C> |
| -inline ResourceOwner<R, C>::ResourceOwner(const ResourcePtr<R>& resource) |
| - : m_resource(resource) |
| -{ |
| - if (m_resource) |
| - m_resource->addClient(this); |
| +#endif |
|
haraken
2016/01/14 04:26:43
Nit: In this CL it is safe to call clearResource i
yhirano
2016/01/14 11:55:29
Oh, it's my fault, sorry.
Nate Chapin
2016/01/14 22:54:01
Yeah, I should have caught that, too. Removing.
|
| } |
| template<class R, class C> |
| @@ -96,21 +90,6 @@ inline void ResourceOwner<R, C>::setResource(const ResourcePtr<R>& newResource) |
| } |
| } |
| -template<class R, class C> |
| -inline void ResourceOwner<R, C>::clearResource() |
| -{ |
| - setResource(0); |
| -} |
| - |
| -template<class R, class C> |
| -inline ResourceOwner<R, C>& ResourceOwner<R, C>::operator=(const ResourceOwner<R, C>& other) |
| -{ |
| - if (this == &other) |
| - return *this; |
| - setResource(other.resource()); |
| - return *this; |
| -} |
| - |
| } // namespace blink |
| #endif |