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

Unified Diff: third_party/WebKit/Source/platform/Supplementable.h

Issue 2150443002: Supplement should have a Member to the corresponding Supplementable object (Part 1) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
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 487873705cf0e96439468a31084aa8268612a03a..ba2aa152ff60f429702d2561f179145d764c2e67 100644
--- a/third_party/WebKit/Source/platform/Supplementable.h
+++ b/third_party/WebKit/Source/platform/Supplementable.h
@@ -93,6 +93,12 @@ class Supplementable;
template<typename T>
class Supplement : public GarbageCollectedMixin {
public:
+ // TODO(haraken): Remove the default constructor.
+ // 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)
{
host.provideSupplement(key, supplement);
@@ -108,7 +114,13 @@ public:
return host ? host->requireSupplement(key) : 0;
}
- DEFINE_INLINE_VIRTUAL_TRACE() { }
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ visitor->trace(m_host);
+ }
+
+private:
+ WeakMember<T> m_host;
sof 2016/07/13 07:20:41 Thinking about this some more, what value does it
haraken 2016/07/13 07:24:26 Many Supplement classes that inherit from DOMWindo
sof 2016/07/13 07:39:41 ok, thanks for clarifying the purpose, i.e., |m_ho
haraken 2016/07/13 07:42:12 Yes, right.
};
// Supplementable<T> inherits from GarbageCollectedMixin virtually

Powered by Google App Engine
This is Rietveld 408576698