| 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 file contains utility functions and classes that help the | 5 // This file contains utility functions and classes that help the |
| 6 // implementation, and management of the Callback objects. | 6 // implementation, and management of the Callback objects. |
| 7 | 7 |
| 8 #ifndef BASE_CALLBACK_INTERNAL_H_ | 8 #ifndef BASE_CALLBACK_INTERNAL_H_ |
| 9 #define BASE_CALLBACK_INTERNAL_H_ | 9 #define BASE_CALLBACK_INTERNAL_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // Holds the Callback methods that don't require specialization to reduce | 55 // Holds the Callback methods that don't require specialization to reduce |
| 56 // template bloat. | 56 // template bloat. |
| 57 class BASE_EXPORT CallbackBase { | 57 class BASE_EXPORT CallbackBase { |
| 58 public: | 58 public: |
| 59 // Returns true if Callback is null (doesn't refer to anything). | 59 // Returns true if Callback is null (doesn't refer to anything). |
| 60 bool is_null() const; | 60 bool is_null() const; |
| 61 | 61 |
| 62 // Returns the Callback into an uninitalized state. | 62 // Returns the Callback into an uninitalized state. |
| 63 void Reset(); | 63 void Reset(); |
| 64 | 64 |
| 65 protected: |
| 65 bool Equals(const CallbackBase& other) const; | 66 bool Equals(const CallbackBase& other) const; |
| 66 | 67 |
| 67 protected: | |
| 68 // In C++, it is safe to cast function pointers to function pointers of | 68 // In C++, it is safe to cast function pointers to function pointers of |
| 69 // another type. It is not okay to use void*. We create a InvokeFuncStorage | 69 // another type. It is not okay to use void*. We create a InvokeFuncStorage |
| 70 // that that can store our function pointer, and then cast it back to | 70 // that that can store our function pointer, and then cast it back to |
| 71 // the original type on usage. | 71 // the original type on usage. |
| 72 typedef void(*InvokeFuncStorage)(void); | 72 typedef void(*InvokeFuncStorage)(void); |
| 73 | 73 |
| 74 CallbackBase(InvokeFuncStorage polymorphic_invoke, | 74 CallbackBase(InvokeFuncStorage polymorphic_invoke, |
| 75 scoped_refptr<InvokerStorageBase>* invoker_storage); | 75 scoped_refptr<InvokerStorageBase>* invoker_storage); |
| 76 | 76 |
| 77 // Force the destructor to be instaniated inside this translation unit so | 77 // Force the destructor to be instaniated inside this translation unit so |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 template <typename T> | 126 template <typename T> |
| 127 struct ParamTraits<T[]> { | 127 struct ParamTraits<T[]> { |
| 128 typedef const T* ForwardType; | 128 typedef const T* ForwardType; |
| 129 typedef const T* StorageType; | 129 typedef const T* StorageType; |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 } // namespace internal | 132 } // namespace internal |
| 133 } // namespace base | 133 } // namespace base |
| 134 | 134 |
| 135 #endif // BASE_CALLBACK_INTERNAL_H_ | 135 #endif // BASE_CALLBACK_INTERNAL_H_ |
| OLD | NEW |