| OLD | NEW |
| 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 // It also defines a set of simple functions and utilities that people want | 9 // It also defines a set of simple functions and utilities that people want |
| 10 // when using Callback<> and Bind(). | 10 // when using Callback<> and Bind(). |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 // See http://crbug.com/82038. | 222 // See http://crbug.com/82038. |
| 223 template <typename T> | 223 template <typename T> |
| 224 class SupportsAddRefAndRelease { | 224 class SupportsAddRefAndRelease { |
| 225 typedef char Yes[1]; | 225 typedef char Yes[1]; |
| 226 typedef char No[2]; | 226 typedef char No[2]; |
| 227 | 227 |
| 228 struct BaseMixin { | 228 struct BaseMixin { |
| 229 void AddRef(); | 229 void AddRef(); |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 // MSVC warns when you try to use Base if T has a private destructor, the | |
| 233 // common pattern for refcounted types. It does this even though no attempt to | |
| 234 // instantiate Base is made. We disable the warning for this definition. | |
| 235 #if defined(OS_WIN) | |
| 236 #pragma warning(push) | |
| 237 #pragma warning(disable:4624) | |
| 238 #endif | |
| 239 struct Base : public T, public BaseMixin { | 232 struct Base : public T, public BaseMixin { |
| 240 }; | 233 }; |
| 241 #if defined(OS_WIN) | |
| 242 #pragma warning(pop) | |
| 243 #endif | |
| 244 | 234 |
| 245 template <void(BaseMixin::*)(void)> struct Helper {}; | 235 template <void(BaseMixin::*)(void)> struct Helper {}; |
| 246 | 236 |
| 247 template <typename C> | 237 template <typename C> |
| 248 static No& Check(Helper<&C::AddRef>*); | 238 static No& Check(Helper<&C::AddRef>*); |
| 249 | 239 |
| 250 template <typename > | 240 template <typename > |
| 251 static Yes& Check(...); | 241 static Yes& Check(...); |
| 252 | 242 |
| 253 public: | 243 public: |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 BASE_EXPORT void DoNothing(); | 583 BASE_EXPORT void DoNothing(); |
| 594 | 584 |
| 595 template<typename T> | 585 template<typename T> |
| 596 void DeletePointer(T* obj) { | 586 void DeletePointer(T* obj) { |
| 597 delete obj; | 587 delete obj; |
| 598 } | 588 } |
| 599 | 589 |
| 600 } // namespace base | 590 } // namespace base |
| 601 | 591 |
| 602 #endif // BASE_BIND_HELPERS_H_ | 592 #endif // BASE_BIND_HELPERS_H_ |
| OLD | NEW |