diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 06:23:00 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-26 06:23:00 +0000 |
commit | cb932487f6e6f8768da2030662dcd91929f4df0b (patch) | |
tree | 4563fa67fbafbf8e979e0c69024637b5badd9ec2 /base | |
parent | 3f9bfdac19db30a0a424e21d254f869eafaeb4ac (diff) | |
download | chromium_src-cb932487f6e6f8768da2030662dcd91929f4df0b.zip chromium_src-cb932487f6e6f8768da2030662dcd91929f4df0b.tar.gz chromium_src-cb932487f6e6f8768da2030662dcd91929f4df0b.tar.bz2 |
RefCounted types should not have public destructors, base/ edition
BUG=123295
TEST=it compiles
Review URL: https://chromiumcodereview.appspot.com/10332269
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144130 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/memory/ref_counted.h | 12 | ||||
-rw-r--r-- | base/memory/weak_ptr.h | 3 | ||||
-rw-r--r-- | base/message_pump_libevent.h | 6 | ||||
-rw-r--r-- | base/supports_user_data.cc | 8 | ||||
-rw-r--r-- | base/supports_user_data.h | 4 | ||||
-rw-r--r-- | base/synchronization/waitable_event_watcher.h | 7 | ||||
-rw-r--r-- | base/threading/non_thread_safe.h | 7 | ||||
-rw-r--r-- | base/threading/non_thread_safe_impl.cc | 10 | ||||
-rw-r--r-- | base/threading/non_thread_safe_impl.h | 6 | ||||
-rw-r--r-- | base/threading/platform_thread.h | 4 |
10 files changed, 39 insertions, 28 deletions
diff --git a/base/memory/ref_counted.h b/base/memory/ref_counted.h index 858ed2b..ce0d94a 100644 --- a/base/memory/ref_counted.h +++ b/base/memory/ref_counted.h @@ -85,8 +85,7 @@ class BASE_EXPORT RefCountedThreadSafeBase { template <class T> class RefCounted : public subtle::RefCountedBase { public: - RefCounted() { } - ~RefCounted() { } + RefCounted() {} void AddRef() const { subtle::RefCountedBase::AddRef(); @@ -98,6 +97,9 @@ class RefCounted : public subtle::RefCountedBase { } } + protected: + ~RefCounted() {} + private: DISALLOW_COPY_AND_ASSIGN(RefCounted<T>); }; @@ -133,8 +135,7 @@ struct DefaultRefCountedThreadSafeTraits { template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> > class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase { public: - RefCountedThreadSafe() { } - ~RefCountedThreadSafe() { } + RefCountedThreadSafe() {} void AddRef() const { subtle::RefCountedThreadSafeBase::AddRef(); @@ -146,6 +147,9 @@ class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase { } } + protected: + ~RefCountedThreadSafe() {} + private: friend struct DefaultRefCountedThreadSafeTraits<T>; static void DeleteInternal(const T* x) { delete x; } diff --git a/base/memory/weak_ptr.h b/base/memory/weak_ptr.h index be045a6..d7c452f 100644 --- a/base/memory/weak_ptr.h +++ b/base/memory/weak_ptr.h @@ -251,6 +251,9 @@ class SupportsWeakPtr : public internal::SupportsWeakPtrBase { weak_reference_owner_.DetachFromThread(); } + protected: + ~SupportsWeakPtr() {} + private: internal::WeakReferenceOwner weak_reference_owner_; DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr); diff --git a/base/message_pump_libevent.h b/base/message_pump_libevent.h index 957c548..1666ad0 100644 --- a/base/message_pump_libevent.h +++ b/base/message_pump_libevent.h @@ -45,11 +45,13 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump { // of a file descriptor. class Watcher { public: - virtual ~Watcher() {} // Called from MessageLoop::Run when an FD can be read from/written to // without blocking virtual void OnFileCanReadWithoutBlocking(int fd) = 0; virtual void OnFileCanWriteWithoutBlocking(int fd) = 0; + + protected: + virtual ~Watcher() {} }; // Object returned by WatchFileDescriptor to manage further watching. @@ -74,7 +76,7 @@ class BASE_EXPORT MessagePumpLibevent : public MessagePump { void Init(event* e); // Used by MessagePumpLibevent to take ownership of event_. - event *ReleaseEvent(); + event* ReleaseEvent(); void set_pump(MessagePumpLibevent* pump) { pump_ = pump; } MessagePumpLibevent* pump() { return pump_; } diff --git a/base/supports_user_data.cc b/base/supports_user_data.cc index 2253c86..4fe64bd 100644 --- a/base/supports_user_data.cc +++ b/base/supports_user_data.cc @@ -6,11 +6,7 @@ namespace base { -SupportsUserData::SupportsUserData() { -} - -SupportsUserData::~SupportsUserData() { -} +SupportsUserData::SupportsUserData() {} SupportsUserData::Data* SupportsUserData::GetUserData(const void* key) const { DataMap::const_iterator found = user_data_.find(key); @@ -23,4 +19,6 @@ void SupportsUserData::SetUserData(const void* key, Data* data) { user_data_[key] = linked_ptr<Data>(data); } +SupportsUserData::~SupportsUserData() {} + } // namespace base diff --git a/base/supports_user_data.h b/base/supports_user_data.h index d1c6c9a..17899dd 100644 --- a/base/supports_user_data.h +++ b/base/supports_user_data.h @@ -18,7 +18,6 @@ namespace base { class BASE_EXPORT SupportsUserData { public: SupportsUserData(); - virtual ~SupportsUserData(); // Derive from this class and add your own data members to associate extra // information with this object. Use GetUserData(key) and SetUserData() @@ -34,6 +33,9 @@ class BASE_EXPORT SupportsUserData { Data* GetUserData(const void* key) const; void SetUserData(const void* key, Data* data); + protected: + virtual ~SupportsUserData(); + private: typedef std::map<const void*, linked_ptr<Data> > DataMap; diff --git a/base/synchronization/waitable_event_watcher.h b/base/synchronization/waitable_event_watcher.h index 1512acc..7e1698b 100644 --- a/base/synchronization/waitable_event_watcher.h +++ b/base/synchronization/waitable_event_watcher.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -72,8 +72,6 @@ class BASE_EXPORT WaitableEventWatcher class BASE_EXPORT Delegate { public: - virtual ~Delegate() { } - // ------------------------------------------------------------------------- // This is called on the MessageLoop thread when WaitableEvent has been // signaled. @@ -83,6 +81,9 @@ class BASE_EXPORT WaitableEventWatcher // the past. // ------------------------------------------------------------------------- virtual void OnWaitableEventSignaled(WaitableEvent* waitable_event) = 0; + + protected: + virtual ~Delegate() { } }; // --------------------------------------------------------------------------- diff --git a/base/threading/non_thread_safe.h b/base/threading/non_thread_safe.h index da7b528..be30269 100644 --- a/base/threading/non_thread_safe.h +++ b/base/threading/non_thread_safe.h @@ -29,6 +29,7 @@ class NonThreadSafeDoNothing { } protected: + ~NonThreadSafeDoNothing() {} void DetachFromThread() {} }; @@ -56,11 +57,9 @@ class NonThreadSafeDoNothing { // // In Release mode, CalledOnValidThread will always return true. #ifndef NDEBUG -class NonThreadSafe : public NonThreadSafeImpl { -}; +typedef NonThreadSafeImpl NonThreadSafe; #else -class NonThreadSafe : public NonThreadSafeDoNothing { -}; +typedef NonThreadSafeDoNothing NonThreadSafe; #endif // NDEBUG } // namespace base diff --git a/base/threading/non_thread_safe_impl.cc b/base/threading/non_thread_safe_impl.cc index f9c18c2..7e729d9 100644 --- a/base/threading/non_thread_safe_impl.cc +++ b/base/threading/non_thread_safe_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,14 +8,14 @@ namespace base { -NonThreadSafeImpl::~NonThreadSafeImpl() { - DCHECK(CalledOnValidThread()); -} - bool NonThreadSafeImpl::CalledOnValidThread() const { return thread_checker_.CalledOnValidThread(); } +NonThreadSafeImpl::~NonThreadSafeImpl() { + DCHECK(CalledOnValidThread()); +} + void NonThreadSafeImpl::DetachFromThread() { thread_checker_.DetachFromThread(); } diff --git a/base/threading/non_thread_safe_impl.h b/base/threading/non_thread_safe_impl.h index 4a70e34..71faeb2 100644 --- a/base/threading/non_thread_safe_impl.h +++ b/base/threading/non_thread_safe_impl.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -19,11 +19,11 @@ namespace base { // the right version of the class for your build configuration. class BASE_EXPORT NonThreadSafeImpl { public: - ~NonThreadSafeImpl(); - bool CalledOnValidThread() const; protected: + ~NonThreadSafeImpl(); + // Changes the thread that is checked for in CalledOnValidThread. The next // call to CalledOnValidThread will attach this class to a new thread. It is // up to the NonThreadSafe derived class to decide to expose this or not. diff --git a/base/threading/platform_thread.h b/base/threading/platform_thread.h index fc64f78..de552c8 100644 --- a/base/threading/platform_thread.h +++ b/base/threading/platform_thread.h @@ -54,8 +54,10 @@ class BASE_EXPORT PlatformThread { // ThreadMain method will be called on the newly created thread. class BASE_EXPORT Delegate { public: - virtual ~Delegate() {} virtual void ThreadMain() = 0; + + protected: + virtual ~Delegate() {} }; // Gets the current thread id, which may be useful for logging purposes. |