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

Side by Side Diff: third_party/WebKit/Source/platform/Supplementable.h

Issue 2136473002: Make Supplement and Supplementable live and die together 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2012 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // 86 //
87 // Note that reattachThread() does nothing if assertion is not enabled. 87 // Note that reattachThread() does nothing if assertion is not enabled.
88 // 88 //
89 89
90 template<typename T> 90 template<typename T>
91 class Supplementable; 91 class Supplementable;
92 92
93 template<typename T> 93 template<typename T>
94 class Supplement : public GarbageCollectedMixin { 94 class Supplement : public GarbageCollectedMixin {
95 public: 95 public:
96 // TODO(haraken): Remove this default constructor.
haraken 2016/07/08 06:37:29 I'll fix the TODO before committing. But I want to
sof 2016/07/08 07:07:02 Before Oilpan, Supplementable provided OwnPtr<>-ow
haraken 2016/07/08 07:17:37 Thanks for the details. I feel that it would make
97 Supplement() : m_host(nullptr) { }
98 explicit Supplement(T* host) : m_host(host) { }
99 T* host() const { return m_host; }
100
96 static void provideTo(Supplementable<T>& host, const char* key, Supplement<T >* supplement) 101 static void provideTo(Supplementable<T>& host, const char* key, Supplement<T >* supplement)
97 { 102 {
98 host.provideSupplement(key, supplement); 103 host.provideSupplement(key, supplement);
99 } 104 }
100 105
101 static Supplement<T>* from(Supplementable<T>& host, const char* key) 106 static Supplement<T>* from(Supplementable<T>& host, const char* key)
102 { 107 {
103 return host.requireSupplement(key); 108 return host.requireSupplement(key);
104 } 109 }
105 110
106 static Supplement<T>* from(Supplementable<T>* host, const char* key) 111 static Supplement<T>* from(Supplementable<T>* host, const char* key)
107 { 112 {
108 return host ? host->requireSupplement(key) : 0; 113 return host ? host->requireSupplement(key) : 0;
109 } 114 }
115
116 DEFINE_INLINE_VIRTUAL_TRACE()
117 {
118 visitor->trace(m_host);
119 }
120
121 private:
122 Member<T> m_host;
110 }; 123 };
111 124
112 // Supplementable<T> inherits from GarbageCollectedMixin virtually 125 // Supplementable<T> inherits from GarbageCollectedMixin virtually
113 // to allow ExecutionContext to derive from two GC mixin classes. 126 // to allow ExecutionContext to derive from two GC mixin classes.
114 template<typename T> 127 template<typename T>
115 class Supplementable : public virtual GarbageCollectedMixin { 128 class Supplementable : public virtual GarbageCollectedMixin {
116 WTF_MAKE_NONCOPYABLE(Supplementable); 129 WTF_MAKE_NONCOPYABLE(Supplementable);
117 public: 130 public:
118 void provideSupplement(const char* key, Supplement<T>* supplement) 131 void provideSupplement(const char* key, Supplement<T>* supplement)
119 { 132 {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 }; 182 };
170 183
171 template<typename T> 184 template<typename T>
172 struct ThreadingTrait<Supplementable<T>> { 185 struct ThreadingTrait<Supplementable<T>> {
173 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 186 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
174 }; 187 };
175 188
176 } // namespace blink 189 } // namespace blink
177 190
178 #endif // Supplementable_h 191 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698