Rename 'subtle' namespace to fix duplicate symbol errors (see issue #3140)
This commit is contained in:
parent
17fc2b3e3b
commit
6a1c641f75
|
@ -55,7 +55,7 @@
|
||||||
#include "include/base/cef_thread_checker.h"
|
#include "include/base/cef_thread_checker.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
namespace subtle {
|
namespace cef_subtle {
|
||||||
|
|
||||||
class RefCountedBase {
|
class RefCountedBase {
|
||||||
public:
|
public:
|
||||||
|
@ -263,8 +263,6 @@ class RefCountedThreadSafeBase {
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafeBase);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace subtle
|
|
||||||
|
|
||||||
// ScopedAllowCrossThreadRefCountAccess disables the check documented on
|
// ScopedAllowCrossThreadRefCountAccess disables the check documented on
|
||||||
// RefCounted below for rare pre-existing use cases where thread-safety was
|
// RefCounted below for rare pre-existing use cases where thread-safety was
|
||||||
// guaranteed through other means (e.g. explicit sequencing of calls across
|
// guaranteed through other means (e.g. explicit sequencing of calls across
|
||||||
|
@ -286,6 +284,11 @@ class ScopedAllowCrossThreadRefCountAccess final {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace cef_subtle
|
||||||
|
|
||||||
|
using ScopedAllowCrossThreadRefCountAccess =
|
||||||
|
cef_subtle::ScopedAllowCrossThreadRefCountAccess;
|
||||||
|
|
||||||
//
|
//
|
||||||
// A base class for reference counted classes. Otherwise, known as a cheap
|
// A base class for reference counted classes. Otherwise, known as a cheap
|
||||||
// knock-off of WebKit's RefCounted<T> class. To use this, just extend your
|
// knock-off of WebKit's RefCounted<T> class. To use this, just extend your
|
||||||
|
@ -333,8 +336,8 @@ class ScopedAllowCrossThreadRefCountAccess final {
|
||||||
// base::RefCounted.
|
// base::RefCounted.
|
||||||
//
|
//
|
||||||
#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \
|
#define REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() \
|
||||||
static constexpr ::base::subtle::StartRefCountFromOneTag \
|
static constexpr ::base::cef_subtle::StartRefCountFromOneTag \
|
||||||
kRefCountPreference = ::base::subtle::kStartRefCountFromOneTag
|
kRefCountPreference = ::base::cef_subtle::kStartRefCountFromOneTag
|
||||||
|
|
||||||
template <class T, typename Traits>
|
template <class T, typename Traits>
|
||||||
class RefCounted;
|
class RefCounted;
|
||||||
|
@ -347,17 +350,17 @@ struct DefaultRefCountedTraits {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, typename Traits = DefaultRefCountedTraits<T>>
|
template <class T, typename Traits = DefaultRefCountedTraits<T>>
|
||||||
class RefCounted : public subtle::RefCountedBase {
|
class RefCounted : public cef_subtle::RefCountedBase {
|
||||||
public:
|
public:
|
||||||
static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference =
|
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||||
subtle::kStartRefCountFromZeroTag;
|
cef_subtle::kStartRefCountFromZeroTag;
|
||||||
|
|
||||||
RefCounted() : subtle::RefCountedBase(T::kRefCountPreference) {}
|
RefCounted() : cef_subtle::RefCountedBase(T::kRefCountPreference) {}
|
||||||
|
|
||||||
void AddRef() const { subtle::RefCountedBase::AddRef(); }
|
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
|
||||||
|
|
||||||
void Release() const {
|
void Release() const {
|
||||||
if (subtle::RefCountedBase::Release()) {
|
if (cef_subtle::RefCountedBase::Release()) {
|
||||||
// Prune the code paths which the static analyzer may take to simulate
|
// Prune the code paths which the static analyzer may take to simulate
|
||||||
// object destruction. Use-after-free errors aren't possible given the
|
// object destruction. Use-after-free errors aren't possible given the
|
||||||
// lifetime guarantees of the refcounting system.
|
// lifetime guarantees of the refcounting system.
|
||||||
|
@ -413,18 +416,18 @@ struct DefaultRefCountedThreadSafeTraits {
|
||||||
// We can use REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() with RefCountedThreadSafe
|
// We can use REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE() with RefCountedThreadSafe
|
||||||
// too. See the comment above the RefCounted definition for details.
|
// too. See the comment above the RefCounted definition for details.
|
||||||
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
|
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
|
||||||
class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {
|
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
|
||||||
public:
|
public:
|
||||||
static constexpr subtle::StartRefCountFromZeroTag kRefCountPreference =
|
static constexpr cef_subtle::StartRefCountFromZeroTag kRefCountPreference =
|
||||||
subtle::kStartRefCountFromZeroTag;
|
cef_subtle::kStartRefCountFromZeroTag;
|
||||||
|
|
||||||
explicit RefCountedThreadSafe()
|
explicit RefCountedThreadSafe()
|
||||||
: subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
|
: cef_subtle::RefCountedThreadSafeBase(T::kRefCountPreference) {}
|
||||||
|
|
||||||
void AddRef() const { AddRefImpl(T::kRefCountPreference); }
|
void AddRef() const { AddRefImpl(T::kRefCountPreference); }
|
||||||
|
|
||||||
void Release() const {
|
void Release() const {
|
||||||
if (subtle::RefCountedThreadSafeBase::Release()) {
|
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
|
||||||
ANALYZER_SKIP_THIS_PATH();
|
ANALYZER_SKIP_THIS_PATH();
|
||||||
Traits::Destruct(static_cast<const T*>(this));
|
Traits::Destruct(static_cast<const T*>(this));
|
||||||
}
|
}
|
||||||
|
@ -440,12 +443,12 @@ class RefCountedThreadSafe : public subtle::RefCountedThreadSafeBase {
|
||||||
delete x;
|
delete x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddRefImpl(subtle::StartRefCountFromZeroTag) const {
|
void AddRefImpl(cef_subtle::StartRefCountFromZeroTag) const {
|
||||||
subtle::RefCountedThreadSafeBase::AddRef();
|
cef_subtle::RefCountedThreadSafeBase::AddRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddRefImpl(subtle::StartRefCountFromOneTag) const {
|
void AddRefImpl(cef_subtle::StartRefCountFromOneTag) const {
|
||||||
subtle::RefCountedThreadSafeBase::AddRefWithCheck();
|
cef_subtle::RefCountedThreadSafeBase::AddRefWithCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
|
DISALLOW_COPY_AND_ASSIGN(RefCountedThreadSafe);
|
||||||
|
|
|
@ -46,9 +46,9 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
#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_macros.h"
|
||||||
#include "include/base/cef_compiler_specific.h"
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class scoped_refptr;
|
class scoped_refptr;
|
||||||
|
@ -71,7 +71,7 @@ class BasePromise;
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
|
||||||
namespace subtle {
|
namespace cef_subtle {
|
||||||
|
|
||||||
enum AdoptRefTag { kAdoptRefTag };
|
enum AdoptRefTag { kAdoptRefTag };
|
||||||
enum StartRefCountFromZeroTag { kStartRefCountFromZeroTag };
|
enum StartRefCountFromZeroTag { kStartRefCountFromZeroTag };
|
||||||
|
@ -96,7 +96,7 @@ constexpr bool IsRefCountPreferenceOverridden(...) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace subtle
|
} // namespace cef_subtle
|
||||||
|
|
||||||
// Creates a scoped_refptr from a raw pointer without incrementing the reference
|
// Creates a scoped_refptr from a raw pointer without incrementing the reference
|
||||||
// count. Use this only for a newly created object whose reference count starts
|
// count. Use this only for a newly created object whose reference count starts
|
||||||
|
@ -104,16 +104,16 @@ constexpr bool IsRefCountPreferenceOverridden(...) {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
scoped_refptr<T> AdoptRef(T* obj) {
|
scoped_refptr<T> AdoptRef(T* obj) {
|
||||||
using Tag = std::decay_t<decltype(T::kRefCountPreference)>;
|
using Tag = std::decay_t<decltype(T::kRefCountPreference)>;
|
||||||
static_assert(std::is_same<subtle::StartRefCountFromOneTag, Tag>::value,
|
static_assert(std::is_same<cef_subtle::StartRefCountFromOneTag, Tag>::value,
|
||||||
"Use AdoptRef only if the reference count starts from one.");
|
"Use AdoptRef only if the reference count starts from one.");
|
||||||
|
|
||||||
DCHECK(obj);
|
DCHECK(obj);
|
||||||
DCHECK(obj->HasOneRef());
|
DCHECK(obj->HasOneRef());
|
||||||
obj->Adopted();
|
obj->Adopted();
|
||||||
return scoped_refptr<T>(obj, subtle::kAdoptRefTag);
|
return scoped_refptr<T>(obj, cef_subtle::kAdoptRefTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace subtle {
|
namespace cef_subtle {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromZeroTag) {
|
scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromZeroTag) {
|
||||||
|
@ -125,14 +125,14 @@ scoped_refptr<T> AdoptRefIfNeeded(T* obj, StartRefCountFromOneTag) {
|
||||||
return AdoptRef(obj);
|
return AdoptRef(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace subtle
|
} // namespace cef_subtle
|
||||||
|
|
||||||
// Constructs an instance of T, which is a ref counted type, and wraps the
|
// Constructs an instance of T, which is a ref counted type, and wraps the
|
||||||
// object into a scoped_refptr<T>.
|
// object into a scoped_refptr<T>.
|
||||||
template <typename T, typename... Args>
|
template <typename T, typename... Args>
|
||||||
scoped_refptr<T> MakeRefCounted(Args&&... args) {
|
scoped_refptr<T> MakeRefCounted(Args&&... args) {
|
||||||
T* obj = new T(std::forward<Args>(args)...);
|
T* obj = new T(std::forward<Args>(args)...);
|
||||||
return subtle::AdoptRefIfNeeded(obj, T::kRefCountPreference);
|
return cef_subtle::AdoptRefIfNeeded(obj, T::kRefCountPreference);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes an instance of T, which is a ref counted type, and wraps the object
|
// Takes an instance of T, which is a ref counted type, and wraps the object
|
||||||
|
@ -250,7 +250,7 @@ class TRIVIAL_ABI scoped_refptr {
|
||||||
}
|
}
|
||||||
|
|
||||||
~scoped_refptr() {
|
~scoped_refptr() {
|
||||||
static_assert(!base::subtle::IsRefCountPreferenceOverridden(
|
static_assert(!base::cef_subtle::IsRefCountPreferenceOverridden(
|
||||||
static_cast<T*>(nullptr), static_cast<T*>(nullptr)),
|
static_cast<T*>(nullptr), static_cast<T*>(nullptr)),
|
||||||
"It's unsafe to override the ref count preference."
|
"It's unsafe to override the ref count preference."
|
||||||
" Please remove REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE"
|
" Please remove REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE"
|
||||||
|
@ -324,7 +324,7 @@ class TRIVIAL_ABI scoped_refptr {
|
||||||
friend class ::base::internal::BasePromise;
|
friend class ::base::internal::BasePromise;
|
||||||
friend class ::base::WrappedPromise;
|
friend class ::base::WrappedPromise;
|
||||||
|
|
||||||
scoped_refptr(T* p, base::subtle::AdoptRefTag) : ptr_(p) {}
|
scoped_refptr(T* p, base::cef_subtle::AdoptRefTag) : ptr_(p) {}
|
||||||
|
|
||||||
// Friend required for move constructors that set r.ptr_ to null.
|
// Friend required for move constructors that set r.ptr_ to null.
|
||||||
template <typename U>
|
template <typename U>
|
||||||
|
|
|
@ -16,7 +16,7 @@ std::atomic_int g_cross_thread_ref_count_access_allow_count(0);
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace subtle {
|
namespace cef_subtle {
|
||||||
|
|
||||||
bool RefCountedThreadSafeBase::HasOneRef() const {
|
bool RefCountedThreadSafeBase::HasOneRef() const {
|
||||||
return ref_count_.IsOne();
|
return ref_count_.IsOne();
|
||||||
|
@ -84,8 +84,6 @@ bool RefCountedBase::CalledOnValidThread() const {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace subtle
|
|
||||||
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
ScopedAllowCrossThreadRefCountAccess::ScopedAllowCrossThreadRefCountAccess() {
|
ScopedAllowCrossThreadRefCountAccess::ScopedAllowCrossThreadRefCountAccess() {
|
||||||
++g_cross_thread_ref_count_access_allow_count;
|
++g_cross_thread_ref_count_access_allow_count;
|
||||||
|
@ -96,4 +94,5 @@ ScopedAllowCrossThreadRefCountAccess::~ScopedAllowCrossThreadRefCountAccess() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
} // namespace cef_subtle
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
|
Loading…
Reference in New Issue