mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Use DCHECK_IS_ON() instead of !NDEBUG for debug logic (issue #1961)
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
// If the Chromium implementation diverges the below implementation should be
|
||||
// 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"
|
||||
@@ -57,7 +58,7 @@ namespace cef_internal {
|
||||
// AssertAcquired() method.
|
||||
class Lock {
|
||||
public:
|
||||
#if defined(NDEBUG) // Optimized wrapper implementation
|
||||
#if !DCHECK_IS_ON() // Optimized wrapper implementation
|
||||
Lock() : lock_() {}
|
||||
~Lock() {}
|
||||
void Acquire() { lock_.Lock(); }
|
||||
@@ -96,10 +97,10 @@ class Lock {
|
||||
}
|
||||
|
||||
void AssertAcquired() const;
|
||||
#endif // NDEBUG
|
||||
#endif // !DCHECK_IS_ON()
|
||||
|
||||
private:
|
||||
#if !defined(NDEBUG)
|
||||
#if DCHECK_IS_ON()
|
||||
// Members and routines taking care of locks assertions.
|
||||
// Note that this checks for recursive locks and allows them
|
||||
// if the variable is set. This is allowed by the underlying implementation
|
||||
@@ -111,7 +112,7 @@ class Lock {
|
||||
// All private data is implicitly protected by lock_.
|
||||
// Be VERY careful to only access members under that lock.
|
||||
base::PlatformThreadRef owning_thread_ref_;
|
||||
#endif // NDEBUG
|
||||
#endif // DCHECK_IS_ON()
|
||||
|
||||
// Platform specific underlying lock implementation.
|
||||
LockImpl lock_;
|
||||
|
@@ -50,9 +50,7 @@
|
||||
|
||||
#include "include/base/cef_atomic_ref_count.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#ifndef NDEBUG
|
||||
#include "include/base/cef_logging.h"
|
||||
#endif
|
||||
#include "include/base/cef_thread_collision_warner.h"
|
||||
|
||||
namespace base {
|
||||
@@ -66,14 +64,14 @@ class RefCountedBase {
|
||||
protected:
|
||||
RefCountedBase()
|
||||
: ref_count_(0)
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
, in_dtor_(false)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
~RefCountedBase() {
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
|
||||
#endif
|
||||
}
|
||||
@@ -84,7 +82,7 @@ class RefCountedBase {
|
||||
// Current thread books the critical section "AddRelease"
|
||||
// without release it.
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
++ref_count_;
|
||||
@@ -96,11 +94,11 @@ class RefCountedBase {
|
||||
// Current thread books the critical section "AddRelease"
|
||||
// without release it.
|
||||
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
DCHECK(!in_dtor_);
|
||||
#endif
|
||||
if (--ref_count_ == 0) {
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
in_dtor_ = true;
|
||||
#endif
|
||||
return true;
|
||||
@@ -110,7 +108,7 @@ class RefCountedBase {
|
||||
|
||||
private:
|
||||
mutable int ref_count_;
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool in_dtor_;
|
||||
#endif
|
||||
|
||||
@@ -134,7 +132,7 @@ class RefCountedThreadSafeBase {
|
||||
|
||||
private:
|
||||
mutable AtomicRefCount ref_count_;
|
||||
#ifndef NDEBUG
|
||||
#if DCHECK_IS_ON()
|
||||
mutable bool in_dtor_;
|
||||
#endif
|
||||
|
||||
|
@@ -50,6 +50,7 @@
|
||||
#include "include/base/cef_atomicops.h"
|
||||
#include "include/base/cef_basictypes.h"
|
||||
#include "include/base/cef_build.h"
|
||||
#include "include/base/cef_logging.h"
|
||||
#include "include/base/cef_macros.h"
|
||||
|
||||
// A helper class alongside macros to be used to verify assumptions about thread
|
||||
@@ -139,7 +140,7 @@
|
||||
// };
|
||||
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
#if DCHECK_IS_ON()
|
||||
|
||||
// Defines a class member that acts like a mutex. It is used only as a
|
||||
// verification tool.
|
||||
|
Reference in New Issue
Block a user