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

Unified Diff: base/callback_internal.h

Issue 2344143002: Add const to BindStateBase to align RefCounted constness (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « base/bind_internal.h ('k') | base/callback_internal.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/callback_internal.h
diff --git a/base/callback_internal.h b/base/callback_internal.h
index afed81c843e408c01076d92691f81fb9153298e0..f7501f96c5d737f0a0be70590743c45e6b05329a 100644
--- a/base/callback_internal.h
+++ b/base/callback_internal.h
@@ -36,9 +36,9 @@ class BASE_EXPORT BindStateBase {
protected:
BindStateBase(InvokeFuncStorage polymorphic_invoke,
- void (*destructor)(BindStateBase*));
+ void (*destructor)(const BindStateBase*));
BindStateBase(InvokeFuncStorage polymorphic_invoke,
- void (*destructor)(BindStateBase*),
+ void (*destructor)(const BindStateBase*),
bool (*is_cancelled)(const BindStateBase*));
~BindStateBase() = default;
@@ -51,8 +51,8 @@ class BASE_EXPORT BindStateBase {
return is_cancelled_(this);
}
- void AddRef();
- void Release();
+ void AddRef() const;
+ void Release() const;
Yuta Kitamura 2016/09/20 10:04:21 I'm not sure adding const to these is legit. In my
tzik 2016/09/20 10:54:30 The refcount is not a state of the instance, but a
Yuta Kitamura 2016/09/21 06:01:36 Ah okay, this lets us refcount const objects, righ
// 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
@@ -60,10 +60,10 @@ class BASE_EXPORT BindStateBase {
// the original type on usage.
InvokeFuncStorage polymorphic_invoke_;
- AtomicRefCount ref_count_;
+ mutable AtomicRefCount ref_count_;
// Pointer to a function that will properly destroy |this|.
- void (*destructor_)(BindStateBase*);
+ void (*destructor_)(const BindStateBase*);
bool (*is_cancelled_)(const BindStateBase*);
DISALLOW_COPY_AND_ASSIGN(BindStateBase);
« no previous file with comments | « base/bind_internal.h ('k') | base/callback_internal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698