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

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

Issue 2630703002: Rename Supplement::host() to Supplement::supplementable() (Closed)
Patch Set: temp Created 3 years, 11 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 | « third_party/WebKit/Source/modules/vr/NavigatorVR.cpp ('k') | 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 template <typename T> 92 template <typename T>
93 class Supplementable; 93 class Supplementable;
94 94
95 template <typename T> 95 template <typename T>
96 class Supplement : public GarbageCollectedMixin { 96 class Supplement : public GarbageCollectedMixin {
97 public: 97 public:
98 // TODO(haraken): Remove the default constructor. 98 // TODO(haraken): Remove the default constructor.
99 // All Supplement objects should be instantiated with m_host. 99 // All Supplement objects should be instantiated with m_host.
100 Supplement() {} 100 Supplement() {}
101 101
102 explicit Supplement(T& host) : m_host(&host) {} 102 explicit Supplement(T& supplementable) : m_supplementable(&supplementable) {}
103 103
104 // Supplementable and its supplements live and die together. 104 // Supplementable and its supplements live and die together.
105 // Thus host() should never return null (if the default constructor 105 // Thus supplementable() should never return null (if the default constructor
106 // is completely removed). 106 // is completely removed).
107 T* host() const { return m_host; } 107 T* supplementable() const { return m_supplementable; }
108 108
109 static void provideTo(Supplementable<T>& host, 109 static void provideTo(Supplementable<T>& supplementable,
110 const char* key, 110 const char* key,
111 Supplement<T>* supplement) { 111 Supplement<T>* supplement) {
112 host.provideSupplement(key, supplement); 112 supplementable.provideSupplement(key, supplement);
113 } 113 }
114 114
115 static Supplement<T>* from(Supplementable<T>& host, const char* key) { 115 static Supplement<T>* from(Supplementable<T>& supplementable,
116 return host.requireSupplement(key); 116 const char* key) {
117 return supplementable.requireSupplement(key);
117 } 118 }
118 119
119 static Supplement<T>* from(Supplementable<T>* host, const char* key) { 120 static Supplement<T>* from(Supplementable<T>* supplementable,
120 return host ? host->requireSupplement(key) : 0; 121 const char* key) {
122 return supplementable ? supplementable->requireSupplement(key) : 0;
121 } 123 }
122 124
123 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_host); } 125 DEFINE_INLINE_VIRTUAL_TRACE() { visitor->trace(m_supplementable); }
124 126
125 private: 127 private:
126 Member<T> m_host; 128 Member<T> m_supplementable;
127 }; 129 };
128 130
129 // Supplementable<T> inherits from GarbageCollectedMixin virtually 131 // Supplementable<T> inherits from GarbageCollectedMixin virtually
130 // to allow ExecutionContext to derive from two GC mixin classes. 132 // to allow ExecutionContext to derive from two GC mixin classes.
131 template <typename T> 133 template <typename T>
132 class Supplementable : public virtual GarbageCollectedMixin { 134 class Supplementable : public virtual GarbageCollectedMixin {
133 WTF_MAKE_NONCOPYABLE(Supplementable); 135 WTF_MAKE_NONCOPYABLE(Supplementable);
134 136
135 public: 137 public:
136 void provideSupplement(const char* key, Supplement<T>* supplement) { 138 void provideSupplement(const char* key, Supplement<T>* supplement) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 }; 190 };
189 191
190 template <typename T> 192 template <typename T>
191 struct ThreadingTrait<Supplementable<T>> { 193 struct ThreadingTrait<Supplementable<T>> {
192 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity; 194 static const ThreadAffinity Affinity = ThreadingTrait<T>::Affinity;
193 }; 195 };
194 196
195 } // namespace blink 197 } // namespace blink
196 198
197 #endif // Supplementable_h 199 #endif // Supplementable_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/NavigatorVR.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698