Remove DISALLOW_ macro from include/ (see issue #3234)

Also perform related C++ cleanup:
- Use =default instead of {} for default implementations of
  constructors/destructors.
- Replace typedef with using.
This commit is contained in:
Marshall Greenblatt 2021-12-06 17:26:35 -05:00
parent 1eb55cbba8
commit b76badd958
9 changed files with 63 additions and 47 deletions

View File

@ -45,7 +45,6 @@
#include <atomic> #include <atomic>
#include "include/base/cef_macros.h"
#include "include/base/cef_thread_checker.h" #include "include/base/cef_thread_checker.h"
namespace base { namespace base {
@ -56,6 +55,10 @@ namespace base {
class AtomicFlag { class AtomicFlag {
public: public:
AtomicFlag(); AtomicFlag();
AtomicFlag(const AtomicFlag&) = delete;
AtomicFlag& operator=(const AtomicFlag&) = delete;
~AtomicFlag(); ~AtomicFlag();
// Set the flag. Must always be called from the same thread. // Set the flag. Must always be called from the same thread.
@ -76,8 +79,6 @@ class AtomicFlag {
private: private:
std::atomic<uint_fast8_t> flag_{0}; std::atomic<uint_fast8_t> flag_{0};
base::ThreadChecker set_thread_checker_; base::ThreadChecker set_thread_checker_;
DISALLOW_COPY_AND_ASSIGN(AtomicFlag);
}; };
} // namespace base } // namespace base

View File

@ -41,7 +41,6 @@
// updated to match. // updated to match.
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_platform_thread.h" #include "include/base/cef_platform_thread.h"
#include "include/base/internal/cef_lock_impl.h" #include "include/base/internal/cef_lock_impl.h"
@ -55,6 +54,10 @@ class Lock {
public: public:
#if !DCHECK_IS_ON() // Optimized wrapper implementation #if !DCHECK_IS_ON() // Optimized wrapper implementation
Lock() : lock_() {} Lock() : lock_() {}
Lock(const Lock&) = delete;
Lock& operator=(const Lock&) = delete;
~Lock() {} ~Lock() {}
void Acquire() { lock_.Lock(); } void Acquire() { lock_.Lock(); }
void Release() { lock_.Unlock(); } void Release() { lock_.Unlock(); }
@ -111,8 +114,6 @@ class Lock {
// Platform specific underlying lock implementation. // Platform specific underlying lock implementation.
LockImpl lock_; LockImpl lock_;
DISALLOW_COPY_AND_ASSIGN(Lock);
}; };
// A helper class that acquires the given Lock while the AutoLock is in scope. // A helper class that acquires the given Lock while the AutoLock is in scope.
@ -126,6 +127,9 @@ class AutoLock {
lock_.AssertAcquired(); lock_.AssertAcquired();
} }
AutoLock(const AutoLock&) = delete;
AutoLock& operator=(const AutoLock&) = delete;
~AutoLock() { ~AutoLock() {
lock_.AssertAcquired(); lock_.AssertAcquired();
lock_.Release(); lock_.Release();
@ -133,7 +137,6 @@ class AutoLock {
private: private:
Lock& lock_; Lock& lock_;
DISALLOW_COPY_AND_ASSIGN(AutoLock);
}; };
// AutoUnlock is a helper that will Release() the |lock| argument in the // AutoUnlock is a helper that will Release() the |lock| argument in the
@ -146,11 +149,13 @@ class AutoUnlock {
lock_.Release(); lock_.Release();
} }
AutoUnlock(const AutoUnlock&) = delete;
AutoUnlock& operator=(const AutoUnlock&) = delete;
~AutoUnlock() { lock_.Acquire(); } ~AutoUnlock() { lock_.Acquire(); }
private: private:
Lock& lock_; Lock& lock_;
DISALLOW_COPY_AND_ASSIGN(AutoUnlock);
}; };
} // namespace cef_internal } // namespace cef_internal
@ -158,9 +163,9 @@ class AutoUnlock {
// Implement classes in the cef_internal namespace and then expose them to the // Implement classes in the cef_internal namespace and then expose them to the
// base namespace. This avoids conflicts with the base.lib implementation when // base namespace. This avoids conflicts with the base.lib implementation when
// linking sandbox support on Windows. // linking sandbox support on Windows.
using cef_internal::Lock;
using cef_internal::AutoLock; using cef_internal::AutoLock;
using cef_internal::AutoUnlock; using cef_internal::AutoUnlock;
using cef_internal::Lock;
} // namespace base } // namespace base

