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

Side by Side Diff: base/bind_helpers.h

Issue 6981001: Make the Pepper proxy support in-process font rendering. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | build/all.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This defines a set of argument wrappers and related factory methods that 5 // This defines a set of argument wrappers and related factory methods that
6 // can be used specify the refcounting and reference semantics of arguments 6 // can be used specify the refcounting and reference semantics of arguments
7 // that are bound by the Bind() function in base/bind.h. 7 // that are bound by the Bind() function in base/bind.h.
8 // 8 //
9 // The public functions are base::Unretained() and base::ConstRef(). 9 // The public functions are base::Unretained() and base::ConstRef().
10 // Unretained() allows Bind() to bind a non-refcounted class. 10 // Unretained() allows Bind() to bind a non-refcounted class.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // exist, then &C::TargetFunc is not ambiguous, and the overload resolution 116 // exist, then &C::TargetFunc is not ambiguous, and the overload resolution
117 // will prefer GoodCheck(Helper<&C::TargetFunc>*). 117 // will prefer GoodCheck(Helper<&C::TargetFunc>*).
118 // 118 //
119 // This method of SFINAE will correctly probe for inherited names, but it cannot 119 // This method of SFINAE will correctly probe for inherited names, but it cannot
120 // typecheck those names. It's still a good enough sanity check though. 120 // typecheck those names. It's still a good enough sanity check though.
121 // 121 //
122 // Works on gcc-4.2, gcc-4.4, and Visual Studio 2008. 122 // Works on gcc-4.2, gcc-4.4, and Visual Studio 2008.
123 // 123 //
124 // TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted 124 // TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted
125 // this works well. 125 // this works well.
126 //
127 // TODO(ajwong): Make this check for Release() as well.
128 // See http://crbug.com/82038.
126 template <typename T> 129 template <typename T>
127 class SupportsAddRefAndRelease { 130 class SupportsAddRefAndRelease {
128 typedef char Yes[1]; 131 typedef char Yes[1];
129 typedef char No[2]; 132 typedef char No[2];
130 133
131 struct BaseMixin { 134 struct BaseMixin {
132 void AddRef(); 135 void AddRef();
133 void Release();
134 }; 136 };
135 137
136 // MSVC warns when you try to use Base if T has a private destructor, the 138 // MSVC warns when you try to use Base if T has a private destructor, the
137 // common pattern for refcounted types. It does this even though no attempt to 139 // common pattern for refcounted types. It does this even though no attempt to
138 // instantiate Base is made. We disable the warning for this definition. 140 // instantiate Base is made. We disable the warning for this definition.
139 #if defined(OS_WIN) 141 #if defined(OS_WIN)
140 #pragma warning(disable:4624) 142 #pragma warning(disable:4624)
141 #endif 143 #endif
142 struct Base : public T, public BaseMixin { 144 struct Base : public T, public BaseMixin {
143 }; 145 };
144 #if defined(OS_WIN) 146 #if defined(OS_WIN)
145 #pragma warning(default:4624) 147 #pragma warning(default:4624)
146 #endif 148 #endif
147 149
148 template <void(BaseMixin::*)(void)> struct Helper {}; 150 template <void(BaseMixin::*)(void)> struct Helper {};
149 151
150 template <typename C> 152 template <typename C>
151 static No& Check(Helper<&C::AddRef>*, Helper<&C::Release>*); 153 static No& Check(Helper<&C::AddRef>*);
152 154
153 template <typename > 155 template <typename >
154 static Yes& Check(...); 156 static Yes& Check(...);
155 157
156 public: 158 public:
157 static const bool value = sizeof(Check<Base>(0,0)) == sizeof(Yes); 159 static const bool value = sizeof(Check<Base>(0)) == sizeof(Yes);
158 }; 160 };
159 161
160 162
161 // Helpers to assert that arguments of a recounted type are bound with a 163 // Helpers to assert that arguments of a recounted type are bound with a
162 // scoped_refptr. 164 // scoped_refptr.
163 template <bool IsClasstype, typename T> 165 template <bool IsClasstype, typename T>
164 struct UnsafeBindtoRefCountedArgHelper : false_type { 166 struct UnsafeBindtoRefCountedArgHelper : false_type {
165 }; 167 };
166 168
167 template <typename T> 169 template <typename T>
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 256 }
255 257
256 template <typename T> 258 template <typename T>
257 inline internal::ConstRefWrapper<T> ConstRef(const T& o) { 259 inline internal::ConstRefWrapper<T> ConstRef(const T& o) {
258 return internal::ConstRefWrapper<T>(o); 260 return internal::ConstRefWrapper<T>(o);
259 } 261 }
260 262
261 } // namespace base 263 } // namespace base
262 264
263 #endif // BASE_BIND_HELPERS_H_ 265 #endif // BASE_BIND_HELPERS_H_
OLDNEW
« no previous file with comments | « no previous file | build/all.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698