Rename namespace to "cef_internal" for base types

This fixes duplicate symbol errors when building CEF sample applications as
part of the Chromium build. These applications pick up a link-time dependency
on base.lib via the //sandbox and/or //testing/gtest targets which then
conflict with the symbols provided by the libcef_dll_wrapper target.
This commit is contained in:
Marshall Greenblatt 2023-01-04 13:40:37 -05:00
parent a986b1c226
commit 83cb82d50f
7 changed files with 63 additions and 63 deletions

View File

@ -97,20 +97,20 @@ namespace base {
/// Bind as OnceCallback. /// Bind as OnceCallback.
/// ///
template <typename Functor, typename... Args> template <typename Functor, typename... Args>
inline OnceCallback<internal::MakeUnboundRunType<Functor, Args...>> BindOnce( inline OnceCallback<cef_internal::MakeUnboundRunType<Functor, Args...>> BindOnce(
Functor&& functor, Functor&& functor,
Args&&... args) { Args&&... args) {
static_assert(!internal::IsOnceCallback<std::decay_t<Functor>>() || static_assert(!cef_internal::IsOnceCallback<std::decay_t<Functor>>() ||
(std::is_rvalue_reference<Functor&&>() && (std::is_rvalue_reference<Functor&&>() &&
!std::is_const<std::remove_reference_t<Functor>>()), !std::is_const<std::remove_reference_t<Functor>>()),
"BindOnce requires non-const rvalue for OnceCallback binding." "BindOnce requires non-const rvalue for OnceCallback binding."
" I.e.: base::BindOnce(std::move(callback))."); " I.e.: base::BindOnce(std::move(callback)).");
static_assert( static_assert(
conjunction< conjunction<
internal::AssertBindArgIsNotBasePassed<std::decay_t<Args>>...>::value, cef_internal::AssertBindArgIsNotBasePassed<std::decay_t<Args>>...>::value,
"Use std::move() instead of base::Passed() with base::BindOnce()"); "Use std::move() instead of base::Passed() with base::BindOnce()");
return internal::BindImpl<OnceCallback>(std::forward<Functor>(functor), return cef_internal::BindImpl<OnceCallback>(std::forward<Functor>(functor),
std::forward<Args>(args)...); std::forward<Args>(args)...);
} }
@ -118,13 +118,13 @@ inline OnceCallback<internal::MakeUnboundRunType<Functor, Args...>> BindOnce(
/// Bind as RepeatingCallback. /// Bind as RepeatingCallback.
/// ///
template <typename Functor, typename... Args> template <typename Functor, typename... Args>
inline RepeatingCallback<internal::MakeUnboundRunType<Functor, Args...>> inline RepeatingCallback<cef_internal::MakeUnboundRunType<Functor, Args...>>
BindRepeating(Functor&& functor, Args&&... args) { BindRepeating(Functor&& functor, Args&&... args) {
static_assert( static_assert(
!internal::IsOnceCallback<std::decay_t<Functor>>(), !cef_internal::IsOnceCallback<std::decay_t<Functor>>(),
"BindRepeating cannot bind OnceCallback. Use BindOnce with std::move()."); "BindRepeating cannot bind OnceCallback. Use BindOnce with std::move().");
return internal::BindImpl<RepeatingCallback>(std::forward<Functor>(functor), return cef_internal::BindImpl<RepeatingCallback>(std::forward<Functor>(functor),
std::forward<Args>(args)...); std::forward<Args>(args)...);
} }
@ -175,8 +175,8 @@ RepeatingCallback<Signature> BindRepeating(
/// to compile because Foo does not support the AddRef() and Release() methods. /// to compile because Foo does not support the AddRef() and Release() methods.
/// ///
template <typename T> template <typename T>
inline internal::UnretainedWrapper<T> Unretained(T* o) { inline cef_internal::UnretainedWrapper<T> Unretained(T* o) {
return internal::UnretainedWrapper<T>(o); return cef_internal::UnretainedWrapper<T>(o);
} }
/// ///
@ -201,12 +201,12 @@ inline internal::UnretainedWrapper<T> Unretained(T* o) {
/// </pre> /// </pre>
/// ///
template <typename T> template <typename T>
inline internal::RetainedRefWrapper<T> RetainedRef(T* o) { inline cef_internal::RetainedRefWrapper<T> RetainedRef(T* o) {
return internal::RetainedRefWrapper<T>(o); return cef_internal::RetainedRefWrapper<T>(o);
} }
template <typename T> template <typename T>
inline internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) { inline cef_internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) {
return internal::RetainedRefWrapper<T>(std::move(o)); return cef_internal::RetainedRefWrapper<T>(std::move(o));
} }
/// ///
@ -234,14 +234,14 @@ inline internal::RetainedRefWrapper<T> RetainedRef(scoped_refptr<T> o) {
/// reference to the callback is deleted. /// reference to the callback is deleted.
/// ///
template <typename T> template <typename T>
inline internal::OwnedWrapper<T> Owned(T* o) { inline cef_internal::OwnedWrapper<T> Owned(T* o) {
return internal::OwnedWrapper<T>(o); return cef_internal::OwnedWrapper<T>(o);
} }
template <typename T, typename Deleter> template <typename T, typename Deleter>
inline internal::OwnedWrapper<T, Deleter> Owned( inline cef_internal::OwnedWrapper<T, Deleter> Owned(
std::unique_ptr<T, Deleter>&& ptr) { std::unique_ptr<T, Deleter>&& ptr) {
return internal::OwnedWrapper<T, Deleter>(std::move(ptr)); return cef_internal::OwnedWrapper<T, Deleter>(std::move(ptr));
} }
/// ///
@ -277,8 +277,8 @@ inline internal::OwnedWrapper<T, Deleter> Owned(
/// an object owned by the callback. /// an object owned by the callback.
/// ///
template <typename T> template <typename T>
internal::OwnedRefWrapper<std::decay_t<T>> OwnedRef(T&& t) { cef_internal::OwnedRefWrapper<std::decay_t<T>> OwnedRef(T&& t) {
return internal::OwnedRefWrapper<std::decay_t<T>>(std::forward<T>(t)); return cef_internal::OwnedRefWrapper<std::decay_t<T>>(std::forward<T>(t));
} }
/// ///
@ -329,12 +329,12 @@ internal::OwnedRefWrapper<std::decay_t<T>> OwnedRef(T&& t) {
/// ///
template <typename T, template <typename T,
std::enable_if_t<!std::is_lvalue_reference<T>::value>* = nullptr> std::enable_if_t<!std::is_lvalue_reference<T>::value>* = nullptr>
inline internal::PassedWrapper<T> Passed(T&& scoper) { inline cef_internal::PassedWrapper<T> Passed(T&& scoper) {
return internal::PassedWrapper<T>(std::move(scoper)); return cef_internal::PassedWrapper<T>(std::move(scoper));
} }
template <typename T> template <typename T>
inline internal::PassedWrapper<T> Passed(T* scoper) { inline cef_internal::PassedWrapper<T> Passed(T* scoper) {
return internal::PassedWrapper<T>(std::move(*scoper)); return cef_internal::PassedWrapper<T>(std::move(*scoper));
} }
/// ///
@ -357,8 +357,8 @@ inline internal::PassedWrapper<T> Passed(T* scoper) {
/// </pre> /// </pre>
/// ///
template <typename T> template <typename T>
inline internal::IgnoreResultHelper<T> IgnoreResult(T data) { inline cef_internal::IgnoreResultHelper<T> IgnoreResult(T data) {
return internal::IgnoreResultHelper<T>(std::move(data)); return cef_internal::IgnoreResultHelper<T>(std::move(data));
} }
#if defined(OS_APPLE) && !HAS_FEATURE(objc_arc) #if defined(OS_APPLE) && !HAS_FEATURE(objc_arc)

View File

@ -83,18 +83,18 @@
namespace base { namespace base {
template <typename R, typename... Args> template <typename R, typename... Args>
class OnceCallback<R(Args...)> : public internal::CallbackBase { class OnceCallback<R(Args...)> : public cef_internal::CallbackBase {
public: public:
using ResultType = R; using ResultType = R;
using RunType = R(Args...); using RunType = R(Args...);
using PolymorphicInvoke = R (*)(internal::BindStateBase*, using PolymorphicInvoke = R (*)(cef_internal::BindStateBase*,
internal::PassingType<Args>...); cef_internal::PassingType<Args>...);
constexpr OnceCallback() = default; constexpr OnceCallback() = default;
OnceCallback(std::nullptr_t) = delete; OnceCallback(std::nullptr_t) = delete;
explicit OnceCallback(internal::BindStateBase* bind_state) explicit OnceCallback(cef_internal::BindStateBase* bind_state)
: internal::CallbackBase(bind_state) {} : cef_internal::CallbackBase(bind_state) {}
OnceCallback(const OnceCallback&) = delete; OnceCallback(const OnceCallback&) = delete;
OnceCallback& operator=(const OnceCallback&) = delete; OnceCallback& operator=(const OnceCallback&) = delete;
@ -103,10 +103,10 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase {
OnceCallback& operator=(OnceCallback&&) noexcept = default; OnceCallback& operator=(OnceCallback&&) noexcept = default;
OnceCallback(RepeatingCallback<RunType> other) OnceCallback(RepeatingCallback<RunType> other)
: internal::CallbackBase(std::move(other)) {} : cef_internal::CallbackBase(std::move(other)) {}
OnceCallback& operator=(RepeatingCallback<RunType> other) { OnceCallback& operator=(RepeatingCallback<RunType> other) {
static_cast<internal::CallbackBase&>(*this) = std::move(other); static_cast<cef_internal::CallbackBase&>(*this) = std::move(other);
return *this; return *this;
} }
@ -142,7 +142,7 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase {
OnceCallback<ThenR(Args...)> Then(OnceCallback<ThenR(ThenArgs...)> then) && { OnceCallback<ThenR(Args...)> Then(OnceCallback<ThenR(ThenArgs...)> then) && {
CHECK(then); CHECK(then);
return BindOnce( return BindOnce(
internal::ThenHelper< cef_internal::ThenHelper<
OnceCallback, OnceCallback<ThenR(ThenArgs...)>>::CreateTrampoline(), OnceCallback, OnceCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
std::move(*this), std::move(then)); std::move(*this), std::move(then));
} }
@ -155,7 +155,7 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase {
RepeatingCallback<ThenR(ThenArgs...)> then) && { RepeatingCallback<ThenR(ThenArgs...)> then) && {
CHECK(then); CHECK(then);
return BindOnce( return BindOnce(
internal::ThenHelper< cef_internal::ThenHelper<
OnceCallback, OnceCallback,
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(), RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
std::move(*this), std::move(then)); std::move(*this), std::move(then));
@ -163,18 +163,18 @@ class OnceCallback<R(Args...)> : public internal::CallbackBase {
}; };
template <typename R, typename... Args> template <typename R, typename... Args>
class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable { class RepeatingCallback<R(Args...)> : public cef_internal::CallbackBaseCopyable {
public: public:
using ResultType = R; using ResultType = R;
using RunType = R(Args...); using RunType = R(Args...);
using PolymorphicInvoke = R (*)(internal::BindStateBase*, using PolymorphicInvoke = R (*)(cef_internal::BindStateBase*,
internal::PassingType<Args>...); cef_internal::PassingType<Args>...);
constexpr RepeatingCallback() = default; constexpr RepeatingCallback() = default;
RepeatingCallback(std::nullptr_t) = delete; RepeatingCallback(std::nullptr_t) = delete;
explicit RepeatingCallback(internal::BindStateBase* bind_state) explicit RepeatingCallback(cef_internal::BindStateBase* bind_state)
: internal::CallbackBaseCopyable(bind_state) {} : cef_internal::CallbackBaseCopyable(bind_state) {}
// Copyable and movable. // Copyable and movable.
RepeatingCallback(const RepeatingCallback&) = default; RepeatingCallback(const RepeatingCallback&) = default;
@ -224,7 +224,7 @@ class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable {
RepeatingCallback<ThenR(ThenArgs...)> then) const& { RepeatingCallback<ThenR(ThenArgs...)> then) const& {
CHECK(then); CHECK(then);
return BindRepeating( return BindRepeating(
internal::ThenHelper< cef_internal::ThenHelper<
RepeatingCallback, RepeatingCallback,
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(), RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
*this, std::move(then)); *this, std::move(then));
@ -235,7 +235,7 @@ class RepeatingCallback<R(Args...)> : public internal::CallbackBaseCopyable {
RepeatingCallback<ThenR(ThenArgs...)> then) && { RepeatingCallback<ThenR(ThenArgs...)> then) && {
CHECK(then); CHECK(then);
return BindRepeating( return BindRepeating(
internal::ThenHelper< cef_internal::ThenHelper<
RepeatingCallback, RepeatingCallback,
RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(), RepeatingCallback<ThenR(ThenArgs...)>>::CreateTrampoline(),
std::move(*this), std::move(then)); std::move(*this), std::move(then));

View File

@ -97,7 +97,7 @@ struct BindUnwrapTraits;
template <typename Functor, typename BoundArgsTuple, typename SFINAE = void> template <typename Functor, typename BoundArgsTuple, typename SFINAE = void>
struct CallbackCancellationTraits; struct CallbackCancellationTraits;
namespace internal { namespace cef_internal {
template <typename Functor, typename SFINAE = void> template <typename Functor, typename SFINAE = void>
struct FunctorTraits; struct FunctorTraits;
@ -1259,7 +1259,7 @@ decltype(auto) BindImpl(Functor&& functor, Args&&... args) {
std::forward<Functor>(functor), std::forward<Args>(args)...)); std::forward<Functor>(functor), std::forward<Args>(args)...));
} }
} // namespace internal } // namespace cef_internal
// An injection point to control |this| pointer behavior on a method invocation. // An injection point to control |this| pointer behavior on a method invocation.
// If IsWeakReceiver<> is true_type for |T| and |T| is used for a receiver of a // If IsWeakReceiver<> is true_type for |T| and |T| is used for a receiver of a
@ -1303,30 +1303,30 @@ struct BindUnwrapTraits {
}; };
template <typename T> template <typename T>
struct BindUnwrapTraits<internal::UnretainedWrapper<T>> { struct BindUnwrapTraits<cef_internal::UnretainedWrapper<T>> {
static T* Unwrap(const internal::UnretainedWrapper<T>& o) { return o.get(); } static T* Unwrap(const cef_internal::UnretainedWrapper<T>& o) { return o.get(); }
}; };
template <typename T> template <typename T>
struct BindUnwrapTraits<internal::RetainedRefWrapper<T>> { struct BindUnwrapTraits<cef_internal::RetainedRefWrapper<T>> {
static T* Unwrap(const internal::RetainedRefWrapper<T>& o) { return o.get(); } static T* Unwrap(const cef_internal::RetainedRefWrapper<T>& o) { return o.get(); }
}; };
template <typename T, typename Deleter> template <typename T, typename Deleter>
struct BindUnwrapTraits<internal::OwnedWrapper<T, Deleter>> { struct BindUnwrapTraits<cef_internal::OwnedWrapper<T, Deleter>> {
static T* Unwrap(const internal::OwnedWrapper<T, Deleter>& o) { static T* Unwrap(const cef_internal::OwnedWrapper<T, Deleter>& o) {
return o.get(); return o.get();
} }
}; };
template <typename T> template <typename T>
struct BindUnwrapTraits<internal::OwnedRefWrapper<T>> { struct BindUnwrapTraits<cef_internal::OwnedRefWrapper<T>> {
static T& Unwrap(const internal::OwnedRefWrapper<T>& o) { return o.get(); } static T& Unwrap(const cef_internal::OwnedRefWrapper<T>& o) { return o.get(); }
}; };
template <typename T> template <typename T>
struct BindUnwrapTraits<internal::PassedWrapper<T>> { struct BindUnwrapTraits<cef_internal::PassedWrapper<T>> {
static T Unwrap(const internal::PassedWrapper<T>& o) { return o.Take(); } static T Unwrap(const cef_internal::PassedWrapper<T>& o) { return o.Take(); }
}; };
#if defined(OS_WIN) #if defined(OS_WIN)
@ -1351,7 +1351,7 @@ struct CallbackCancellationTraits<
Functor, Functor,
std::tuple<BoundArgs...>, std::tuple<BoundArgs...>,
std::enable_if_t< std::enable_if_t<
internal::IsWeakMethod<internal::FunctorTraits<Functor>::is_method, cef_internal::IsWeakMethod<cef_internal::FunctorTraits<Functor>::is_method,
BoundArgs...>::value>> { BoundArgs...>::value>> {
static constexpr bool is_cancellable = true; static constexpr bool is_cancellable = true;

View File

@ -43,7 +43,7 @@ namespace base {
struct FakeBindState; struct FakeBindState;
namespace internal { namespace cef_internal {
class BindStateBase; class BindStateBase;
class FinallyExecutorCommon; class FinallyExecutorCommon;
@ -269,7 +269,7 @@ struct ThenHelper<OriginalCallback<OriginalR(OriginalArgs...)>,
} }
}; };
} // namespace internal } // namespace cef_internal
} // namespace base } // namespace base
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_ #endif // CEF_INCLUDE_BASE_INTERNAL_CEF_CALLBACK_INTERNAL_H_

View File

@ -47,7 +47,7 @@ namespace base {
// This is a base internal implementation file used by task.h and callback.h. // This is a base internal implementation file used by task.h and callback.h.
// Not for public consumption, so we wrap it in namespace internal. // Not for public consumption, so we wrap it in namespace internal.
namespace internal { namespace cef_internal {
template <typename T, typename = void> template <typename T, typename = void>
struct IsRefCountedType : std::false_type {}; struct IsRefCountedType : std::false_type {};
@ -68,7 +68,7 @@ struct NeedsScopedRefptrButGetsRawPtr
"NeedsScopedRefptrButGetsRawPtr requires non-reference type."); "NeedsScopedRefptrButGetsRawPtr requires non-reference type.");
}; };
} // namespace internal } // namespace cef_internal
} // namespace base } // namespace base

View File

@ -44,7 +44,7 @@
namespace base { namespace base {
namespace mac { namespace mac {
namespace internal { namespace cef_internal {
template <typename B> template <typename B>
struct ScopedBlockTraits { struct ScopedBlockTraits {
@ -53,12 +53,12 @@ struct ScopedBlockTraits {
static void Release(B block) { Block_release(block); } static void Release(B block) { Block_release(block); }
}; };
} // namespace internal } // namespace cef_internal
// ScopedBlock<> is patterned after ScopedCFTypeRef<>, but uses Block_copy() and // ScopedBlock<> is patterned after ScopedCFTypeRef<>, but uses Block_copy() and
// Block_release() instead of CFRetain() and CFRelease(). // Block_release() instead of CFRetain() and CFRelease().
template <typename B> template <typename B>
using ScopedBlock = ScopedTypeRef<B, internal::ScopedBlockTraits<B>>; using ScopedBlock = ScopedTypeRef<B, cef_internal::ScopedBlockTraits<B>>;
} // namespace mac } // namespace mac
} // namespace base } // namespace base

View File

@ -7,7 +7,7 @@
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
namespace base { namespace base {
namespace internal { namespace cef_internal {
namespace { namespace {
@ -97,5 +97,5 @@ CallbackBaseCopyable& CallbackBaseCopyable::operator=(
CallbackBaseCopyable& CallbackBaseCopyable::operator=( CallbackBaseCopyable& CallbackBaseCopyable::operator=(
CallbackBaseCopyable&& c) noexcept = default; CallbackBaseCopyable&& c) noexcept = default;
} // namespace internal } // namespace cef_internal
} // namespace base } // namespace base