View File

@ -164,7 +164,6 @@
#include <string> #include <string>
#include "include/base/cef_build.h" #include "include/base/cef_build.h"
#include "include/base/cef_macros.h"
#include "include/internal/cef_logging_internal.h" #include "include/internal/cef_logging_internal.h"
namespace cef { namespace cef {
@ -202,21 +201,21 @@ const LogSeverity LOG_DFATAL = LOG_FATAL;
// A few definitions of macros that don't generate much code. These are used // A few definitions of macros that don't generate much code. These are used
// by LOG() and LOG_IF, etc. Since these are used all over our code, it's // by LOG() and LOG_IF, etc. Since these are used all over our code, it's
// better to have compact code for these operations. // better to have compact code for these operations.
#define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \ #define COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ...) \
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_INFO, \ ::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_INFO, \
##__VA_ARGS__) ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \ #define COMPACT_GOOGLE_LOG_EX_WARNING(ClassName, ...) \
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_WARNING, \ ::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_WARNING, \
##__VA_ARGS__) ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \ #define COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ...) \
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_ERROR, \ ::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_ERROR, \
##__VA_ARGS__) ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \ #define COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ...) \
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_FATAL, \ ::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_FATAL, \
##__VA_ARGS__) ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \ #define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_DFATAL, \ ::cef::logging::ClassName(__FILE__, __LINE__, ::cef::logging::LOG_DFATAL, \
##__VA_ARGS__) ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage) #define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage) #define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
@ -583,6 +582,9 @@ class LogMessage {
LogSeverity severity, LogSeverity severity,
std::string* result); std::string* result);
LogMessage(const LogMessage&) = delete;
LogMessage& operator=(const LogMessage&) = delete;
~LogMessage(); ~LogMessage();
std::ostream& stream() { return stream_; } std::ostream& stream() { return stream_; }
@ -614,8 +616,6 @@ class LogMessage {
SaveLastError last_error_; SaveLastError last_error_;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(LogMessage);
}; };
// A non-macro interface to the log facility; (useful // A non-macro interface to the log facility; (useful
@ -655,6 +655,9 @@ class Win32ErrorLogMessage {
LogSeverity severity, LogSeverity severity,
SystemErrorCode err); SystemErrorCode err);
Win32ErrorLogMessage(const Win32ErrorLogMessage&) = delete;
Win32ErrorLogMessage& operator=(const Win32ErrorLogMessage&) = delete;
// Appends the error message before destructing the encapsulated class. // Appends the error message before destructing the encapsulated class.
~Win32ErrorLogMessage(); ~Win32ErrorLogMessage();
@ -663,8 +666,6 @@ class Win32ErrorLogMessage {
private: private:
SystemErrorCode err_; SystemErrorCode err_;
LogMessage log_message_; LogMessage log_message_;
DISALLOW_COPY_AND_ASSIGN(Win32ErrorLogMessage);
}; };
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
// Appends a formatted system message of the errno type // Appends a formatted system message of the errno type
@ -675,6 +676,9 @@ class ErrnoLogMessage {
LogSeverity severity, LogSeverity severity,
SystemErrorCode err); SystemErrorCode err);
ErrnoLogMessage(const ErrnoLogMessage&) = delete;
ErrnoLogMessage& operator=(const ErrnoLogMessage&) = delete;
// Appends the error message before destructing the encapsulated class. // Appends the error message before destructing the encapsulated class.
~ErrnoLogMessage(); ~ErrnoLogMessage();
@ -683,8 +687,6 @@ class ErrnoLogMessage {
private: private:
SystemErrorCode err_; SystemErrorCode err_;
LogMessage log_message_; LogMessage log_message_;
DISALLOW_COPY_AND_ASSIGN(ErrnoLogMessage);
}; };
#endif // OS_WIN #endif // OS_WIN

