| 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 b2a45d081905ca96a2849550387d545276b2135f..a8e9c22169053e9e31f8e34369cfe0597aaf0268 100644
|
| --- a/third_party/WebKit/Source/core/fetch/ResourceOwner.h
|
| +++ b/third_party/WebKit/Source/core/fetch/ResourceOwner.h
|
| @@ -32,22 +32,49 @@
|
| #define ResourceOwner_h
|
|
|
| #include "core/fetch/Resource.h"
|
| +#include <type_traits>
|
|
|
| namespace blink {
|
|
|
| +template <typename Client, bool isClientGarbageCollectedMixin>
|
| +class ResourceOwnerBase;
|
| +
|
| +template <typename Client>
|
| +class ResourceOwnerBase<Client, true> : public Client {
|
| +public:
|
| + DEFINE_INLINE_VIRTUAL_TRACE()
|
| + {
|
| + Client::trace(visitor);
|
| + }
|
| +};
|
| +
|
| +// TODO(yhirano): Remove this template once all ResourceClients become
|
| +// GarbageCollectedMixin.
|
| +template <typename Client>
|
| +class ResourceOwnerBase<Client, false> : public GarbageCollectedMixin, public Client {
|
| +public:
|
| + DEFINE_INLINE_VIRTUAL_TRACE() {}
|
| +};
|
| +
|
| template<class R, class C = typename R::ClientType>
|
| -class ResourceOwner : public GarbageCollectedMixin, public C {
|
| +class ResourceOwner : public ResourceOwnerBase<C, std::is_base_of<GarbageCollectedMixin, C>::value> {
|
| USING_PRE_FINALIZER(ResourceOwner, clearResource);
|
| public:
|
| using ResourceType = R;
|
| + ~ResourceOwner() override {}
|
| + ResourceType* resource() const { return m_resource; }
|
|
|
| - virtual ~ResourceOwner();
|
| - ResourceType* resource() const { return m_resource.get(); }
|
| -
|
| - DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_resource); }
|
| + DEFINE_INLINE_TRACE()
|
| + {
|
| + visitor->trace(m_resource);
|
| + ResourceOwnerBase<C, std::is_base_of<GarbageCollectedMixin, C>::value>::trace(visitor);
|
| + }
|
|
|
| protected:
|
| - ResourceOwner();
|
| + ResourceOwner()
|
| + {
|
| + ThreadState::current()->registerPreFinalizer(this);
|
| + }
|
|
|
| void setResource(ResourceType*);
|
| void clearResource() { setResource(nullptr); }
|
| @@ -57,17 +84,6 @@ private:
|
| };
|
|
|
| template<class R, class C>
|
| -inline ResourceOwner<R, C>::ResourceOwner()
|
| -{
|
| - ThreadState::current()->registerPreFinalizer(this);
|
| -}
|
| -
|
| -template<class R, class C>
|
| -inline ResourceOwner<R, C>::~ResourceOwner()
|
| -{
|
| -}
|
| -
|
| -template<class R, class C>
|
| inline void ResourceOwner<R, C>::setResource(R* newResource)
|
| {
|
| if (newResource == m_resource)
|
|
|