Chromium Code Reviews| Index: third_party/WebKit/Source/platform/Supplementable.h |
| diff --git a/third_party/WebKit/Source/platform/Supplementable.h b/third_party/WebKit/Source/platform/Supplementable.h |
| index c9ff4c197dab5b62421b72066915b50e2b85a205..c2b90df0f0a3ec2457dac03425f1d030a2dfbfe9 100644 |
| --- a/third_party/WebKit/Source/platform/Supplementable.h |
| +++ b/third_party/WebKit/Source/platform/Supplementable.h |
| @@ -95,6 +95,12 @@ class Supplementable; |
| template <typename T> |
| class Supplement : public GarbageCollectedMixin { |
| public: |
| + // TODO(haraken): Remove the default constructor. |
|
sof
2017/01/19 07:38:39
I'd argue that this isn't a natural goal for all s
|
| + // All Supplement objects should be instantiated with m_host. |
| + Supplement() {} |
| + explicit Supplement(T& host) : m_host(&host) {} |
| + T* host() const { return m_host; } |
| + |
| static void provideTo(Supplementable<T>& host, |
| const char* key, |
| Supplement<T>* supplement) { |
| @@ -109,7 +115,10 @@ class Supplement : public GarbageCollectedMixin { |
| return host ? host->requireSupplement(key) : 0; |
| } |
| - DEFINE_INLINE_VIRTUAL_TRACE() {} |
| + DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_host); } |
| + |
| + private: |
| + Member<T> m_host; |
| }; |
| // Supplementable<T> inherits from GarbageCollectedMixin virtually |