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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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