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

Unified Diff: base/callback_internal.h

Issue 6542026: Callback: De-inline CallbackBase, and move to callback_helpers -> callback_internal.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/base
Patch Set: Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
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_
« no previous file with comments | « base/callback.h.pump ('k') | base/callback_internal.cc » ('j') | base/callback_internal.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698