View File

@ -49,7 +49,6 @@
#include "include/base/cef_build.h" #include "include/base/cef_build.h"
#include "include/base/cef_compiler_specific.h" #include "include/base/cef_compiler_specific.h"
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_scoped_refptr.h" #include "include/base/cef_scoped_refptr.h"
#include "include/base/cef_template_util.h" #include "include/base/cef_template_util.h"
#include "include/base/cef_thread_checker.h" #include "include/base/cef_thread_checker.h"
@ -76,6 +75,9 @@ class RefCountedBase {
#endif #endif
} }
RefCountedBase(const RefCountedBase&) = delete;
RefCountedBase& operator=(const RefCountedBase&) = delete;
~RefCountedBase() { ~RefCountedBase() {
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()"; DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
@ -168,8 +170,6 @@ class RefCountedBase {
mutable bool in_dtor_ = false; mutable bool in_dtor_ = false;
mutable ThreadChecker thread_checker_; mutable ThreadChecker thread_checker_;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(RefCountedBase);
}; };
class RefCountedThreadSafeBase { class RefCountedThreadSafeBase {
@ -186,6 +186,9 @@ class RefCountedThreadSafeBase {
#endif #endif
} }
RefCountedThreadSafeBase(const RefCountedThreadSafeBase&) = delete;
RefCountedThreadSafeBase& operator=(const RefCountedThreadSafeBase&) = delete;
#if DCHECK_IS_ON() #if DCHECK_IS_ON()
~RefCountedThreadSafeBase(); ~RefCountedThreadSafeBase();
#else #else
@ -259,8 +262,6 @@ class RefCountedThreadSafeBase {
mutable bool needs_adopt_ref_ = false; mutable bool needs_adopt_ref_ = false;
mutable bool in_dtor_ = false; mutable bool in_dtor_ = false;
#endif #endif
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
}; };
// ScopedAllowCrossThreadRefCountAccess disables the check documented on // ScopedAllowCrossThreadRefCountAccess disables the check documented on
@ -357,6 +358,9 @@ class RefCounted : public cef_subtle::RefCountedBase {
RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {} RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {}
RefCounted(const RefCounted&) = delete;
RefCounted& operator=(const RefCounted&) = delete;
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); } void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
void Release() const { void Release() const {
@ -379,8 +383,6 @@ class RefCounted : public cef_subtle::RefCountedBase {
static void DeleteInternal(const U* x) { static void DeleteInternal(const U* x) {
delete x; delete x;
} }
DISALLOW_COPY_AND_ASSIGN(RefCounted);
}; };
// Forward declaration. // Forward declaration.
@ -424,6 +426,9 @@ class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
explicit RefCountedThreadSafe() explicit RefCountedThreadSafe()
: cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {} : cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
RefCountedThreadSafe(const RefCountedThreadSafe&) = delete;
RefCountedThreadSafe& operator=(const RefCountedThreadSafe&) = delete;
void AddRef() const { AddRefImpl(T::kRefCountPreference); } void AddRef() const { AddRefImpl(T::kRefCountPreference); }
void Release() const { void Release() const {
@ -450,8 +455,6 @@ class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
void AddRefImpl(cef_subtle::StartRefCountFromOneTag) const { void AddRefImpl(cef_subtle::StartRefCountFromOneTag) const {
cef_subtle::RefCountedThreadSafeBase::AddRefWithCheck(); cef_subtle::RefCountedThreadSafeBase::AddRefWithCheck();
} }
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
}; };
// //

View File

@ -48,7 +48,6 @@
#include "include/base/cef_compiler_specific.h" #include "include/base/cef_compiler_specific.h"
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
template <class T> template <class T>
class scoped_refptr; class scoped_refptr;

View File

@ -109,7 +109,6 @@
#include "include/base/cef_atomic_flag.h" #include "include/base/cef_atomic_flag.h"
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_ref_counted.h" #include "include/base/cef_ref_counted.h"
#include "include/base/cef_thread_checker.h" #include "include/base/cef_thread_checker.h"
@ -357,9 +356,14 @@ class WeakPtrFactoryBase {
template <class T> template <class T>
class WeakPtrFactory : public internal::WeakPtrFactoryBase { class WeakPtrFactory : public internal::WeakPtrFactoryBase {
public: public:
WeakPtrFactory() = delete;
explicit WeakPtrFactory(T* ptr) explicit WeakPtrFactory(T* ptr)
: WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {} : WeakPtrFactoryBase(reinterpret_cast<uintptr_t>(ptr)) {}
WeakPtrFactory(const WeakPtrFactory&) = delete;
WeakPtrFactory& operator=(const WeakPtrFactory&) = delete;
~WeakPtrFactory() = default; ~WeakPtrFactory() = default;
WeakPtr<T> GetWeakPtr() const { WeakPtr<T> GetWeakPtr() const {
@ -378,9 +382,6 @@ class WeakPtrFactory : public internal::WeakPtrFactoryBase {
DCHECK(ptr_); DCHECK(ptr_);
return weak_reference_owner_.HasRefs(); return weak_reference_owner_.HasRefs();
} }
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(WeakPtrFactory);
}; };
// A class may extend from SupportsWeakPtr to let others take weak pointers to // A class may extend from SupportsWeakPtr to let others take weak pointers to
@ -393,6 +394,9 @@ class SupportsWeakPtr : public internal::SupportsWeakPtrBase {
public: public:
SupportsWeakPtr() = default; SupportsWeakPtr() = default;
SupportsWeakPtr(const SupportsWeakPtr&) = delete;
SupportsWeakPtr& operator=(const SupportsWeakPtr&) = delete;
WeakPtr<T> AsWeakPtr() { WeakPtr<T> AsWeakPtr() {
return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this)); return WeakPtr<T>(weak_reference_owner_.GetRef(), static_cast<T*>(this));
} }
@ -402,7 +406,6 @@ class SupportsWeakPtr : public internal::SupportsWeakPtrBase {
private: private:
internal::WeakReferenceOwner weak_reference_owner_; internal::WeakReferenceOwner weak_reference_owner_;
DISALLOW_COPY_AND_ASSIGN(SupportsWeakPtr);
}; };
// Helper function that uses type deduction to safely return a WeakPtr<Derived> // Helper function that uses type deduction to safely return a WeakPtr<Derived>

View File

@ -40,8 +40,6 @@
#include <pthread.h> #include <pthread.h>
#endif #endif
#include "include/base/cef_macros.h"
namespace base { namespace base {
namespace cef_internal { namespace cef_internal {
@ -57,6 +55,10 @@ class LockImpl {
#endif #endif
LockImpl(); LockImpl();
LockImpl(const LockImpl&) = delete;
LockImpl& operator=(const LockImpl&) = delete;
~LockImpl(); ~LockImpl();
// If the lock is not held, take it and return true. If the lock is already // If the lock is not held, take it and return true. If the lock is already
@ -77,8 +79,6 @@ class LockImpl {
private: private:
NativeHandle native_handle_; NativeHandle native_handle_;
DISALLOW_COPY_AND_ASSIGN(LockImpl);
}; };
} // namespace cef_internal } // namespace cef_internal

View File

@ -90,7 +90,10 @@ class CefBaseScoped {
/// ///
class CefRefCount { class CefRefCount {
public: public:
CefRefCount() {} CefRefCount() = default;
CefRefCount(const CefRefCount&) = delete;
CefRefCount& operator=(const CefRefCount&) = delete;
/// ///
// Increment the reference count. // Increment the reference count.
@ -114,7 +117,6 @@ class CefRefCount {
private: private:
mutable base::AtomicRefCount ref_count_{0}; mutable base::AtomicRefCount ref_count_{0};
DISALLOW_COPY_AND_ASSIGN(CefRefCount);
}; };
/// ///

View File

@ -8,6 +8,7 @@
#include <string> #include <string>
#include "include/base/cef_macros.h"
#include "include/base/cef_ref_counted.h" #include "include/base/cef_ref_counted.h"
#include "include/internal/cef_types_wrappers.h" #include "include/internal/cef_types_wrappers.h"
#include "tests/cefclient/browser/osr_renderer_settings.h" #include "tests/cefclient/browser/osr_renderer_settings.h"