mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-09 00:28:59 +01:00
Update include files for bracket style
This commit is contained in:
parent
83cb82d50f
commit
9f8be5ea6c
@ -73,8 +73,9 @@ class AutoReset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~AutoReset() {
|
~AutoReset() {
|
||||||
if (scoped_variable_)
|
if (scoped_variable_) {
|
||||||
*scoped_variable_ = std::move(original_value_);
|
*scoped_variable_ = std::move(original_value_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -97,21 +97,20 @@ namespace base {
|
|||||||
/// Bind as OnceCallback.
|
/// Bind as OnceCallback.
|
||||||
///
|
///
|
||||||
template <typename Functor, typename... Args>
|
template <typename Functor, typename... Args>
|
||||||
inline OnceCallback<cef_internal::MakeUnboundRunType<Functor, Args...>> BindOnce(
|
inline OnceCallback<cef_internal::MakeUnboundRunType<Functor, Args...>>
|
||||||
Functor&& functor,
|
BindOnce(Functor&& functor, Args&&... args) {
|
||||||
Args&&... args) {
|
|
||||||
static_assert(!cef_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<cef_internal::AssertBindArgIsNotBasePassed<
|
||||||
cef_internal::AssertBindArgIsNotBasePassed<std::decay_t<Args>>...>::value,
|
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 cef_internal::BindImpl<OnceCallback>(std::forward<Functor>(functor),
|
return cef_internal::BindImpl<OnceCallback>(std::forward<Functor>(functor),
|
||||||
std::forward<Args>(args)...);
|
std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -124,8 +123,8 @@ BindRepeating(Functor&& functor, Args&&... args) {
|
|||||||
!cef_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 cef_internal::BindImpl<RepeatingCallback>(std::forward<Functor>(functor),
|
return cef_internal::BindImpl<RepeatingCallback>(
|
||||||
std::forward<Args>(args)...);
|
std::forward<Functor>(functor), std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -163,7 +163,8 @@ class OnceCallback<R(Args...)> : public cef_internal::CallbackBase {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename R, typename... Args>
|
template <typename R, typename... Args>
|
||||||
class RepeatingCallback<R(Args...)> : public cef_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...);
|
||||||
|
@ -242,8 +242,9 @@ class CallbackListBase {
|
|||||||
// the reentrant Notify() call.
|
// the reentrant Notify() call.
|
||||||
template <typename... RunArgs>
|
template <typename... RunArgs>
|
||||||
void Notify(RunArgs&&... args) {
|
void Notify(RunArgs&&... args) {
|
||||||
if (empty())
|
if (empty()) {
|
||||||
return; // Nothing to do.
|
return; // Nothing to do.
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
AutoReset<bool> iterating(&iterating_, true);
|
AutoReset<bool> iterating(&iterating_, true);
|
||||||
@ -257,18 +258,20 @@ class CallbackListBase {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
for (auto it = next_valid(callbacks_.begin()); it != callbacks_.end();
|
for (auto it = next_valid(callbacks_.begin()); it != callbacks_.end();
|
||||||
it = next_valid(it))
|
it = next_valid(it)) {
|
||||||
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...,
|
// NOTE: Intentionally does not call std::forward<RunArgs>(args)...,
|
||||||
// since that would allow move-only arguments.
|
// since that would allow move-only arguments.
|
||||||
static_cast<CallbackListImpl*>(this)->RunCallback(it++, args...);
|
static_cast<CallbackListImpl*>(this)->RunCallback(it++, args...);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Re-entrant invocations shouldn't prune anything from the list. This can
|
// Re-entrant invocations shouldn't prune anything from the list. This can
|
||||||
// invalidate iterators from underneath higher call frames. It's safe to
|
// invalidate iterators from underneath higher call frames. It's safe to
|
||||||
// simply do nothing, since the outermost frame will continue through here
|
// simply do nothing, since the outermost frame will continue through here
|
||||||
// and prune all null callbacks below.
|
// and prune all null callbacks below.
|
||||||
if (iterating_)
|
if (iterating_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Any null callbacks remaining in the list were canceled due to
|
// Any null callbacks remaining in the list were canceled due to
|
||||||
// Subscription destruction during iteration, and can safely be erased now.
|
// Subscription destruction during iteration, and can safely be erased now.
|
||||||
@ -282,8 +285,9 @@ class CallbackListBase {
|
|||||||
// that were executed above have all been removed regardless of whether
|
// that were executed above have all been removed regardless of whether
|
||||||
// they're counted in |erased_callbacks_|.
|
// they're counted in |erased_callbacks_|.
|
||||||
if (removal_callback_ &&
|
if (removal_callback_ &&
|
||||||
(erased_callbacks || IsOnceCallback<CallbackType>::value))
|
(erased_callbacks || IsOnceCallback<CallbackType>::value)) {
|
||||||
removal_callback_.Run(); // May delete |this|!
|
removal_callback_.Run(); // May delete |this|!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -295,8 +299,9 @@ class CallbackListBase {
|
|||||||
private:
|
private:
|
||||||
// Cancels the callback pointed to by |it|, which is guaranteed to be valid.
|
// Cancels the callback pointed to by |it|, which is guaranteed to be valid.
|
||||||
void CancelCallback(const typename Callbacks::iterator& it) {
|
void CancelCallback(const typename Callbacks::iterator& it) {
|
||||||
if (static_cast<CallbackListImpl*>(this)->CancelNullCallback(it))
|
if (static_cast<CallbackListImpl*>(this)->CancelNullCallback(it)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (iterating_) {
|
if (iterating_) {
|
||||||
// Calling erase() here is unsafe, since the loop in Notify() may be
|
// Calling erase() here is unsafe, since the loop in Notify() may be
|
||||||
@ -306,8 +311,9 @@ class CallbackListBase {
|
|||||||
it->Reset();
|
it->Reset();
|
||||||
} else {
|
} else {
|
||||||
callbacks_.erase(it);
|
callbacks_.erase(it);
|
||||||
if (removal_callback_)
|
if (removal_callback_) {
|
||||||
removal_callback_.Run(); // May delete |this|!
|
removal_callback_.Run(); // May delete |this|!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,8 +133,9 @@ class CancelableCallbackImpl {
|
|||||||
|
|
||||||
// Returns a callback that can be disabled by calling Cancel().
|
// Returns a callback that can be disabled by calling Cancel().
|
||||||
CallbackType callback() const {
|
CallbackType callback() const {
|
||||||
if (!callback_)
|
if (!callback_) {
|
||||||
return CallbackType();
|
return CallbackType();
|
||||||
|
}
|
||||||
CallbackType forwarder;
|
CallbackType forwarder;
|
||||||
MakeForwarder(&forwarder);
|
MakeForwarder(&forwarder);
|
||||||
return forwarder;
|
return forwarder;
|
||||||
|
@ -105,13 +105,16 @@ class RefCountedBase {
|
|||||||
|
|
||||||
#if DCHECK_IS_ON()
|
#if DCHECK_IS_ON()
|
||||||
DCHECK(!in_dtor_);
|
DCHECK(!in_dtor_);
|
||||||
if (ref_count_ == 0)
|
if (ref_count_ == 0) {
|
||||||
in_dtor_ = true;
|
in_dtor_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (ref_count_ >= 1)
|
if (ref_count_ >= 1) {
|
||||||
DCHECK(CalledOnValidThread());
|
DCHECK(CalledOnValidThread());
|
||||||
if (ref_count_ == 1)
|
}
|
||||||
|
if (ref_count_ == 1) {
|
||||||
thread_checker_.DetachFromThread();
|
thread_checker_.DetachFromThread();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return ref_count_ == 0;
|
return ref_count_ == 0;
|
||||||
|
@ -229,8 +229,9 @@ class TRIVIAL_ABI scoped_refptr {
|
|||||||
// should move or copy construct from an existing scoped_refptr<T> to the
|
// should move or copy construct from an existing scoped_refptr<T> to the
|
||||||
// ref-counted object.
|
// ref-counted object.
|
||||||
scoped_refptr(T* p) : ptr_(p) {
|
scoped_refptr(T* p) : ptr_(p) {
|
||||||
if (ptr_)
|
if (ptr_) {
|
||||||
AddRef(ptr_);
|
AddRef(ptr_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy constructor. This is required in addition to the copy conversion
|
// Copy constructor. This is required in addition to the copy conversion
|
||||||
@ -261,8 +262,9 @@ class TRIVIAL_ABI scoped_refptr {
|
|||||||
"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"
|
||||||
" from subclasses.");
|
" from subclasses.");
|
||||||
if (ptr_)
|
if (ptr_) {
|
||||||
Release(ptr_);
|
Release(ptr_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T* get() const { return ptr_; }
|
T* get() const { return ptr_; }
|
||||||
|
@ -97,21 +97,24 @@ class ScopedTypeRef {
|
|||||||
element_type object = Traits::InvalidValue(),
|
element_type object = Traits::InvalidValue(),
|
||||||
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
|
base::scoped_policy::OwnershipPolicy policy = base::scoped_policy::ASSUME)
|
||||||
: object_(object) {
|
: object_(object) {
|
||||||
if (object_ && policy == base::scoped_policy::RETAIN)
|
if (object_ && policy == base::scoped_policy::RETAIN) {
|
||||||
object_ = Traits::Retain(object_);
|
object_ = Traits::Retain(object_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedTypeRef(const ScopedTypeRef<T, Traits>& that) : object_(that.object_) {
|
ScopedTypeRef(const ScopedTypeRef<T, Traits>& that) : object_(that.object_) {
|
||||||
if (object_)
|
if (object_) {
|
||||||
object_ = Traits::Retain(object_);
|
object_ = Traits::Retain(object_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This allows passing an object to a function that takes its superclass.
|
// This allows passing an object to a function that takes its superclass.
|
||||||
template <typename R, typename RTraits>
|
template <typename R, typename RTraits>
|
||||||
explicit ScopedTypeRef(const ScopedTypeRef<R, RTraits>& that_as_subclass)
|
explicit ScopedTypeRef(const ScopedTypeRef<R, RTraits>& that_as_subclass)
|
||||||
: object_(that_as_subclass.get()) {
|
: object_(that_as_subclass.get()) {
|
||||||
if (object_)
|
if (object_) {
|
||||||
object_ = Traits::Retain(object_);
|
object_ = Traits::Retain(object_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedTypeRef(ScopedTypeRef<T, Traits>&& that) : object_(that.object_) {
|
ScopedTypeRef(ScopedTypeRef<T, Traits>&& that) : object_(that.object_) {
|
||||||
@ -119,8 +122,9 @@ class ScopedTypeRef {
|
|||||||
}
|
}
|
||||||
|
|
||||||
~ScopedTypeRef() {
|
~ScopedTypeRef() {
|
||||||
if (object_)
|
if (object_) {
|
||||||
Traits::Release(object_);
|
Traits::Release(object_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedTypeRef& operator=(const ScopedTypeRef<T, Traits>& that) {
|
ScopedTypeRef& operator=(const ScopedTypeRef<T, Traits>& that) {
|
||||||
@ -143,10 +147,12 @@ class ScopedTypeRef {
|
|||||||
void reset(element_type object = Traits::InvalidValue(),
|
void reset(element_type object = Traits::InvalidValue(),
|
||||||
base::scoped_policy::OwnershipPolicy policy =
|
base::scoped_policy::OwnershipPolicy policy =
|
||||||
base::scoped_policy::ASSUME) {
|
base::scoped_policy::ASSUME) {
|
||||||
if (object && policy == base::scoped_policy::RETAIN)
|
if (object && policy == base::scoped_policy::RETAIN) {
|
||||||
object = Traits::Retain(object);
|
object = Traits::Retain(object);
|
||||||
if (object_)
|
}
|
||||||
|
if (object_) {
|
||||||
Traits::Release(object_);
|
Traits::Release(object_);
|
||||||
|
}
|
||||||
object_ = object;
|
object_ = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,12 @@
|
|||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
|
||||||
template <class T> struct is_non_const_reference : std::false_type {};
|
template <class T>
|
||||||
template <class T> struct is_non_const_reference<T&> : std::true_type {};
|
struct is_non_const_reference : std::false_type {};
|
||||||
template <class T> struct is_non_const_reference<const T&> : std::false_type {};
|
template <class T>
|
||||||
|
struct is_non_const_reference<T&> : std::true_type {};
|
||||||
|
template <class T>
|
||||||
|
struct is_non_const_reference<const T&> : std::false_type {};
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
|
@ -687,8 +687,9 @@ struct InvokeHelper<true, ReturnType> {
|
|||||||
static inline void MakeItSo(Functor&& functor,
|
static inline void MakeItSo(Functor&& functor,
|
||||||
BoundWeakPtr&& weak_ptr,
|
BoundWeakPtr&& weak_ptr,
|
||||||
RunArgs&&... args) {
|
RunArgs&&... args) {
|
||||||
if (!weak_ptr)
|
if (!weak_ptr) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
using Traits = MakeFunctorTraits<Functor>;
|
using Traits = MakeFunctorTraits<Functor>;
|
||||||
Traits::Invoke(std::forward<Functor>(functor),
|
Traits::Invoke(std::forward<Functor>(functor),
|
||||||
std::forward<BoundWeakPtr>(weak_ptr),
|
std::forward<BoundWeakPtr>(weak_ptr),
|
||||||
@ -1304,12 +1305,16 @@ struct BindUnwrapTraits {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct BindUnwrapTraits<cef_internal::UnretainedWrapper<T>> {
|
struct BindUnwrapTraits<cef_internal::UnretainedWrapper<T>> {
|
||||||
static T* Unwrap(const cef_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<cef_internal::RetainedRefWrapper<T>> {
|
struct BindUnwrapTraits<cef_internal::RetainedRefWrapper<T>> {
|
||||||
static T* Unwrap(const cef_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>
|
||||||
@ -1321,7 +1326,9 @@ struct BindUnwrapTraits<cef_internal::OwnedWrapper<T, Deleter>> {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct BindUnwrapTraits<cef_internal::OwnedRefWrapper<T>> {
|
struct BindUnwrapTraits<cef_internal::OwnedRefWrapper<T>> {
|
||||||
static T& Unwrap(const cef_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>
|
||||||
@ -1350,9 +1357,9 @@ template <typename Functor, typename... BoundArgs>
|
|||||||
struct CallbackCancellationTraits<
|
struct CallbackCancellationTraits<
|
||||||
Functor,
|
Functor,
|
||||||
std::tuple<BoundArgs...>,
|
std::tuple<BoundArgs...>,
|
||||||
std::enable_if_t<
|
std::enable_if_t<cef_internal::IsWeakMethod<
|
||||||
cef_internal::IsWeakMethod<cef_internal::FunctorTraits<Functor>::is_method,
|
cef_internal::FunctorTraits<Functor>::is_method,
|
||||||
BoundArgs...>::value>> {
|
BoundArgs...>::value>> {
|
||||||
static constexpr bool is_cancellable = true;
|
static constexpr bool is_cancellable = true;
|
||||||
|
|
||||||
template <typename Receiver, typename... Args>
|
template <typename Receiver, typename... Args>
|
||||||
|
@ -38,7 +38,8 @@
|
|||||||
#include "include/base/cef_scoped_typeref_mac.h"
|
#include "include/base/cef_scoped_typeref_mac.h"
|
||||||
|
|
||||||
#if defined(__has_feature) && __has_feature(objc_arc)
|
#if defined(__has_feature) && __has_feature(objc_arc)
|
||||||
#error "Cannot include include/base/internal/cef_scoped_block_mac.h in file built with ARC."
|
#error \
|
||||||
|
"Cannot include include/base/internal/cef_scoped_block_mac.h in file built with ARC."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
@ -124,22 +124,26 @@ class CefRefCount {
|
|||||||
/// Macro that provides a reference counting implementation for classes
|
/// Macro that provides a reference counting implementation for classes
|
||||||
/// extending CefBase.
|
/// extending CefBase.
|
||||||
///
|
///
|
||||||
#define IMPLEMENT_REFCOUNTING(ClassName) \
|
#define IMPLEMENT_REFCOUNTING(ClassName) \
|
||||||
public: \
|
public: \
|
||||||
void AddRef() const override { ref_count_.AddRef(); } \
|
void AddRef() const override { \
|
||||||
bool Release() const override { \
|
ref_count_.AddRef(); \
|
||||||
if (ref_count_.Release()) { \
|
} \
|
||||||
delete static_cast<const ClassName*>(this); \
|
bool Release() const override { \
|
||||||
return true; \
|
if (ref_count_.Release()) { \
|
||||||
} \
|
delete static_cast<const ClassName*>(this); \
|
||||||
return false; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
bool HasOneRef() const override { return ref_count_.HasOneRef(); } \
|
return false; \
|
||||||
bool HasAtLeastOneRef() const override { \
|
} \
|
||||||
return ref_count_.HasAtLeastOneRef(); \
|
bool HasOneRef() const override { \
|
||||||
} \
|
return ref_count_.HasOneRef(); \
|
||||||
\
|
} \
|
||||||
private: \
|
bool HasAtLeastOneRef() const override { \
|
||||||
|
return ref_count_.HasAtLeastOneRef(); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
private: \
|
||||||
CefRefCount ref_count_
|
CefRefCount ref_count_
|
||||||
|
|
||||||
#endif // CEF_INCLUDE_CEF_BASE_H_
|
#endif // CEF_INCLUDE_CEF_BASE_H_
|
||||||
|
@ -74,8 +74,9 @@ struct CefStringTraitsWide {
|
|||||||
memset(&cstr, 0, sizeof(cstr));
|
memset(&cstr, 0, sizeof(cstr));
|
||||||
cef_string_wide_to_utf8(s->str, s->length, &cstr);
|
cef_string_wide_to_utf8(s->str, s->length, &cstr);
|
||||||
std::string str;
|
std::string str;
|
||||||
if (cstr.length > 0)
|
if (cstr.length > 0) {
|
||||||
str = std::string(cstr.str, cstr.length);
|
str = std::string(cstr.str, cstr.length);
|
||||||
|
}
|
||||||
cef_string_utf8_clear(&cstr);
|
cef_string_utf8_clear(&cstr);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -183,8 +184,9 @@ struct CefStringTraitsUTF8 {
|
|||||||
memset(&cstr, 0, sizeof(cstr));
|
memset(&cstr, 0, sizeof(cstr));
|
||||||
cef_string_utf8_to_wide(s->str, s->length, &cstr);
|
cef_string_utf8_to_wide(s->str, s->length, &cstr);
|
||||||
std::wstring str;
|
std::wstring str;
|
||||||
if (cstr.length > 0)
|
if (cstr.length > 0) {
|
||||||
str = std::wstring(cstr.str, cstr.length);
|
str = std::wstring(cstr.str, cstr.length);
|
||||||
|
}
|
||||||
cef_string_wide_clear(&cstr);
|
cef_string_wide_clear(&cstr);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -255,8 +257,9 @@ struct CefStringTraitsUTF16 {
|
|||||||
memset(&cstr, 0, sizeof(cstr));
|
memset(&cstr, 0, sizeof(cstr));
|
||||||
cef_string_utf16_to_utf8(s->str, s->length, &cstr);
|
cef_string_utf16_to_utf8(s->str, s->length, &cstr);
|
||||||
std::string str;
|
std::string str;
|
||||||
if (cstr.length > 0)
|
if (cstr.length > 0) {
|
||||||
str = std::string(cstr.str, cstr.length);
|
str = std::string(cstr.str, cstr.length);
|
||||||
|
}
|
||||||
cef_string_utf8_clear(&cstr);
|
cef_string_utf8_clear(&cstr);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -274,8 +277,9 @@ struct CefStringTraitsUTF16 {
|
|||||||
memset(&cstr, 0, sizeof(cstr));
|
memset(&cstr, 0, sizeof(cstr));
|
||||||
cef_string_utf16_to_wide(s->str, s->length, &cstr);
|
cef_string_utf16_to_wide(s->str, s->length, &cstr);
|
||||||
std::wstring str;
|
std::wstring str;
|
||||||
if (cstr.length > 0)
|
if (cstr.length > 0) {
|
||||||
str = std::wstring(cstr.str, cstr.length);
|
str = std::wstring(cstr.str, cstr.length);
|
||||||
|
}
|
||||||
cef_string_wide_clear(&cstr);
|
cef_string_wide_clear(&cstr);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -374,8 +378,9 @@ class CefStringBase {
|
|||||||
}
|
}
|
||||||
CefStringBase(const char* src, size_t length = 0)
|
CefStringBase(const char* src, size_t length = 0)
|
||||||
: string_(NULL), owner_(false) {
|
: string_(NULL), owner_(false) {
|
||||||
if (src)
|
if (src) {
|
||||||
FromString(src, length);
|
FromString(src, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -388,8 +393,9 @@ class CefStringBase {
|
|||||||
}
|
}
|
||||||
CefStringBase(const wchar_t* src, size_t length = 0)
|
CefStringBase(const wchar_t* src, size_t length = 0)
|
||||||
: string_(NULL), owner_(false) {
|
: string_(NULL), owner_(false) {
|
||||||
if (src)
|
if (src) {
|
||||||
FromWString(src, length);
|
FromWString(src, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -402,8 +408,9 @@ class CefStringBase {
|
|||||||
}
|
}
|
||||||
CefStringBase(const std::u16string::value_type* src, size_t length = 0)
|
CefStringBase(const std::u16string::value_type* src, size_t length = 0)
|
||||||
: string_(NULL), owner_(false) {
|
: string_(NULL), owner_(false) {
|
||||||
if (src)
|
if (src) {
|
||||||
FromString16(src, length);
|
FromString16(src, length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if defined(WCHAR_T_IS_UTF32)
|
#if defined(WCHAR_T_IS_UTF32)
|
||||||
CefStringBase(const char16* src, size_t length = 0)
|
CefStringBase(const char16* src, size_t length = 0)
|
||||||
@ -423,8 +430,9 @@ class CefStringBase {
|
|||||||
///
|
///
|
||||||
CefStringBase(const char_type* src, size_t src_len, bool copy)
|
CefStringBase(const char_type* src, size_t src_len, bool copy)
|
||||||
: string_(NULL), owner_(false) {
|
: string_(NULL), owner_(false) {
|
||||||
if (src && src_len > 0)
|
if (src && src_len > 0) {
|
||||||
FromString(src, src_len, copy);
|
FromString(src, src_len, copy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -433,8 +441,9 @@ class CefStringBase {
|
|||||||
/// this class and will not be freed by this class.
|
/// this class and will not be freed by this class.
|
||||||
///
|
///
|
||||||
CefStringBase(const struct_type* src) : string_(NULL), owner_(false) {
|
CefStringBase(const struct_type* src) : string_(NULL), owner_(false) {
|
||||||
if (!src)
|
if (!src) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
// Reference the existing structure without taking ownership.
|
// Reference the existing structure without taking ownership.
|
||||||
Attach(const_cast<struct_type*>(src), false);
|
Attach(const_cast<struct_type*>(src), false);
|
||||||
}
|
}
|
||||||
@ -468,12 +477,15 @@ class CefStringBase {
|
|||||||
/// Compare this string to the specified string.
|
/// Compare this string to the specified string.
|
||||||
///
|
///
|
||||||
int compare(const CefStringBase& str) const {
|
int compare(const CefStringBase& str) const {
|
||||||
if (empty() && str.empty())
|
if (empty() && str.empty()) {
|
||||||
return 0;
|
return 0;
|
||||||
if (empty())
|
}
|
||||||
|
if (empty()) {
|
||||||
return -1;
|
return -1;
|
||||||
if (str.empty())
|
}
|
||||||
|
if (str.empty()) {
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
return traits::compare(string_, str.GetStruct());
|
return traits::compare(string_, str.GetStruct());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,8 +493,9 @@ class CefStringBase {
|
|||||||
/// Clear the string data.
|
/// Clear the string data.
|
||||||
///
|
///
|
||||||
void clear() {
|
void clear() {
|
||||||
if (string_)
|
if (string_) {
|
||||||
traits::clear(string_);
|
traits::clear(string_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -524,8 +537,9 @@ class CefStringBase {
|
|||||||
/// will be freed if this class owns the structure.
|
/// will be freed if this class owns the structure.
|
||||||
///
|
///
|
||||||
void ClearAndFree() {
|
void ClearAndFree() {
|
||||||
if (!string_)
|
if (!string_) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if (owner_) {
|
if (owner_) {
|
||||||
clear();
|
clear();
|
||||||
delete string_;
|
delete string_;
|
||||||
@ -555,8 +569,9 @@ class CefStringBase {
|
|||||||
// Free the previous structure and data, if any.
|
// Free the previous structure and data, if any.
|
||||||
ClearAndFree();
|
ClearAndFree();
|
||||||
|
|
||||||
if (!str)
|
if (!str) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AllocIfNeeded();
|
AllocIfNeeded();
|
||||||
owner_ = true;
|
owner_ = true;
|
||||||
@ -583,8 +598,9 @@ class CefStringBase {
|
|||||||
/// this string class currently contains no data.
|
/// this string class currently contains no data.
|
||||||
///
|
///
|
||||||
userfree_struct_type DetachToUserFree() {
|
userfree_struct_type DetachToUserFree() {
|
||||||
if (empty())
|
if (empty()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
userfree_struct_type str = traits::userfree_alloc();
|
userfree_struct_type str = traits::userfree_alloc();
|
||||||
if (owner_) {
|
if (owner_) {
|
||||||
@ -637,8 +653,9 @@ class CefStringBase {
|
|||||||
/// necessary based on the underlying string type.
|
/// necessary based on the underlying string type.
|
||||||
///
|
///
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
if (empty())
|
if (empty()) {
|
||||||
return std::string();
|
return std::string();
|
||||||
|
}
|
||||||
return traits::to_string(string_);
|
return traits::to_string(string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -678,8 +695,9 @@ class CefStringBase {
|
|||||||
/// necessary based on the underlying string type.
|
/// necessary based on the underlying string type.
|
||||||
///
|
///
|
||||||
std::wstring ToWString() const {
|
std::wstring ToWString() const {
|
||||||
if (empty())
|
if (empty()) {
|
||||||
return std::wstring();
|
return std::wstring();
|
||||||
|
}
|
||||||
return traits::to_wstring(string_);
|
return traits::to_wstring(string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,8 +737,9 @@ class CefStringBase {
|
|||||||
/// necessary based on the underlying string type.
|
/// necessary based on the underlying string type.
|
||||||
///
|
///
|
||||||
std::u16string ToString16() const {
|
std::u16string ToString16() const {
|
||||||
if (empty())
|
if (empty()) {
|
||||||
return std::u16string();
|
return std::u16string();
|
||||||
|
}
|
||||||
return traits::to_string16(string_);
|
return traits::to_string16(string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,8 +49,9 @@ class CefStructBase : public traits::struct_type {
|
|||||||
virtual ~CefStructBase() {
|
virtual ~CefStructBase() {
|
||||||
// Only clear this object's data if it isn't currently attached to a
|
// Only clear this object's data if it isn't currently attached to a
|
||||||
// structure.
|
// structure.
|
||||||
if (!attached_to_)
|
if (!attached_to_) {
|
||||||
Clear(this);
|
Clear(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CefStructBase(const CefStructBase& r) {
|
CefStructBase(const CefStructBase& r) {
|
||||||
@ -69,8 +70,9 @@ class CefStructBase : public traits::struct_type {
|
|||||||
void AttachTo(struct_type& source) {
|
void AttachTo(struct_type& source) {
|
||||||
// Only clear this object's data if it isn't currently attached to a
|
// Only clear this object's data if it isn't currently attached to a
|
||||||
// structure.
|
// structure.
|
||||||
if (!attached_to_)
|
if (!attached_to_) {
|
||||||
Clear(this);
|
Clear(this);
|
||||||
|
}
|
||||||
|
|
||||||
// This object is now attached to the new structure.
|
// This object is now attached to the new structure.
|
||||||
attached_to_ = &source;
|
attached_to_ = &source;
|
||||||
|
@ -103,22 +103,26 @@ struct CefDeleteOnFileUserBlockingThread
|
|||||||
struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
|
struct CefDeleteOnRendererThread : public CefDeleteOnThread<TID_RENDERER> {};
|
||||||
|
|
||||||
// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor.
|
// Same as IMPLEMENT_REFCOUNTING() but using the specified Destructor.
|
||||||
#define IMPLEMENT_REFCOUNTING_EX(ClassName, Destructor) \
|
#define IMPLEMENT_REFCOUNTING_EX(ClassName, Destructor) \
|
||||||
public: \
|
public: \
|
||||||
void AddRef() const override { ref_count_.AddRef(); } \
|
void AddRef() const override { \
|
||||||
bool Release() const override { \
|
ref_count_.AddRef(); \
|
||||||
if (ref_count_.Release()) { \
|
} \
|
||||||
Destructor::Destruct(this); \
|
bool Release() const override { \
|
||||||
return true; \
|
if (ref_count_.Release()) { \
|
||||||
} \
|
Destructor::Destruct(this); \
|
||||||
return false; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
bool HasOneRef() const override { return ref_count_.HasOneRef(); } \
|
return false; \
|
||||||
bool HasAtLeastOneRef() const override { \
|
} \
|
||||||
return ref_count_.HasAtLeastOneRef(); \
|
bool HasOneRef() const override { \
|
||||||
} \
|
return ref_count_.HasOneRef(); \
|
||||||
\
|
} \
|
||||||
private: \
|
bool HasAtLeastOneRef() const override { \
|
||||||
|
return ref_count_.HasAtLeastOneRef(); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
private: \
|
||||||
CefRefCount ref_count_
|
CefRefCount ref_count_
|
||||||
|
|
||||||
#define IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(ClassName) \
|
#define IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(ClassName) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user