OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 protected: | 30 protected: |
31 friend class RefCountedThreadSafe<BindStateBase>; | 31 friend class RefCountedThreadSafe<BindStateBase>; |
32 virtual ~BindStateBase() {} | 32 virtual ~BindStateBase() {} |
33 }; | 33 }; |
34 | 34 |
35 // Holds the Callback methods that don't require specialization to reduce | 35 // Holds the Callback methods that don't require specialization to reduce |
36 // template bloat. | 36 // template bloat. |
37 class BASE_EXPORT CallbackBase { | 37 class BASE_EXPORT CallbackBase { |
38 public: | 38 public: |
39 // Returns true if Callback is null (doesn't refer to anything). | 39 // Returns true if Callback is null (doesn't refer to anything). |
40 bool is_null() const; | 40 bool is_null() const { return bind_state_.get() == NULL; } |
41 | 41 |
42 // Returns the Callback into an uninitialized state. | 42 // Returns the Callback into an uninitialized state. |
43 void Reset(); | 43 void Reset(); |
44 | 44 |
45 protected: | 45 protected: |
46 // In C++, it is safe to cast function pointers to function pointers of | 46 // In C++, it is safe to cast function pointers to function pointers of |
47 // another type. It is not okay to use void*. We create a InvokeFuncStorage | 47 // another type. It is not okay to use void*. We create a InvokeFuncStorage |
48 // that that can store our function pointer, and then cast it back to | 48 // that that can store our function pointer, and then cast it back to |
49 // the original type on usage. | 49 // the original type on usage. |
50 typedef void(*InvokeFuncStorage)(void); | 50 typedef void(*InvokeFuncStorage)(void); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 169 |
170 template <typename T> | 170 template <typename T> |
171 typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) { | 171 typename enable_if<IsMoveOnlyType<T>::value, T>::type CallbackForward(T& t) { |
172 return t.Pass(); | 172 return t.Pass(); |
173 } | 173 } |
174 | 174 |
175 } // namespace internal | 175 } // namespace internal |
176 } // namespace base | 176 } // namespace base |
177 | 177 |
178 #endif // BASE_CALLBACK_INTERNAL_H_ | 178 #endif // BASE_CALLBACK_INTERNAL_H_ |
OLD | NEW |