Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceOwner.h

Issue 2014533002: Move FontResourceClient to Oilpan heap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FontResource.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7afc520c6a001e10d534a092f802929d8e4906e4 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 R, typename C, bool isClientGarbageCollectedMixin>
hiroshige 2016/05/27 08:18:38 |R| is not necessary? nit optional: How about ren
yhirano 2016/05/27 16:37:28 Done.
+class ResourceOwnerBase;
+
+template <typename R, typename C>
+class ResourceOwnerBase<R, C, true> : public C {
+public:
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ C::trace(visitor);
+ }
+};
+
+// TODO(yhirano): Remove this template once all ResourceClients become
+// GarbageCollectedMixin.
+template <typename R, typename C>
+class ResourceOwnerBase<R, C, false> : public GarbageCollectedMixin, public C {
+public:
+ DEFINE_INLINE_VIRTUAL_TRACE() {}
+};
+
template<class R, class C = typename R::ClientType>
-class ResourceOwner : public GarbageCollectedMixin, public C {
+class ResourceOwner : public ResourceOwnerBase<R, 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<R, 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)
« no previous file with comments | « third_party/WebKit/Source/core/fetch/FontResource.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698