Index: base/callback_internal.h |
diff --git a/base/callback_helpers.h b/base/callback_internal.h |
similarity index 64% |
rename from base/callback_helpers.h |
rename to base/callback_internal.h |
index 86b0df1eefeba6fe6d63036d9360f4f1551965de..b7b2924bbdd7cf96cb5a027aa18dad32bc20215d 100644 |
--- a/base/callback_helpers.h |
+++ b/base/callback_internal.h |
@@ -5,8 +5,8 @@ |
// This file contains utility functions and classes that help the |
// implementation, and management of the Callback objects. |
-#ifndef BASE_CALLBACK_HELPERS_H_ |
-#define BASE_CALLBACK_HELPERS_H_ |
+#ifndef BASE_CALLBACK_INTERNAL_H_ |
+#define BASE_CALLBACK_INTERNAL_H_ |
#pragma once |
#include "base/ref_counted.h" |
@@ -49,7 +49,33 @@ InvokerStorageHolder<T> MakeInvokerStorageHolder(T* o) { |
return InvokerStorageHolder<T>(o); |
} |
+// Holds the Callback methods that don't require specialization to reduce |
+// template bloat. |
+class CallbackBase { |
+ public: |
+ // Returns true if Callback is null (doesn't refer to anything). |
+ bool is_null() const; |
+ |
+ // Returns the Callback into an uninitalized state. |
+ void Reset(); |
+ |
+ bool Equals(const CallbackBase& other) const; |
+ |
+ protected: |
+ // In C++, it is safe to cast function pointers to function pointers of |
+ // another type. It is not okay to use void*. We create a InvokeFuncStorage |
+ // that that can store our function pointer, and then cast it back to |
+ // the original type on usage. |
+ typedef void(*InvokeFuncStorage)(void); |
+ |
+ CallbackBase(InvokeFuncStorage polymorphic_invoke, |
+ scoped_refptr<InvokerStorageBase>* invoker_storage); |
Elliot Glaysher
2011/02/18 20:39:11
Drive by: add a destructor. The autogenerated one
awong
2011/02/18 21:27:24
Done. Added comment summarizing our IM discussion
|
+ |
+ scoped_refptr<InvokerStorageBase> invoker_storage_; |
+ InvokeFuncStorage polymorphic_invoke_; |
+}; |
+ |
} // namespace internal |
} // namespace base |
-#endif // BASE_CALLBACK_HELPERS_H_ |
+#endif // BASE_CALLBACK_INTERNAL_H_ |