Apply clang-format to all C, C++ and ObjC files (issue #2171)

This commit is contained in:
Marshall Greenblatt
2017-05-17 11:29:28 +02:00
parent a566549e04
commit 31d9407ee2
1331 changed files with 33014 additions and 32258 deletions

View File

@ -56,14 +56,14 @@
// Annotations are not currently supported.
#define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */
#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */
#define ANNOTATE_HAPPENS_AFTER(obj) /* empty */
namespace base {
typedef subtle::Atomic32 AtomicRefCount;
// Increment a reference count by "increment", which must exceed 0.
inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr,
inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr,
AtomicRefCount increment) {
subtle::NoBarrier_AtomicIncrement(ptr, increment);
}
@ -72,7 +72,7 @@ inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr,
// and return whether the result is non-zero.
// Insert barriers to ensure that state written before the reference count
// became zero will be visible to a thread that has just made the count zero.
inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr,
inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr,
AtomicRefCount decrement) {
ANNOTATE_HAPPENS_BEFORE(ptr);
bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0);
@ -83,14 +83,14 @@ inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr,
}
// Increment a reference count by 1.
inline void AtomicRefCountInc(volatile AtomicRefCount *ptr) {
inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) {
base::AtomicRefCountIncN(ptr, 1);
}
// Decrement a reference count by 1 and return whether the result is non-zero.
// Insert barriers to ensure that state written before the reference count
// became zero will be visible to a thread that has just made the count zero.
inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) {
inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) {
return base::AtomicRefCountDecN(ptr, 1);
}
@ -100,7 +100,7 @@ inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) {
// the test for a reference count of one, and performs the memory barrier
// needed for the owning thread to act on the object, knowing that it has
// exclusive access to the object.
inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) {
inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) {
bool res = (subtle::Acquire_Load(ptr) == 1);
if (res) {
ANNOTATE_HAPPENS_AFTER(ptr);
@ -111,7 +111,7 @@ inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) {
// Return whether the reference count is zero. With conventional object
// referencing counting, the object will be destroyed, so the reference count
// should never be zero. Hence this is generally used for a debug check.
inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) {
inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) {
bool res = (subtle::Acquire_Load(ptr) == 0);
if (res) {
ANNOTATE_HAPPENS_AFTER(ptr);

View File

@ -122,8 +122,7 @@ Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value);
// *ptr with the increment applied. This routine implies no memory barriers.
Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);
Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment);
Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);
// These following lower-level operations are typically useful only to people
// implementing higher-level synchronization operations like spinlocks,

View File

@ -32,8 +32,8 @@
#define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_
#pragma once
#include <limits.h> // For UINT_MAX
#include <stddef.h> // For size_t
#include <limits.h> // For UINT_MAX
#include <stddef.h> // For size_t
#include "include/base/cef_build.h"
@ -43,34 +43,34 @@
// On Mac OS X, |long long| is used for 64-bit types for compatibility with
// <inttypes.h> format macros even in the LP64 model.
#if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD)
typedef long int64; // NOLINT(runtime/int)
typedef unsigned long uint64; // NOLINT(runtime/int)
typedef long int64;
typedef unsigned long uint64;
#else
typedef long long int64; // NOLINT(runtime/int)
typedef unsigned long long uint64; // NOLINT(runtime/int)
typedef long long int64;
typedef unsigned long long uint64;
#endif
// TODO: Remove these type guards. These are to avoid conflicts with
// obsolete/protypes.h in the Gecko SDK.
#ifndef _INT32
#define _INT32
typedef int int32;
typedef int int32;
#endif
// TODO: Remove these type guards. These are to avoid conflicts with
// obsolete/protypes.h in the Gecko SDK.
#ifndef _UINT32
#define _UINT32
typedef unsigned int uint32;
typedef unsigned int uint32;
#endif
// UTF-16 character type.
// This should be kept synchronized with base/strings/string16.h
#ifndef char16
#if defined(WCHAR_T_IS_UTF16)
typedef wchar_t char16;
typedef wchar_t char16;
#elif defined(WCHAR_T_IS_UTF32)
typedef unsigned short char16;
typedef unsigned short char16;
#endif
#endif

View File

@ -89,34 +89,32 @@
namespace base {
template <typename Functor>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void()>
::UnboundRunType>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void()>::UnboundRunType>
Bind(Functor functor) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
typedef cef_internal::BindState<RunnableType, RunType, void()> BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor)));
}
template <typename Functor, typename P1>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)>
::UnboundRunType>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)>::
UnboundRunType>
Bind(Functor functor, const P1& p1) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -131,39 +129,39 @@ Bind(Functor functor, const P1& p1) {
// invoked function will receive a reference to the stored copy of the
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ),
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
typedef cef_internal::BindState<RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)> BindState;
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1));
}
template <typename Functor, typename P1, typename P2>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType)>
::UnboundRunType>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType)>::
UnboundRunType>
Bind(Functor functor, const P1& p1, const P2& p2) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -179,43 +177,43 @@ Bind(Functor functor, const P1& p1, const P2& p2) {
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ),
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P2>::value,
p2_is_refcounted_type_and_needs_scoped_refptr);
typedef cef_internal::BindState<RunnableType, RunType,
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType)> BindState;
typename cef_internal::CallbackParamTraits<P2>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1, p2));
}
template <typename Functor, typename P1, typename P2, typename P3>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType)>
::UnboundRunType>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType)>::
UnboundRunType>
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -231,18 +229,17 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) {
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ),
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
@ -250,29 +247,30 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3) {
p2_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P3>::value,
p3_is_refcounted_type_and_needs_scoped_refptr);
typedef cef_internal::BindState<RunnableType, RunType,
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType)> BindState;
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3));
}
template <typename Functor, typename P1, typename P2, typename P3, typename P4>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType)>
::UnboundRunType>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType)>::
UnboundRunType>
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -288,19 +286,18 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ),
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
@ -310,33 +307,42 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4) {
p3_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P4>::value,
p4_is_refcounted_type_and_needs_scoped_refptr);
typedef cef_internal::BindState<RunnableType, RunType,
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType)> BindState;
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4));
}
template <typename Functor, typename P1, typename P2, typename P3, typename P4,
typename P5>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType)>
::UnboundRunType>
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
const P5& p5) {
template <typename Functor,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType)>::
UnboundRunType>
Bind(Functor functor,
const P1& p1,
const P2& p2,
const P3& p3,
const P4& p4,
const P5& p5) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -352,20 +358,19 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ),
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
@ -377,35 +382,46 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
p4_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P5>::value,
p5_is_refcounted_type_and_needs_scoped_refptr);
typedef cef_internal::BindState<RunnableType, RunType,
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType)> BindState;
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5));
}
template <typename Functor, typename P1, typename P2, typename P3, typename P4,
typename P5, typename P6>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType)>
::UnboundRunType>
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
const P5& p5, const P6& p6) {
template <typename Functor,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType)>::
UnboundRunType>
Bind(Functor functor,
const P1& p1,
const P2& p2,
const P3& p3,
const P4& p4,
const P5& p5,
const P6& p6) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -421,21 +437,20 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ),
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
@ -449,37 +464,50 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
p5_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P6>::value,
p6_is_refcounted_type_and_needs_scoped_refptr);
typedef cef_internal::BindState<RunnableType, RunType,
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType)> BindState;
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6));
return Callback<typename BindState::UnboundRunType>(new BindState(
cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6));
}
template <typename Functor, typename P1, typename P2, typename P3, typename P4,
typename P5, typename P6, typename P7>
base::Callback<
typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType,
typename cef_internal::CallbackParamTraits<P7>::StorageType)>
::UnboundRunType>
Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
const P5& p5, const P6& p6, const P7& p7) {
template <typename Functor,
typename P1,
typename P2,
typename P3,
typename P4,
typename P5,
typename P6,
typename P7>
base::Callback<typename cef_internal::BindState<
typename cef_internal::FunctorTraits<Functor>::RunnableType,
typename cef_internal::FunctorTraits<Functor>::RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType,
typename cef_internal::CallbackParamTraits<P7>::StorageType)>::
UnboundRunType>
Bind(Functor functor,
const P1& p1,
const P2& p2,
const P3& p3,
const P4& p4,
const P5& p5,
const P6& p6,
const P7& p7) {
// Typedefs for how to store and run the functor.
typedef typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef
typename cef_internal::FunctorTraits<Functor>::RunnableType RunnableType;
typedef typename cef_internal::FunctorTraits<Functor>::RunType RunType;
// Use RunnableType::RunType instead of RunType above because our
@ -495,22 +523,21 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
// argument and not the original.
COMPILE_ASSERT(
!(is_non_const_reference<typename BoundFunctorTraits::A1Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A7Type>::value ),
is_non_const_reference<typename BoundFunctorTraits::A2Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A3Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A4Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A5Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A6Type>::value ||
is_non_const_reference<typename BoundFunctorTraits::A7Type>::value),
do_not_bind_functions_with_nonconst_ref);
// For methods, we need to be careful for parameter 1. We do not require
// a scoped_refptr because BindState<> itself takes care of AddRef() for
// methods. We also disallow binding of an array as the method's target
// object.
COMPILE_ASSERT(
cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(cef_internal::HasIsMethodTag<RunnableType>::value ||
!cef_internal::NeedsScopedRefptrButGetsRawPtr<P1>::value,
p1_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::HasIsMethodTag<RunnableType>::value ||
!is_array<P1>::value,
first_bound_argument_to_method_cannot_be_array);
@ -526,19 +553,19 @@ Bind(Functor functor, const P1& p1, const P2& p2, const P3& p3, const P4& p4,
p6_is_refcounted_type_and_needs_scoped_refptr);
COMPILE_ASSERT(!cef_internal::NeedsScopedRefptrButGetsRawPtr<P7>::value,
p7_is_refcounted_type_and_needs_scoped_refptr);
typedef cef_internal::BindState<RunnableType, RunType,
typedef cef_internal::BindState<
RunnableType, RunType,
void(typename cef_internal::CallbackParamTraits<P1>::StorageType,
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType,
typename cef_internal::CallbackParamTraits<P7>::StorageType)> BindState;
typename cef_internal::CallbackParamTraits<P2>::StorageType,
typename cef_internal::CallbackParamTraits<P3>::StorageType,
typename cef_internal::CallbackParamTraits<P4>::StorageType,
typename cef_internal::CallbackParamTraits<P5>::StorageType,
typename cef_internal::CallbackParamTraits<P6>::StorageType,
typename cef_internal::CallbackParamTraits<P7>::StorageType)>
BindState;
return Callback<typename BindState::UnboundRunType>(
new BindState(cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6,
p7));
return Callback<typename BindState::UnboundRunType>(new BindState(
cef_internal::MakeRunnable(functor), p1, p2, p3, p4, p5, p6, p7));
}
} // namespace base

View File

@ -274,20 +274,20 @@ class SupportsAddRefAndRelease {
// instantiate Base is made. We disable the warning for this definition.
#if defined(OS_WIN)
#pragma warning(push)
#pragma warning(disable:4624)
#pragma warning(disable : 4624)
#endif
struct Base : public T, public BaseMixin {
};
struct Base : public T, public BaseMixin {};
#if defined(OS_WIN)
#pragma warning(pop)
#endif
template <void(BaseMixin::*)(void)> struct Helper {};
template <void (BaseMixin::*)(void)>
struct Helper {};
template <typename C>
static No& Check(Helper<&C::AddRef>*);
template <typename >
template <typename>
static Yes& Check(...);
public:
@ -297,22 +297,18 @@ class SupportsAddRefAndRelease {
// Helpers to assert that arguments of a recounted type are bound with a
// scoped_refptr.
template <bool IsClasstype, typename T>
struct UnsafeBindtoRefCountedArgHelper : false_type {
};
struct UnsafeBindtoRefCountedArgHelper : false_type {};
template <typename T>
struct UnsafeBindtoRefCountedArgHelper<true, T>
: integral_constant<bool, SupportsAddRefAndRelease<T>::value> {
};
: integral_constant<bool, SupportsAddRefAndRelease<T>::value> {};
template <typename T>
struct UnsafeBindtoRefCountedArg : false_type {
};
struct UnsafeBindtoRefCountedArg : false_type {};
template <typename T>
struct UnsafeBindtoRefCountedArg<T*>
: UnsafeBindtoRefCountedArgHelper<is_class<T>::value, T> {
};
: UnsafeBindtoRefCountedArgHelper<is_class<T>::value, T> {};
template <typename T>
class HasIsMethodTag {
@ -334,6 +330,7 @@ class UnretainedWrapper {
public:
explicit UnretainedWrapper(T* o) : ptr_(o) {}
T* get() const { return ptr_; }
private:
T* ptr_;
};
@ -343,6 +340,7 @@ class ConstRefWrapper {
public:
explicit ConstRefWrapper(const T& o) : ptr_(&o) {}
const T& get() const { return *ptr_; }
private:
const T* ptr_;
};
@ -355,7 +353,7 @@ struct IgnoreResultHelper {
};
template <typename T>
struct IgnoreResultHelper<Callback<T> > {
struct IgnoreResultHelper<Callback<T>> {
explicit IgnoreResultHelper(const Callback<T>& functor) : functor_(functor) {}
const Callback<T>& functor_;
@ -409,8 +407,7 @@ class PassedWrapper {
public:
explicit PassedWrapper(T scoper) : is_valid_(true), scoper_(scoper.Pass()) {}
PassedWrapper(const PassedWrapper& other)
: is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {
}
: is_valid_(other.is_valid_), scoper_(other.scoper_.Pass()) {}
T Pass() const {
CHECK(is_valid_);
is_valid_ = false;
@ -430,7 +427,7 @@ struct UnwrapTraits {
};
template <typename T>
struct UnwrapTraits<UnretainedWrapper<T> > {
struct UnwrapTraits<UnretainedWrapper<T>> {
typedef T* ForwardType;
static ForwardType Unwrap(UnretainedWrapper<T> unretained) {
return unretained.get();
@ -438,7 +435,7 @@ struct UnwrapTraits<UnretainedWrapper<T> > {
};
template <typename T>
struct UnwrapTraits<ConstRefWrapper<T> > {
struct UnwrapTraits<ConstRefWrapper<T>> {
typedef const T& ForwardType;
static ForwardType Unwrap(ConstRefWrapper<T> const_ref) {
return const_ref.get();
@ -446,31 +443,27 @@ struct UnwrapTraits<ConstRefWrapper<T> > {
};
template <typename T>
struct UnwrapTraits<scoped_refptr<T> > {
struct UnwrapTraits<scoped_refptr<T>> {
typedef T* ForwardType;
static ForwardType Unwrap(const scoped_refptr<T>& o) { return o.get(); }
};
template <typename T>
struct UnwrapTraits<WeakPtr<T> > {
struct UnwrapTraits<WeakPtr<T>> {
typedef const WeakPtr<T>& ForwardType;
static ForwardType Unwrap(const WeakPtr<T>& o) { return o; }
};
template <typename T>
struct UnwrapTraits<OwnedWrapper<T> > {
struct UnwrapTraits<OwnedWrapper<T>> {
typedef T* ForwardType;
static ForwardType Unwrap(const OwnedWrapper<T>& o) {
return o.get();
}
static ForwardType Unwrap(const OwnedWrapper<T>& o) { return o.get(); }
};
template <typename T>
struct UnwrapTraits<PassedWrapper<T> > {
struct UnwrapTraits<PassedWrapper<T>> {
typedef T ForwardType;
static T Unwrap(PassedWrapper<T>& o) {
return o.Pass();
}
static T Unwrap(PassedWrapper<T>& o) { return o.Pass(); }
};
// Utility for handling different refcounting semantics in the Bind()
@ -505,7 +498,7 @@ struct MaybeRefcount<true, T*> {
// No need to additionally AddRef() and Release() since we are storing a
// scoped_refptr<> inside the storage object already.
template <typename T>
struct MaybeRefcount<true, scoped_refptr<T> > {
struct MaybeRefcount<true, scoped_refptr<T>> {
static void AddRef(const scoped_refptr<T>& o) {}
static void Release(const scoped_refptr<T>& o) {}
};
@ -526,10 +519,10 @@ template <bool IsMethod, typename P1>
struct IsWeakMethod : public false_type {};
template <typename T>
struct IsWeakMethod<true, WeakPtr<T> > : public true_type {};
struct IsWeakMethod<true, WeakPtr<T>> : public true_type {};
template <typename T>
struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T> > > : public true_type {};
struct IsWeakMethod<true, ConstRefWrapper<WeakPtr<T>>> : public true_type {};
} // namespace cef_internal
@ -567,14 +560,14 @@ static inline cef_internal::IgnoreResultHelper<T> IgnoreResult(T data) {
}
template <typename T>
static inline cef_internal::IgnoreResultHelper<Callback<T> >
IgnoreResult(const Callback<T>& data) {
return cef_internal::IgnoreResultHelper<Callback<T> >(data);
static inline cef_internal::IgnoreResultHelper<Callback<T>> IgnoreResult(
const Callback<T>& data) {
return cef_internal::IgnoreResultHelper<Callback<T>>(data);
}
void DoNothing();
template<typename T>
template <typename T>
void DeletePointer(T* obj) {
delete obj;
}

View File

@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef CEF_INCLUDE_BASE_CEF_BUILD_H_
#define CEF_INCLUDE_BASE_CEF_BUILD_H_
#pragma once
@ -116,12 +115,10 @@
// Type detection for wchar_t.
#if defined(OS_WIN)
#define WCHAR_T_IS_UTF16
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fffffff || __WCHAR_MAX__ == 0xffffffff)
#define WCHAR_T_IS_UTF32
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && \
defined(__WCHAR_MAX__) && \
#elif defined(OS_POSIX) && defined(COMPILER_GCC) && defined(__WCHAR_MAX__) && \
(__WCHAR_MAX__ == 0x7fff || __WCHAR_MAX__ == 0xffff)
// On Posix, we'll detect short wchar_t, but projects aren't guaranteed to
// compile in this mode (in particular, Chrome doesn't). This is intended for
@ -181,7 +178,7 @@
// Visual Studio 2010 and later support override.
#define OVERRIDE override
#elif defined(COMPILER_GCC) && __cplusplus >= 201103 && \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700
// GCC 4.7 supports explicit virtual overrides when C++11 support is enabled.
#define OVERRIDE override
#else
@ -191,10 +188,9 @@
// Check for C++11 template alias support which was added in VS2013 and GCC4.7.
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
#if __cplusplus > 199711L || \
(defined(_MSC_VER) && _MSC_VER >= 1800) || \
(defined(__GNUC__) && \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700))
#if __cplusplus > 199711L || (defined(_MSC_VER) && _MSC_VER >= 1800) || \
(defined(__GNUC__) && \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__ >= 40700))
#define HAS_CPP11_TEMPLATE_ALIAS_SUPPORT
#endif

View File

@ -45,9 +45,9 @@
// If the Chromium implementation diverges the below implementation should be
// updated to match.
#include "include/base/internal/cef_callback_internal.h"
#include "include/base/cef_callback_forward.h"
#include "include/base/cef_template_util.h"
#include "include/base/internal/cef_callback_internal.h"
// NOTE: Header files that do not require the full definition of Callback or
// Closure should #include "base/cef_callback_forward.h" instead of this file.
@ -407,21 +407,20 @@ class Callback<R(void)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)();
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -437,9 +436,7 @@ class Callback<R(void)> : public cef_internal::CallbackBase {
}
private:
typedef R(*PolymorphicInvoke)(
cef_internal::BindStateBase*);
typedef R (*PolymorphicInvoke)(cef_internal::BindStateBase*);
};
template <typename R, typename A1>
@ -447,21 +444,20 @@ class Callback<R(A1)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -477,10 +473,9 @@ class Callback<R(A1)> : public cef_internal::CallbackBase {
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType);
};
template <typename R, typename A1, typename A2>
@ -488,21 +483,20 @@ class Callback<R(A1, A2)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1, A2);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -520,11 +514,10 @@ class Callback<R(A1, A2)> : public cef_internal::CallbackBase {
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType);
};
template <typename R, typename A1, typename A2, typename A3>
@ -532,21 +525,20 @@ class Callback<R(A1, A2, A3)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1, A2, A3);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -566,12 +558,11 @@ class Callback<R(A1, A2, A3)> : public cef_internal::CallbackBase {
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType);
};
template <typename R, typename A1, typename A2, typename A3, typename A4>
@ -579,21 +570,20 @@ class Callback<R(A1, A2, A3, A4)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1, A2, A3, A4);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -615,36 +605,38 @@ class Callback<R(A1, A2, A3, A4)> : public cef_internal::CallbackBase {
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType);
};
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5>
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
class Callback<R(A1, A2, A3, A4, A5)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1, A2, A3, A4, A5);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -660,45 +652,47 @@ class Callback<R(A1, A2, A3, A4, A5)> : public cef_internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
cef_internal::CallbackForward(a2),
cef_internal::CallbackForward(a3),
cef_internal::CallbackForward(a4),
cef_internal::CallbackForward(a5));
return f(
bind_state_.get(), cef_internal::CallbackForward(a1),
cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3),
cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5));
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
typename cef_internal::CallbackParamTraits<A5>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
typename cef_internal::CallbackParamTraits<A5>::ForwardType);
};
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
class Callback<R(A1, A2, A3, A4, A5, A6)> : public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -715,47 +709,51 @@ class Callback<R(A1, A2, A3, A4, A5, A6)> : public cef_internal::CallbackBase {
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
cef_internal::CallbackForward(a2),
cef_internal::CallbackForward(a3),
cef_internal::CallbackForward(a4),
cef_internal::CallbackForward(a5),
cef_internal::CallbackForward(a6));
return f(
bind_state_.get(), cef_internal::CallbackForward(a1),
cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3),
cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5),
cef_internal::CallbackForward(a6));
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
typename cef_internal::CallbackParamTraits<A6>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
typename cef_internal::CallbackParamTraits<A6>::ForwardType);
};
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public cef_internal::CallbackBase {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
class Callback<R(A1, A2, A3, A4, A5, A6, A7)>
: public cef_internal::CallbackBase {
public:
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
Callback() : CallbackBase(NULL) { }
Callback() : CallbackBase(NULL) {}
// Note that this constructor CANNOT be explicit, and that Bind() CANNOT
// return the exact Callback<> type. See base/bind.h for details.
template <typename Runnable, typename BindRunType, typename BoundArgsType>
Callback(cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>* bind_state)
Callback(
cef_internal::BindState<Runnable, BindRunType, BoundArgsType>* bind_state)
: CallbackBase(bind_state) {
// Force the assignment to a local variable of PolymorphicInvoke
// so the compiler will typecheck that the passed in Run() method has
// the correct type.
PolymorphicInvoke invoke_func =
&cef_internal::BindState<Runnable, BindRunType, BoundArgsType>
::InvokerType::Run;
&cef_internal::BindState<Runnable, BindRunType,
BoundArgsType>::InvokerType::Run;
polymorphic_invoke_ = reinterpret_cast<InvokeFuncStorage>(invoke_func);
}
@ -773,29 +771,25 @@ class Callback<R(A1, A2, A3, A4, A5, A6, A7)> : public cef_internal::CallbackBas
PolymorphicInvoke f =
reinterpret_cast<PolymorphicInvoke>(polymorphic_invoke_);
return f(bind_state_.get(), cef_internal::CallbackForward(a1),
cef_internal::CallbackForward(a2),
cef_internal::CallbackForward(a3),
cef_internal::CallbackForward(a4),
cef_internal::CallbackForward(a5),
cef_internal::CallbackForward(a6),
cef_internal::CallbackForward(a7));
return f(
bind_state_.get(), cef_internal::CallbackForward(a1),
cef_internal::CallbackForward(a2), cef_internal::CallbackForward(a3),
cef_internal::CallbackForward(a4), cef_internal::CallbackForward(a5),
cef_internal::CallbackForward(a6), cef_internal::CallbackForward(a7));
}
private:
typedef R(*PolymorphicInvoke)(
typedef R (*PolymorphicInvoke)(
cef_internal::BindStateBase*,
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
typename cef_internal::CallbackParamTraits<A6>::ForwardType,
typename cef_internal::CallbackParamTraits<A7>::ForwardType);
typename cef_internal::CallbackParamTraits<A1>::ForwardType,
typename cef_internal::CallbackParamTraits<A2>::ForwardType,
typename cef_internal::CallbackParamTraits<A3>::ForwardType,
typename cef_internal::CallbackParamTraits<A4>::ForwardType,
typename cef_internal::CallbackParamTraits<A5>::ForwardType,
typename cef_internal::CallbackParamTraits<A6>::ForwardType,
typename cef_internal::CallbackParamTraits<A7>::ForwardType);
};
// Syntactic sugar to make Callbacks<void(void)> easier to declare since it
// will be used in a lot of APIs with delayed execution.
typedef Callback<void(void)> Closure;

View File

@ -48,12 +48,12 @@
#include <list>
#include "include/base/cef_basictypes.h"
#include "include/base/cef_callback.h"
#include "include/base/internal/cef_callback_internal.h"
#include "include/base/cef_build.h"
#include "include/base/cef_callback.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_scoped_ptr.h"
#include "include/base/internal/cef_callback_internal.h"
// OVERVIEW:
//
@ -120,9 +120,7 @@ class CallbackListBase {
public:
Subscription(CallbackListBase<CallbackType>* list,
typename std::list<CallbackType>::iterator iter)
: list_(list),
iter_(iter) {
}
: list_(list), iter_(iter) {}
~Subscription() {
if (list_->active_iterator_count_) {
@ -167,14 +165,12 @@ class CallbackListBase {
class Iterator {
public:
explicit Iterator(CallbackListBase<CallbackType>* list)
: list_(list),
list_iter_(list_->callbacks_.begin()) {
: list_(list), list_iter_(list_->callbacks_.begin()) {
++list_->active_iterator_count_;
}
Iterator(const Iterator& iter)
: list_(iter.list_),
list_iter_(iter.list_iter_) {
: list_(iter.list_), list_iter_(iter.list_iter_) {
++list_->active_iterator_count_;
}
@ -210,9 +206,7 @@ class CallbackListBase {
// Returns an instance of a CallbackListBase::Iterator which can be used
// to run callbacks.
Iterator GetIterator() {
return Iterator(this);
}
Iterator GetIterator() { return Iterator(this); }
// Compact the list: remove any entries which were NULLed out during
// iteration.
@ -242,11 +236,12 @@ class CallbackListBase {
} // namespace cef_internal
template <typename Sig> class CallbackList;
template <typename Sig>
class CallbackList;
template <>
class CallbackList<void(void)>
: public cef_internal::CallbackListBase<Callback<void(void)> > {
: public cef_internal::CallbackListBase<Callback<void(void)>> {
public:
typedef Callback<void(void)> CallbackType;
@ -267,7 +262,7 @@ class CallbackList<void(void)>
template <typename A1>
class CallbackList<void(A1)>
: public cef_internal::CallbackListBase<Callback<void(A1)> > {
: public cef_internal::CallbackListBase<Callback<void(A1)>> {
public:
typedef Callback<void(A1)> CallbackType;
@ -288,7 +283,7 @@ class CallbackList<void(A1)>
template <typename A1, typename A2>
class CallbackList<void(A1, A2)>
: public cef_internal::CallbackListBase<Callback<void(A1, A2)> > {
: public cef_internal::CallbackListBase<Callback<void(A1, A2)>> {
public:
typedef Callback<void(A1, A2)> CallbackType;
@ -310,7 +305,7 @@ class CallbackList<void(A1, A2)>
template <typename A1, typename A2, typename A3>
class CallbackList<void(A1, A2, A3)>
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3)> > {
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3)>> {
public:
typedef Callback<void(A1, A2, A3)> CallbackType;
@ -333,7 +328,7 @@ class CallbackList<void(A1, A2, A3)>
template <typename A1, typename A2, typename A3, typename A4>
class CallbackList<void(A1, A2, A3, A4)>
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4)> > {
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4)>> {
public:
typedef Callback<void(A1, A2, A3, A4)> CallbackType;
@ -357,7 +352,8 @@ class CallbackList<void(A1, A2, A3, A4)>
template <typename A1, typename A2, typename A3, typename A4, typename A5>
class CallbackList<void(A1, A2, A3, A4, A5)>
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5)> > {
: public cef_internal::CallbackListBase<
Callback<void(A1, A2, A3, A4, A5)>> {
public:
typedef Callback<void(A1, A2, A3, A4, A5)> CallbackType;
@ -380,11 +376,15 @@ class CallbackList<void(A1, A2, A3, A4, A5)>
DISALLOW_COPY_AND_ASSIGN(CallbackList);
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6>
template <typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
class CallbackList<void(A1, A2, A3, A4, A5, A6)>
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5,
A6)> > {
: public cef_internal::CallbackListBase<
Callback<void(A1, A2, A3, A4, A5, A6)>> {
public:
typedef Callback<void(A1, A2, A3, A4, A5, A6)> CallbackType;
@ -408,11 +408,16 @@ class CallbackList<void(A1, A2, A3, A4, A5, A6)>
DISALLOW_COPY_AND_ASSIGN(CallbackList);
};
template <typename A1, typename A2, typename A3, typename A4, typename A5,
typename A6, typename A7>
template <typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
class CallbackList<void(A1, A2, A3, A4, A5, A6, A7)>
: public cef_internal::CallbackListBase<Callback<void(A1, A2, A3, A4, A5, A6,
A7)> > {
: public cef_internal::CallbackListBase<
Callback<void(A1, A2, A3, A4, A5, A6, A7)>> {
public:
typedef Callback<void(A1, A2, A3, A4, A5, A6, A7)> CallbackType;

View File

@ -83,8 +83,8 @@
// updated to match.
#include "include/base/cef_bind.h"
#include "include/base/cef_callback.h"
#include "include/base/cef_build.h"
#include "include/base/cef_callback.h"
#include "include/base/cef_logging.h"
#include "include/base/cef_macros.h"
#include "include/base/cef_weak_ptr.h"
@ -102,8 +102,7 @@ class CancelableCallback<void(void)> {
// |callback| must not be null.
explicit CancelableCallback(const base::Callback<void(void)>& callback)
: weak_factory_(this),
callback_(callback) {
: weak_factory_(this), callback_(callback) {
DCHECK(!callback.is_null());
InitializeForwarder();
}
@ -118,9 +117,7 @@ class CancelableCallback<void(void)> {
}
// Returns true if the wrapped callback has been cancelled.
bool IsCancelled() const {
return callback_.is_null();
}
bool IsCancelled() const { return callback_.is_null(); }
// Sets |callback| as the closure that may be cancelled. |callback| may not
// be null. Outstanding and any previously wrapped callbacks are cancelled.
@ -137,14 +134,10 @@ class CancelableCallback<void(void)> {
}
// Returns a callback that can be disabled by calling Cancel().
const base::Callback<void(void)>& callback() const {
return forwarder_;
}
const base::Callback<void(void)>& callback() const { return forwarder_; }
private:
void Forward() {
callback_.Run();
}
void Forward() { callback_.Run(); }
// Helper method to bind |forwarder_| using a weak pointer from
// |weak_factory_|.
@ -154,7 +147,7 @@ class CancelableCallback<void(void)> {
}
// Used to ensure Forward() is not run when this object is destroyed.
base::WeakPtrFactory<CancelableCallback<void(void)> > weak_factory_;
base::WeakPtrFactory<CancelableCallback<void(void)>> weak_factory_;
// The wrapper closure.
base::Callback<void(void)> forwarder_;
@ -172,8 +165,7 @@ class CancelableCallback<void(A1)> {
// |callback| must not be null.
explicit CancelableCallback(const base::Callback<void(A1)>& callback)
: weak_factory_(this),
callback_(callback) {
: weak_factory_(this), callback_(callback) {
DCHECK(!callback.is_null());
InitializeForwarder();
}
@ -188,9 +180,7 @@ class CancelableCallback<void(A1)> {
}
// Returns true if the wrapped callback has been cancelled.
bool IsCancelled() const {
return callback_.is_null();
}
bool IsCancelled() const { return callback_.is_null(); }
// Sets |callback| as the closure that may be cancelled. |callback| may not
// be null. Outstanding and any previously wrapped callbacks are cancelled.
@ -207,14 +197,10 @@ class CancelableCallback<void(A1)> {
}
// Returns a callback that can be disabled by calling Cancel().
const base::Callback<void(A1)>& callback() const {
return forwarder_;
}
const base::Callback<void(A1)>& callback() const { return forwarder_; }
private:
void Forward(A1 a1) const {
callback_.Run(a1);
}
void Forward(A1 a1) const { callback_.Run(a1); }
// Helper method to bind |forwarder_| using a weak pointer from
// |weak_factory_|.
@ -224,7 +210,7 @@ class CancelableCallback<void(A1)> {
}
// Used to ensure Forward() is not run when this object is destroyed.
base::WeakPtrFactory<CancelableCallback<void(A1)> > weak_factory_;
base::WeakPtrFactory<CancelableCallback<void(A1)>> weak_factory_;
// The wrapper closure.
base::Callback<void(A1)> forwarder_;
@ -242,8 +228,7 @@ class CancelableCallback<void(A1, A2)> {
// |callback| must not be null.
explicit CancelableCallback(const base::Callback<void(A1, A2)>& callback)
: weak_factory_(this),
callback_(callback) {
: weak_factory_(this), callback_(callback) {
DCHECK(!callback.is_null());
InitializeForwarder();
}
@ -258,9 +243,7 @@ class CancelableCallback<void(A1, A2)> {
}
// Returns true if the wrapped callback has been cancelled.
bool IsCancelled() const {
return callback_.is_null();
}
bool IsCancelled() const { return callback_.is_null(); }
// Sets |callback| as the closure that may be cancelled. |callback| may not
// be null. Outstanding and any previously wrapped callbacks are cancelled.
@ -277,14 +260,10 @@ class CancelableCallback<void(A1, A2)> {
}
// Returns a callback that can be disabled by calling Cancel().
const base::Callback<void(A1, A2)>& callback() const {
return forwarder_;
}
const base::Callback<void(A1, A2)>& callback() const { return forwarder_; }
private:
void Forward(A1 a1, A2 a2) const {
callback_.Run(a1, a2);
}
void Forward(A1 a1, A2 a2) const { callback_.Run(a1, a2); }
// Helper method to bind |forwarder_| using a weak pointer from
// |weak_factory_|.
@ -294,7 +273,7 @@ class CancelableCallback<void(A1, A2)> {
}
// Used to ensure Forward() is not run when this object is destroyed.
base::WeakPtrFactory<CancelableCallback<void(A1, A2)> > weak_factory_;
base::WeakPtrFactory<CancelableCallback<void(A1, A2)>> weak_factory_;
// The wrapper closure.
base::Callback<void(A1, A2)> forwarder_;

View File

@ -125,9 +125,7 @@ class AutoLock {
public:
struct AlreadyAcquired {};
explicit AutoLock(Lock& lock) : lock_(lock) {
lock_.Acquire();
}
explicit AutoLock(Lock& lock) : lock_(lock) { lock_.Acquire(); }
AutoLock(Lock& lock, const AlreadyAcquired&) : lock_(lock) {
lock_.AssertAcquired();
@ -153,9 +151,7 @@ class AutoUnlock {
lock_.Release();
}
~AutoUnlock() {
lock_.Acquire();
}
~AutoUnlock() { lock_.Acquire(); }
private:
Lock& lock_;

View File

@ -158,9 +158,9 @@
// updated to match.
#include <cassert>
#include <string>
#include <cstring>
#include <sstream>
#include <string>
#include "include/base/cef_build.h"
#include "include/base/cef_macros.h"
@ -201,32 +201,27 @@ 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, ...) \
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_INFO , \
##__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, ...) \
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_ERROR , \
##__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, ...) \
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL , \
##__VA_ARGS__)
#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, ...) \
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_WARNING, \
##__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, ...) \
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_FATAL, \
##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_EX_DFATAL(ClassName, ...) \
cef::logging::ClassName(__FILE__, __LINE__, cef::logging::LOG_DFATAL, \
##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_INFO \
COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
#define COMPACT_GOOGLE_LOG_WARNING \
COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
#define COMPACT_GOOGLE_LOG_ERROR \
COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage)
#define COMPACT_GOOGLE_LOG_FATAL \
COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage)
#define COMPACT_GOOGLE_LOG_DFATAL \
COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage)
#define COMPACT_GOOGLE_LOG_INFO COMPACT_GOOGLE_LOG_EX_INFO(LogMessage)
#define COMPACT_GOOGLE_LOG_WARNING COMPACT_GOOGLE_LOG_EX_WARNING(LogMessage)
#define COMPACT_GOOGLE_LOG_ERROR COMPACT_GOOGLE_LOG_EX_ERROR(LogMessage)
#define COMPACT_GOOGLE_LOG_FATAL COMPACT_GOOGLE_LOG_EX_FATAL(LogMessage)
#define COMPACT_GOOGLE_LOG_DFATAL COMPACT_GOOGLE_LOG_EX_DFATAL(LogMessage)
#if defined(OS_WIN)
// wingdi.h defines ERROR to be 0. When we call LOG(ERROR), it gets
@ -236,7 +231,7 @@ const LogSeverity LOG_DFATAL = LOG_FATAL;
// the Windows SDK does for consistency.
#define ERROR 0
#define COMPACT_GOOGLE_LOG_EX_0(ClassName, ...) \
COMPACT_GOOGLE_LOG_EX_ERROR(ClassName , ##__VA_ARGS__)
COMPACT_GOOGLE_LOG_EX_ERROR(ClassName, ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_0 COMPACT_GOOGLE_LOG_ERROR
// Needed for LOG_IS_ON(ERROR).
const LogSeverity LOG_0 = LOG_ERROR;
@ -246,7 +241,7 @@ const LogSeverity LOG_0 = LOG_ERROR;
// LOG_IS_ON(DFATAL) always holds in debug mode. In particular, CHECK()s will
// always fire if they fail.
#define LOG_IS_ON(severity) \
((::cef::logging::LOG_ ## severity) >= ::cef::logging::GetMinLogLevel())
((::cef::logging::LOG_##severity) >= ::cef::logging::GetMinLogLevel())
// We can't do any caching tricks with VLOG_IS_ON() like the
// google-glog version since it requires GCC extensions. This means
@ -257,8 +252,8 @@ const LogSeverity LOG_0 = LOG_ERROR;
// Helper macro which avoids evaluating the arguments to a stream if
// the condition doesn't hold.
#define LAZY_STREAM(stream, condition) \
!(condition) ? (void) 0 : ::cef::logging::LogMessageVoidify() & (stream)
#define LAZY_STREAM(stream, condition) \
!(condition) ? (void)0 : ::cef::logging::LogMessageVoidify() & (stream)
// We use the preprocessor's merging operator, "##", so that, e.g.,
// LOG(INFO) becomes the token COMPACT_GOOGLE_LOG_INFO. There's some funny
@ -268,7 +263,7 @@ const LogSeverity LOG_0 = LOG_ERROR;
// impossible to stream something like a string directly to an unnamed
// ostream. We employ a neat hack by calling the stream() member
// function of LogMessage which seems to avoid the problem.
#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_ ## severity.stream()
#define LOG_STREAM(severity) COMPACT_GOOGLE_LOG_##severity.stream()
#define LOG(severity) LAZY_STREAM(LOG_STREAM(severity), LOG_IS_ON(severity))
#define LOG_IF(severity, condition) \
@ -286,16 +281,18 @@ const LogSeverity LOG_0 = LOG_ERROR;
#define VLOG_IF(verbose_level, condition) \
LAZY_STREAM(VLOG_STREAM(verbose_level), \
VLOG_IS_ON(verbose_level) && (condition))
VLOG_IS_ON(verbose_level) && (condition))
#if defined (OS_WIN)
#define VPLOG_STREAM(verbose_level) \
cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
::cef::logging::GetLastSystemErrorCode()).stream()
#if defined(OS_WIN)
#define VPLOG_STREAM(verbose_level) \
cef::logging::Win32ErrorLogMessage(__FILE__, __LINE__, -verbose_level, \
::cef::logging::GetLastSystemErrorCode()) \
.stream()
#elif defined(OS_POSIX)
#define VPLOG_STREAM(verbose_level) \
cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
::cef::logging::GetLastSystemErrorCode()).stream()
#define VPLOG_STREAM(verbose_level) \
cef::logging::ErrnoLogMessage(__FILE__, __LINE__, -verbose_level, \
::cef::logging::GetLastSystemErrorCode()) \
.stream()
#endif
#define VPLOG(verbose_level) \
@ -303,34 +300,35 @@ const LogSeverity LOG_0 = LOG_ERROR;
#define VPLOG_IF(verbose_level, condition) \
LAZY_STREAM(VPLOG_STREAM(verbose_level), \
VLOG_IS_ON(verbose_level) && (condition))
VLOG_IS_ON(verbose_level) && (condition))
// TODO(akalin): Add more VLOG variants, e.g. VPLOG.
#define LOG_ASSERT(condition) \
#define LOG_ASSERT(condition) \
LOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
#define SYSLOG_ASSERT(condition) \
SYSLOG_IF(FATAL, !(condition)) << "Assert failed: " #condition ". "
#if defined(OS_WIN)
#define PLOG_STREAM(severity) \
COMPACT_GOOGLE_LOG_EX_ ## severity(Win32ErrorLogMessage, \
::cef::logging::GetLastSystemErrorCode()).stream()
#define PLOG_STREAM(severity) \
COMPACT_GOOGLE_LOG_EX_##severity(Win32ErrorLogMessage, \
::cef::logging::GetLastSystemErrorCode()) \
.stream()
#elif defined(OS_POSIX)
#define PLOG_STREAM(severity) \
COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \
::cef::logging::GetLastSystemErrorCode()).stream()
#define PLOG_STREAM(severity) \
COMPACT_GOOGLE_LOG_EX_##severity(ErrnoLogMessage, \
::cef::logging::GetLastSystemErrorCode()) \
.stream()
#endif
#define PLOG(severity) \
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
#define PLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
#define PLOG_IF(severity, condition) \
LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
// The actual stream used isn't important.
#define EAT_STREAM_PARAMETERS \
true ? (void) 0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
#define EAT_STREAM_PARAMETERS \
true ? (void)0 : ::cef::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
// CHECK dies with a fatal error if condition is not true. It is *not*
// controlled by NDEBUG, so the check will be executed regardless of
@ -341,28 +339,27 @@ const LogSeverity LOG_0 = LOG_ERROR;
#define CHECK(condition) \
LAZY_STREAM(LOG_STREAM(FATAL), !(condition)) \
<< "Check failed: " #condition ". "
<< "Check failed: " #condition ". "
#define PCHECK(condition) \
#define PCHECK(condition) \
LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \
<< "Check failed: " #condition ". "
<< "Check failed: " #condition ". "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use CHECK_EQ et al below.
//
// TODO(akalin): Rewrite this so that constructs like if (...)
// CHECK_EQ(...) else { ... } work properly.
#define CHECK_OP(name, op, val1, val2) \
if (std::string* _result = \
cef::logging::Check##name##Impl((val1), (val2), \
#val1 " " #op " " #val2)) \
cef::logging::LogMessage(__FILE__, __LINE__, _result).stream()
#define CHECK_OP(name, op, val1, val2) \
if (std::string* _result = cef::logging::Check##name##Impl( \
(val1), (val2), #val1 " " #op " " #val2)) \
cef::logging::LogMessage(__FILE__, __LINE__, _result).stream()
// Build the error message string. This is separate from the "Impl"
// function template because it is not performance critical and so can
// be out of line, while the "Impl" code should be inline. Caller
// takes ownership of the returned string.
template<class t1, class t2>
template <class t1, class t2>
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
std::ostringstream ss;
ss << names << " (" << v1 << " vs. " << v2 << ")";
@ -374,51 +371,60 @@ std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
#if !defined(COMPILER_MSVC)
// Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated
// in logging.cc.
extern template std::string* MakeCheckOpString<int, int>(
const int&, const int&, const char* names);
extern template
std::string* MakeCheckOpString<unsigned long, unsigned long>(
const unsigned long&, const unsigned long&, const char* names);
extern template
std::string* MakeCheckOpString<unsigned long, unsigned int>(
const unsigned long&, const unsigned int&, const char* names);
extern template
std::string* MakeCheckOpString<unsigned int, unsigned long>(
const unsigned int&, const unsigned long&, const char* names);
extern template
std::string* MakeCheckOpString<std::string, std::string>(
const std::string&, const std::string&, const char* name);
extern template std::string* MakeCheckOpString<int, int>(const int&,
const int&,
const char* names);
extern template std::string* MakeCheckOpString<unsigned long, unsigned long>(
const unsigned long&,
const unsigned long&,
const char* names);
extern template std::string* MakeCheckOpString<unsigned long, unsigned int>(
const unsigned long&,
const unsigned int&,
const char* names);
extern template std::string* MakeCheckOpString<unsigned int, unsigned long>(
const unsigned int&,
const unsigned long&,
const char* names);
extern template std::string* MakeCheckOpString<std::string, std::string>(
const std::string&,
const std::string&,
const char* name);
#endif
// Helper functions for CHECK_OP macro.
// The (int, int) specialization works around the issue that the compiler
// will not instantiate the template version of the function on values of
// unnamed enum type - see comment below.
#define DEFINE_CHECK_OP_IMPL(name, op) \
template <class t1, class t2> \
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
const char* names) { \
if (v1 op v2) return NULL; \
else return MakeCheckOpString(v1, v2, names); \
} \
#define DEFINE_CHECK_OP_IMPL(name, op) \
template <class t1, class t2> \
inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
const char* names) { \
if (v1 op v2) \
return NULL; \
else \
return MakeCheckOpString(v1, v2, names); \
} \
inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
if (v1 op v2) return NULL; \
else return MakeCheckOpString(v1, v2, names); \
if (v1 op v2) \
return NULL; \
else \
return MakeCheckOpString(v1, v2, names); \
}
DEFINE_CHECK_OP_IMPL(EQ, ==)
DEFINE_CHECK_OP_IMPL(NE, !=)
DEFINE_CHECK_OP_IMPL(LE, <=)
DEFINE_CHECK_OP_IMPL(LT, < )
DEFINE_CHECK_OP_IMPL(LT, <)
DEFINE_CHECK_OP_IMPL(GE, >=)
DEFINE_CHECK_OP_IMPL(GT, > )
DEFINE_CHECK_OP_IMPL(GT, >)
#undef DEFINE_CHECK_OP_IMPL
#define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
#define CHECK_NE(val1, val2) CHECK_OP(NE, !=, val1, val2)
#define CHECK_LE(val1, val2) CHECK_OP(LE, <=, val1, val2)
#define CHECK_LT(val1, val2) CHECK_OP(LT, < , val1, val2)
#define CHECK_LT(val1, val2) CHECK_OP(LT, <, val1, val2)
#define CHECK_GE(val1, val2) CHECK_OP(GE, >=, val1, val2)
#define CHECK_GT(val1, val2) CHECK_OP(GT, > , val1, val2)
#define CHECK_GT(val1, val2) CHECK_OP(GT, >, val1, val2)
#if defined(NDEBUG)
#define ENABLE_DLOG 0
@ -471,11 +477,9 @@ enum { DEBUG_MODE = ENABLE_DLOG };
#undef ENABLE_DLOG
#define DLOG(severity) \
LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
#define DLOG(severity) LAZY_STREAM(LOG_STREAM(severity), DLOG_IS_ON(severity))
#define DPLOG(severity) \
LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
#define DPLOG(severity) LAZY_STREAM(PLOG_STREAM(severity), DLOG_IS_ON(severity))
#define DVLOG(verboselevel) DVLOG_IF(verboselevel, VLOG_IS_ON(verboselevel))
@ -486,7 +490,7 @@ enum { DEBUG_MODE = ENABLE_DLOG };
#if DCHECK_IS_ON()
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
COMPACT_GOOGLE_LOG_EX_FATAL(ClassName , ##__VA_ARGS__)
COMPACT_GOOGLE_LOG_EX_FATAL(ClassName, ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_FATAL
const LogSeverity LOG_DCHECK = LOG_FATAL;
@ -494,7 +498,7 @@ const LogSeverity LOG_DCHECK = LOG_FATAL;
// These are just dummy values.
#define COMPACT_GOOGLE_LOG_EX_DCHECK(ClassName, ...) \
COMPACT_GOOGLE_LOG_EX_INFO(ClassName , ##__VA_ARGS__)
COMPACT_GOOGLE_LOG_EX_INFO(ClassName, ##__VA_ARGS__)
#define COMPACT_GOOGLE_LOG_DCHECK COMPACT_GOOGLE_LOG_INFO
const LogSeverity LOG_DCHECK = LOG_INFO;
@ -505,22 +509,23 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
// variable warnings if the only use of a variable is in a DCHECK.
// This behavior is different from DLOG_IF et al.
#define DCHECK(condition) \
LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
#define DCHECK(condition) \
LAZY_STREAM(LOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
<< "Check failed: " #condition ". "
#define DPCHECK(condition) \
LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
#define DPCHECK(condition) \
LAZY_STREAM(PLOG_STREAM(DCHECK), DCHECK_IS_ON() && !(condition)) \
<< "Check failed: " #condition ". "
// Helper macro for binary operators.
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
#define DCHECK_OP(name, op, val1, val2) \
if (DCHECK_IS_ON()) \
if (std::string* _result = cef::logging::Check##name##Impl( \
(val1), (val2), #val1 " " #op " " #val2)) \
cef::logging::LogMessage(__FILE__, __LINE__, \
::cef::logging::LOG_DCHECK, _result).stream()
#define DCHECK_OP(name, op, val1, val2) \
if (DCHECK_IS_ON()) \
if (std::string* _result = cef::logging::Check##name##Impl( \
(val1), (val2), #val1 " " #op " " #val2)) \
cef::logging::LogMessage(__FILE__, __LINE__, ::cef::logging::LOG_DCHECK, \
_result) \
.stream()
// Equality/Inequality checks - compare two values, and log a
// LOG_DCHECK message including the two values when the result is not
@ -544,13 +549,13 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
#define DCHECK_EQ(val1, val2) DCHECK_OP(EQ, ==, val1, val2)
#define DCHECK_NE(val1, val2) DCHECK_OP(NE, !=, val1, val2)
#define DCHECK_LE(val1, val2) DCHECK_OP(LE, <=, val1, val2)
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, < , val1, val2)
#define DCHECK_LT(val1, val2) DCHECK_OP(LT, <, val1, val2)
#define DCHECK_GE(val1, val2) DCHECK_OP(GE, >=, val1, val2)
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, > , val1, val2)
#define DCHECK_GT(val1, val2) DCHECK_OP(GT, >, val1, val2)
#if defined(NDEBUG) && defined(OS_CHROMEOS)
#define NOTREACHED() LOG(ERROR) << "NOTREACHED() hit in " << \
__FUNCTION__ << ". "
#define NOTREACHED() \
LOG(ERROR) << "NOTREACHED() hit in " << __FUNCTION__ << ". "
#else
#define NOTREACHED() DCHECK(false)
#endif
@ -577,7 +582,9 @@ class LogMessage {
LogMessage(const char* file, int line, std::string* result);
// Used for DCHECK_EQ(), etc. Takes ownership of the given string.
LogMessage(const char* file, int line, LogSeverity severity,
LogMessage(const char* file,
int line,
LogSeverity severity,
std::string* result);
~LogMessage();
@ -617,7 +624,7 @@ class LogMessage {
// A non-macro interface to the log facility; (useful
// when the logging level is not a compile-time constant).
inline void LogAtLevel(int const log_level, std::string const &msg) {
inline void LogAtLevel(int const log_level, std::string const& msg) {
LogMessage(__FILE__, __LINE__, log_level).stream() << msg;
}
@ -626,10 +633,10 @@ inline void LogAtLevel(int const log_level, std::string const &msg) {
// is not used" and "statement has no effect".
class LogMessageVoidify {
public:
LogMessageVoidify() { }
LogMessageVoidify() {}
// This has to be an operator with a precedence lower than << but
// higher than ?:
void operator&(std::ostream&) { }
void operator&(std::ostream&) {}
};
#if defined(OS_WIN)
@ -739,12 +746,13 @@ inline std::ostream& operator<<(std::ostream& out, const std::wstring& wstr) {
#elif NOTIMPLEMENTED_POLICY == 4
#define NOTIMPLEMENTED() LOG(ERROR) << NOTIMPLEMENTED_MSG
#elif NOTIMPLEMENTED_POLICY == 5
#define NOTIMPLEMENTED() do {\
static bool logged_once = false;\
LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
logged_once = true;\
} while(0);\
EAT_STREAM_PARAMETERS
#define NOTIMPLEMENTED() \
do { \
static bool logged_once = false; \
LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG; \
logged_once = true; \
} while (0); \
EAT_STREAM_PARAMETERS
#endif
#endif // !USING_CHROMIUM_INCLUDES

View File

@ -41,7 +41,7 @@
// If the Chromium implementation diverges the below implementation should be
// updated to match.
#include <stddef.h> // For size_t.
#include <stddef.h> // For size_t.
#include "include/base/cef_build.h" // For COMPILER_MSVC
#if !defined(arraysize)
@ -126,14 +126,13 @@ char (&ArraySizeHelper(const T (&array)[N]))[N];
namespace cef {
template <bool>
struct CompileAssert {
};
struct CompileAssert {};
} // namespace cef
#define COMPILE_ASSERT(expr, msg) \
typedef cef::CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1] \
ALLOW_UNUSED_TYPE
#define COMPILE_ASSERT(expr, msg) \
typedef cef::CompileAssert<(bool(expr))> \
msg[bool(expr) ? 1 : -1] ALLOW_UNUSED_TYPE
// Implementation details of COMPILE_ASSERT:
//
@ -187,8 +186,8 @@ struct CompileAssert {
// MSVC_PUSH_DISABLE_WARNING pushes |n| onto a stack of warnings to be disabled.
// The warning remains disabled until popped by MSVC_POP_WARNING.
#define MSVC_PUSH_DISABLE_WARNING(n) __pragma(warning(push)) \
__pragma(warning(disable:n))
#define MSVC_PUSH_DISABLE_WARNING(n) \
__pragma(warning(push)) __pragma(warning(disable : n))
// MSVC_PUSH_WARNING_LEVEL pushes |n| as the global warning level. The level
// remains in effect until popped by MSVC_POP_WARNING(). Use 0 to disable all
@ -207,9 +206,9 @@ struct CompileAssert {
//
// Compiler warning C4355: 'this': used in base member initializer list:
// http://msdn.microsoft.com/en-us/library/3c594ae3(VS.80).aspx
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) MSVC_PUSH_DISABLE_WARNING(4355) \
code \
MSVC_POP_WARNING()
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) \
MSVC_PUSH_DISABLE_WARNING(4355) \
code MSVC_POP_WARNING()
#else // !COMPILER_MSVC
#define ALLOW_THIS_IN_INITIALIZER_LIST(code) code

View File

@ -240,20 +240,22 @@
//
// The workaround is to explicitly declare your copy constructor.
//
#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
private: \
struct rvalue_type { \
#define MOVE_ONLY_TYPE_FOR_CPP_03(type, rvalue_type) \
private: \
struct rvalue_type { \
explicit rvalue_type(type* object) : object(object) {} \
type* object; \
}; \
type(type&); \
void operator=(type&); \
public: \
operator rvalue_type() { return rvalue_type(this); } \
type Pass() { return type(rvalue_type(this)); } \
typedef void MoveOnlyTypeForCPP03; \
type* object; \
}; \
type(type&); \
void operator=(type&); \
\
public: \
operator rvalue_type() { return rvalue_type(this); } \
type Pass() { return type(rvalue_type(this)); } \
typedef void MoveOnlyTypeForCPP03; \
\
private:
#endif // !USING_CHROMIUM_INCLUDES
#endif // CEF_INCLUDE_BASE_CEF_MOVE_H_

View File

@ -69,21 +69,14 @@ class PlatformThreadRef {
public:
typedef cef_platform_thread_handle_t RefType;
PlatformThreadRef()
: id_(0) {
}
PlatformThreadRef() : id_(0) {}
explicit PlatformThreadRef(RefType id)
: id_(id) {
}
explicit PlatformThreadRef(RefType id) : id_(id) {}
bool operator==(PlatformThreadRef other) const {
return id_ == other.id_;
}
bool operator==(PlatformThreadRef other) const { return id_ == other.id_; }
bool is_null() const { return id_ == 0; }
bool is_null() const {
return id_ == 0;
}
private:
RefType id_;
};

View File

@ -64,43 +64,43 @@ class RefCountedBase {
protected:
RefCountedBase()
: ref_count_(0)
#if DCHECK_IS_ON()
, in_dtor_(false)
#endif
{
#if DCHECK_IS_ON()
,
in_dtor_(false)
#endif
{
}
~RefCountedBase() {
#if DCHECK_IS_ON()
#if DCHECK_IS_ON()
DCHECK(in_dtor_) << "RefCounted object deleted without calling Release()";
#endif
#endif
}
void AddRef() const {
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#if DCHECK_IS_ON()
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#if DCHECK_IS_ON()
DCHECK(!in_dtor_);
#endif
#endif
++ref_count_;
}
// Returns true if the object should self-delete.
bool Release() const {
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#if DCHECK_IS_ON()
// TODO(maruel): Add back once it doesn't assert 500 times/sec.
// Current thread books the critical section "AddRelease"
// without release it.
// DFAKE_SCOPED_LOCK_THREAD_LOCKED(add_release_);
#if DCHECK_IS_ON()
DCHECK(!in_dtor_);
#endif
#endif
if (--ref_count_ == 0) {
#if DCHECK_IS_ON()
#if DCHECK_IS_ON()
in_dtor_ = true;
#endif
#endif
return true;
}
return false;
@ -160,9 +160,7 @@ class RefCounted : public cef_subtle::RefCountedBase {
public:
RefCounted() {}
void AddRef() const {
cef_subtle::RefCountedBase::AddRef();
}
void AddRef() const { cef_subtle::RefCountedBase::AddRef(); }
void Release() const {
if (cef_subtle::RefCountedBase::Release()) {
@ -178,18 +176,19 @@ class RefCounted : public cef_subtle::RefCountedBase {
};
// Forward declaration.
template <class T, typename Traits> class RefCountedThreadSafe;
template <class T, typename Traits>
class RefCountedThreadSafe;
// Default traits for RefCountedThreadSafe<T>. Deletes the object when its ref
// count reaches 0. Overload to delete it on a different thread etc.
template<typename T>
template <typename T>
struct DefaultRefCountedThreadSafeTraits {
static void Destruct(const T* x) {
// Delete through RefCountedThreadSafe to make child classes only need to be
// friend with RefCountedThreadSafe instead of this struct, which is an
// implementation detail.
RefCountedThreadSafe<T,
DefaultRefCountedThreadSafeTraits>::DeleteInternal(x);
RefCountedThreadSafe<T, DefaultRefCountedThreadSafeTraits>::DeleteInternal(
x);
}
};
@ -205,14 +204,12 @@ struct DefaultRefCountedThreadSafeTraits {
// private:
// friend class base::RefCountedThreadSafe<MyFoo>;
// ~MyFoo();
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T> >
template <class T, typename Traits = DefaultRefCountedThreadSafeTraits<T>>
class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
public:
RefCountedThreadSafe() {}
void AddRef() const {
cef_subtle::RefCountedThreadSafeBase::AddRef();
}
void AddRef() const { cef_subtle::RefCountedThreadSafeBase::AddRef(); }
void Release() const {
if (cef_subtle::RefCountedThreadSafeBase::Release()) {
@ -234,9 +231,9 @@ class RefCountedThreadSafe : public cef_subtle::RefCountedThreadSafeBase {
// A thread-safe wrapper for some piece of data so we can place other
// things in scoped_refptrs<>.
//
template<typename T>
template <typename T>
class RefCountedData
: public base::RefCountedThreadSafe< base::RefCountedData<T> > {
: public base::RefCountedThreadSafe<base::RefCountedData<T>> {
public:
RefCountedData() : data() {}
RefCountedData(const T& in_value) : data(in_value) {}
@ -244,7 +241,7 @@ class RefCountedData
T data;
private:
friend class base::RefCountedThreadSafe<base::RefCountedData<T> >;
friend class base::RefCountedThreadSafe<base::RefCountedData<T>>;
~RefCountedData() {}
};
@ -303,8 +300,7 @@ class scoped_refptr {
public:
typedef T element_type;
scoped_refptr() : ptr_(NULL) {
}
scoped_refptr() : ptr_(NULL) {}
scoped_refptr(T* p) : ptr_(p) {
if (ptr_)
@ -364,9 +360,7 @@ class scoped_refptr {
*pp = p;
}
void swap(scoped_refptr<T>& r) {
swap(&r.ptr_);
}
void swap(scoped_refptr<T>& r) { swap(&r.ptr_); }
protected:
T* ptr_;

View File

@ -154,7 +154,8 @@ class RefCountedThreadSafeBase;
template <class T>
struct DefaultDeleter {
DefaultDeleter() {}
template <typename U> DefaultDeleter(const DefaultDeleter<U>& other) {
template <typename U>
DefaultDeleter(const DefaultDeleter<U>& other) {
// IMPLEMENTATION NOTE: C++11 20.7.1.1.2p2 only provides this constructor
// if U* is implicitly convertible to T* and U is not an array type.
//
@ -194,7 +195,8 @@ struct DefaultDeleter<T[]> {
// References:
// C++98 [expr.delete]p3
// http://cplusplus.github.com/LWG/lwg-defects.html#938
template <typename U> void operator()(U* array) const;
template <typename U>
void operator()(U* array) const;
};
template <class T, int n>
@ -209,18 +211,18 @@ struct DefaultDeleter<T[n]> {
// scoped_ptr<int, base::FreeDeleter> foo_ptr(
// static_cast<int*>(malloc(sizeof(int))));
struct FreeDeleter {
inline void operator()(void* ptr) const {
free(ptr);
}
inline void operator()(void* ptr) const { free(ptr); }
};
namespace cef_internal {
template <typename T> struct IsNotRefCounted {
template <typename T>
struct IsNotRefCounted {
enum {
value = !base::is_convertible<T*, base::subtle::RefCountedBase*>::value &&
!base::is_convertible<T*, base::subtle::RefCountedThreadSafeBase*>::
value
value =
!base::is_convertible<T*, base::subtle::RefCountedBase*>::value &&
!base::is_convertible<T*,
base::subtle::RefCountedThreadSafeBase*>::value
};
};
@ -229,7 +231,7 @@ template <typename T> struct IsNotRefCounted {
template <class T, class D>
class scoped_ptr_impl {
public:
explicit scoped_ptr_impl(T* p) : data_(p) { }
explicit scoped_ptr_impl(T* p) : data_(p) {}
// Initializer for deleters that have data parameters.
scoped_ptr_impl(T* p, const D& d) : data_(p, d) {}
@ -309,7 +311,8 @@ class scoped_ptr_impl {
private:
// Needed to allow type-converting constructor.
template <typename U, typename V> friend class scoped_ptr_impl;
template <typename U, typename V>
friend class scoped_ptr_impl;
// Use the empty base class optimization to allow us to have a D
// member, while avoiding any space overhead for it when D is an
@ -346,7 +349,7 @@ class scoped_ptr_impl {
// unique_ptr<> features. Known deficiencies include not supporting move-only
// deleteres, function pointers as deleters, and deleters with reference
// types.
template <class T, class D = base::DefaultDeleter<T> >
template <class T, class D = base::DefaultDeleter<T>>
class scoped_ptr {
MOVE_ONLY_TYPE_FOR_CPP_03(scoped_ptr, RValue)
@ -359,13 +362,13 @@ class scoped_ptr {
typedef D deleter_type;
// Constructor. Defaults to initializing with NULL.
scoped_ptr() : impl_(NULL) { }
scoped_ptr() : impl_(NULL) {}
// Constructor. Takes ownership of p.
explicit scoped_ptr(element_type* p) : impl_(p) { }
explicit scoped_ptr(element_type* p) : impl_(p) {}
// Constructor. Allows initialization of a stateful deleter.
scoped_ptr(element_type* p, const D& d) : impl_(p, d) { }
scoped_ptr(element_type* p, const D& d) : impl_(p, d) {}
// Constructor. Allows construction from a scoped_ptr rvalue for a
// convertible type and deleter.
@ -383,7 +386,7 @@ class scoped_ptr {
}
// Constructor. Move constructor for C++03 move emulation of this type.
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {}
// operator=. Allows assignment from a scoped_ptr rvalue for a convertible
// type and deleter.
@ -412,7 +415,7 @@ class scoped_ptr {
assert(impl_.get() != NULL);
return *impl_.get();
}
element_type* operator->() const {
element_type* operator->() const {
assert(impl_.get() != NULL);
return impl_.get();
}
@ -443,18 +446,14 @@ class scoped_ptr {
bool operator!=(const element_type* p) const { return impl_.get() != p; }
// Swap two scoped pointers.
void swap(scoped_ptr& p2) {
impl_.swap(p2.impl_);
}
void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); }
// Release a pointer.
// The return value is the current pointer held by this object.
// If this object holds a NULL pointer, the return value is NULL.
// After this operation, this object will hold a NULL pointer,
// and will not own the object any more.
element_type* release() WARN_UNUSED_RESULT {
return impl_.release();
}
element_type* release() WARN_UNUSED_RESULT { return impl_.release(); }
// C++98 doesn't support functions templates with default parameters which
// makes it hard to write a PassAs() that understands converting the deleter
@ -469,7 +468,8 @@ class scoped_ptr {
private:
// Needed to reach into |impl_| in the constructor.
template <typename U, typename V> friend class scoped_ptr;
template <typename U, typename V>
friend class scoped_ptr;
base::cef_internal::scoped_ptr_impl<element_type, deleter_type> impl_;
// Forbidden for API compatibility with std::unique_ptr.
@ -479,8 +479,10 @@ class scoped_ptr {
// doesn't make sense, and if U == T, it still doesn't make sense
// because you should never have the same object owned by two different
// scoped_ptrs.
template <class U> bool operator==(scoped_ptr<U> const& p2) const;
template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
template <class U>
bool operator==(scoped_ptr<U> const& p2) const;
template <class U>
bool operator!=(scoped_ptr<U> const& p2) const;
};
template <class T, class D>
@ -493,7 +495,7 @@ class scoped_ptr<T[], D> {
typedef D deleter_type;
// Constructor. Defaults to initializing with NULL.
scoped_ptr() : impl_(NULL) { }
scoped_ptr() : impl_(NULL) {}
// Constructor. Stores the given array. Note that the argument's type
// must exactly match T*. In particular:
@ -511,10 +513,10 @@ class scoped_ptr<T[], D> {
// to work around this may use implicit_cast<const T*>().
// However, because of the first bullet in this comment, users MUST
// NOT use implicit_cast<Base*>() to upcast the static type of the array.
explicit scoped_ptr(element_type* array) : impl_(array) { }
explicit scoped_ptr(element_type* array) : impl_(array) {}
// Constructor. Move constructor for C++03 move emulation of this type.
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) { }
scoped_ptr(RValue rvalue) : impl_(&rvalue.object->impl_) {}
// operator=. Move operator= for C++03 move emulation of this type.
scoped_ptr& operator=(RValue rhs) {
@ -553,18 +555,14 @@ class scoped_ptr<T[], D> {
bool operator!=(element_type* array) const { return impl_.get() != array; }
// Swap two scoped pointers.
void swap(scoped_ptr& p2) {
impl_.swap(p2.impl_);
}
void swap(scoped_ptr& p2) { impl_.swap(p2.impl_); }
// Release a pointer.
// The return value is the current pointer held by this object.
// If this object holds a NULL pointer, the return value is NULL.
// After this operation, this object will hold a NULL pointer,
// and will not own the object any more.
element_type* release() WARN_UNUSED_RESULT {
return impl_.release();
}
element_type* release() WARN_UNUSED_RESULT { return impl_.release(); }
private:
// Force element_type to be a complete type.
@ -578,20 +576,24 @@ class scoped_ptr<T[], D> {
// private and has no definition. This is disabled because it is not safe to
// call delete[] on an array whose static type does not match its dynamic
// type.
template <typename U> explicit scoped_ptr(U* array);
template <typename U>
explicit scoped_ptr(U* array);
explicit scoped_ptr(int disallow_construction_from_null);
// Disable reset() from any type other than element_type*, for the same
// reasons as the constructor above.
template <typename U> void reset(U* array);
template <typename U>
void reset(U* array);
void reset(int disallow_reset_from_null);
// Forbid comparison of scoped_ptr types. If U != T, it totally
// doesn't make sense, and if U == T, it still doesn't make sense
// because you should never have the same object owned by two different
// scoped_ptrs.
template <class U> bool operator==(scoped_ptr<U> const& p2) const;
template <class U> bool operator!=(scoped_ptr<U> const& p2) const;
template <class U>
bool operator==(scoped_ptr<U> const& p2) const;
template <class U>
bool operator!=(scoped_ptr<U> const& p2) const;
};
// Free functions

View File

@ -112,26 +112,19 @@ struct string16_char_traits {
typedef mbstate_t state_type;
typedef std::fpos<state_type> pos_type;
static void assign(char_type& c1, const char_type& c2) {
c1 = c2;
}
static void assign(char_type& c1, const char_type& c2) { c1 = c2; }
static bool eq(const char_type& c1, const char_type& c2) {
return c1 == c2;
}
static bool lt(const char_type& c1, const char_type& c2) {
return c1 < c2;
}
static bool eq(const char_type& c1, const char_type& c2) { return c1 == c2; }
static bool lt(const char_type& c1, const char_type& c2) { return c1 < c2; }
static int compare(const char_type* s1, const char_type* s2, size_t n) {
return c16memcmp(s1, s2, n);
}
static size_t length(const char_type* s) {
return c16len(s);
}
static size_t length(const char_type* s) { return c16len(s); }
static const char_type* find(const char_type* s, size_t n,
static const char_type* find(const char_type* s,
size_t n,
const char_type& a) {
return c16memchr(s, a, n);
}
@ -152,21 +145,15 @@ struct string16_char_traits {
return eq_int_type(c, eof()) ? 0 : c;
}
static char_type to_char_type(const int_type& c) {
return char_type(c);
}
static char_type to_char_type(const int_type& c) { return char_type(c); }
static int_type to_int_type(const char_type& c) {
return int_type(c);
}
static int_type to_int_type(const char_type& c) { return int_type(c); }
static bool eq_int_type(const int_type& c1, const int_type& c2) {
return c1 == c2;
}
static int_type eof() {
return static_cast<int_type>(EOF);
}
static int_type eof() { return static_cast<int_type>(EOF); }
};
typedef std::basic_string<char16, base::string16_char_traits> string16;
@ -217,8 +204,8 @@ extern void PrintTo(const string16& str, std::ostream* out);
//
// TODO(mark): File this bug with Apple and update this note with a bug number.
extern template
class std::basic_string<base::char16, base::string16_char_traits>;
extern template class std::basic_string<base::char16,
base::string16_char_traits>;
#endif // WCHAR_T_IS_UTF32

View File

@ -53,70 +53,92 @@ namespace base {
// template definitions from tr1
template<class T, T v>
template <class T, T v>
struct integral_constant {
static const T value = v;
typedef T value_type;
typedef integral_constant<T, v> type;
};
template <class T, T v> const T integral_constant<T, v>::value;
template <class T, T v>
const T integral_constant<T, v>::value;
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;
template <class T> struct is_pointer : false_type {};
template <class T> struct is_pointer<T*> : true_type {};
template <class T>
struct is_pointer : false_type {};
template <class T>
struct is_pointer<T*> : true_type {};
// Member function pointer detection up to four params. Add more as needed
// below. This is built-in to C++ 11, and we can remove this when we switch.
template<typename T>
template <typename T>
struct is_member_function_pointer : false_type {};
template <typename R, typename Z>
struct is_member_function_pointer<R(Z::*)()> : true_type {};
struct is_member_function_pointer<R (Z::*)()> : true_type {};
template <typename R, typename Z>
struct is_member_function_pointer<R(Z::*)() const> : true_type {};
struct is_member_function_pointer<R (Z::*)() const> : true_type {};
template <typename R, typename Z, typename A>
struct is_member_function_pointer<R(Z::*)(A)> : true_type {};
struct is_member_function_pointer<R (Z::*)(A)> : true_type {};
template <typename R, typename Z, typename A>
struct is_member_function_pointer<R(Z::*)(A) const> : true_type {};
struct is_member_function_pointer<R (Z::*)(A) const> : true_type {};
template <typename R, typename Z, typename A, typename B>
struct is_member_function_pointer<R(Z::*)(A, B)> : true_type {};
struct is_member_function_pointer<R (Z::*)(A, B)> : true_type {};
template <typename R, typename Z, typename A, typename B>
struct is_member_function_pointer<R(Z::*)(A, B) const> : true_type {};
struct is_member_function_pointer<R (Z::*)(A, B) const> : true_type {};
template <typename R, typename Z, typename A, typename B, typename C>
struct is_member_function_pointer<R(Z::*)(A, B, C)> : true_type {};
struct is_member_function_pointer<R (Z::*)(A, B, C)> : true_type {};
template <typename R, typename Z, typename A, typename B, typename C>
struct is_member_function_pointer<R(Z::*)(A, B, C) const> : true_type {};
struct is_member_function_pointer<R (Z::*)(A, B, C) const> : true_type {};
template <typename R, typename Z, typename A, typename B, typename C,
template <typename R,
typename Z,
typename A,
typename B,
typename C,
typename D>
struct is_member_function_pointer<R(Z::*)(A, B, C, D)> : true_type {};
template <typename R, typename Z, typename A, typename B, typename C,
struct is_member_function_pointer<R (Z::*)(A, B, C, D)> : true_type {};
template <typename R,
typename Z,
typename A,
typename B,
typename C,
typename D>
struct is_member_function_pointer<R(Z::*)(A, B, C, D) const> : true_type {};
struct is_member_function_pointer<R (Z::*)(A, B, C, D) const> : true_type {};
template <class T, class U>
struct is_same : public false_type {};
template <class T>
struct is_same<T, T> : true_type {};
template <class T, class U> struct is_same : public false_type {};
template <class T> struct is_same<T,T> : true_type {};
template <class>
struct is_array : public false_type {};
template <class T, size_t n>
struct is_array<T[n]> : public true_type {};
template <class T>
struct is_array<T[]> : public true_type {};
template<class> struct is_array : public false_type {};
template<class T, size_t n> struct is_array<T[n]> : public true_type {};
template<class T> struct is_array<T[]> : public true_type {};
template <class T>
struct is_non_const_reference : false_type {};
template <class T>
struct is_non_const_reference<T&> : true_type {};
template <class T>
struct is_non_const_reference<const T&> : false_type {};
template <class T> struct is_non_const_reference : false_type {};
template <class T> struct is_non_const_reference<T&> : true_type {};
template <class T> struct is_non_const_reference<const T&> : false_type {};
template <class T>
struct is_const : false_type {};
template <class T>
struct is_const<const T> : true_type {};
template <class T> struct is_const : false_type {};
template <class T> struct is_const<const T> : true_type {};
template <class T> struct is_void : false_type {};
template <> struct is_void<void> : true_type {};
template <class T>
struct is_void : false_type {};
template <>
struct is_void<void> : true_type {};
namespace cef_internal {
@ -152,7 +174,7 @@ struct ConvertHelper {
// is_class type_trait implementation.
struct IsClassHelper {
template <typename C>
static YesType Test(void(C::*)(void));
static YesType Test(void (C::*)(void));
template <typename C>
static NoType Test(...);
@ -168,22 +190,22 @@ template <typename From, typename To>
struct is_convertible
: integral_constant<bool,
sizeof(cef_internal::ConvertHelper::Test<To>(
cef_internal::ConvertHelper::Create<From>())) ==
sizeof(cef_internal::YesType)> {
};
cef_internal::ConvertHelper::Create<From>())) ==
sizeof(cef_internal::YesType)> {};
template <typename T>
struct is_class
: integral_constant<bool,
sizeof(cef_internal::IsClassHelper::Test<T>(0)) ==
sizeof(cef_internal::YesType)> {
};
sizeof(cef_internal::YesType)> {};
template<bool B, class T = void>
template <bool B, class T = void>
struct enable_if {};
template<class T>
struct enable_if<true, T> { typedef T type; };
template <class T>
struct enable_if<true, T> {
typedef T type;
};
} // namespace base

View File

@ -58,7 +58,6 @@
#define ENABLE_THREAD_CHECKER 0
#endif
namespace base {
namespace cef_internal {
@ -69,9 +68,7 @@ namespace cef_internal {
// right version for your build configuration.
class ThreadCheckerDoNothing {
public:
bool CalledOnValidThread() const {
return true;
}
bool CalledOnValidThread() const { return true; }
void DetachFromThread() {}
};
@ -110,11 +107,9 @@ class ThreadCheckerDoNothing {
//
// In Release mode, CalledOnValidThread will always return true.
#if ENABLE_THREAD_CHECKER
class ThreadChecker : public cef_internal::ThreadCheckerImpl {
};
class ThreadChecker : public cef_internal::ThreadCheckerImpl {};
#else
class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {
};
class ThreadChecker : public cef_internal::ThreadCheckerDoNothing {};
#endif // ENABLE_THREAD_CHECKER
#undef ENABLE_THREAD_CHECKER

View File

@ -139,24 +139,22 @@
// DFAKE_MUTEX(shareable_section_);
// };
#if DCHECK_IS_ON()
// Defines a class member that acts like a mutex. It is used only as a
// verification tool.
#define DFAKE_MUTEX(obj) \
mutable base::ThreadCollisionWarner obj
#define DFAKE_MUTEX(obj) mutable base::ThreadCollisionWarner obj
// Asserts the call is never called simultaneously in two threads. Used at
// member function scope.
#define DFAKE_SCOPED_LOCK(obj) \
base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj)
base::ThreadCollisionWarner::ScopedCheck s_check_##obj(&obj)
// Asserts the call is never called simultaneously in two threads. Used at
// member function scope. Same as DFAKE_SCOPED_LOCK but allows recursive locks.
#define DFAKE_SCOPED_RECURSIVE_LOCK(obj) \
base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj)
base::ThreadCollisionWarner::ScopedRecursiveCheck sr_check_##obj(&obj)
// Asserts the code is always executed in the same thread.
#define DFAKE_SCOPED_LOCK_THREAD_LOCKED(obj) \
base::ThreadCollisionWarner::Check check_##obj(&obj)
base::ThreadCollisionWarner::Check check_##obj(&obj)
#else
@ -187,13 +185,9 @@ class ThreadCollisionWarner {
public:
// The parameter asserter is there only for test purpose
explicit ThreadCollisionWarner(AsserterBase* asserter = new DCheckAsserter())
: valid_thread_id_(0),
counter_(0),
asserter_(asserter) {}
: valid_thread_id_(0), counter_(0), asserter_(asserter) {}
~ThreadCollisionWarner() {
delete asserter_;
}
~ThreadCollisionWarner() { delete asserter_; }
// This class is meant to be used through the macro
// DFAKE_SCOPED_LOCK_THREAD_LOCKED
@ -202,8 +196,7 @@ class ThreadCollisionWarner {
// from one thread
class Check {
public:
explicit Check(ThreadCollisionWarner* warner)
: warner_(warner) {
explicit Check(ThreadCollisionWarner* warner) : warner_(warner) {
warner_->EnterSelf();
}
@ -219,14 +212,11 @@ class ThreadCollisionWarner {
// DFAKE_SCOPED_LOCK
class ScopedCheck {
public:
explicit ScopedCheck(ThreadCollisionWarner* warner)
: warner_(warner) {
explicit ScopedCheck(ThreadCollisionWarner* warner) : warner_(warner) {
warner_->Enter();
}
~ScopedCheck() {
warner_->Leave();
}
~ScopedCheck() { warner_->Leave(); }
private:
ThreadCollisionWarner* warner_;
@ -243,9 +233,7 @@ class ThreadCollisionWarner {
warner_->EnterSelf();
}
~ScopedRecursiveCheck() {
warner_->Leave();
}
~ScopedRecursiveCheck() { warner_->Leave(); }
private:
ThreadCollisionWarner* warner_;

View File

@ -160,32 +160,29 @@
// enabled, then this does nothing.
// - category and name strings must have application lifetime (statics or
// literals). They may not include " chars.
#define TRACE_EVENT0(category, name) \
#define TRACE_EVENT0(category, name) \
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false); \
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false); \
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val, false); \
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false); \
CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name)
// Implementation detail: trace event macros create temporary variable names.
// These macros give each temporary variable a unique name based on the line
// number to prevent name collisions.
#define CEF_INTERNAL_TRACE_EVENT_UID3(a,b) \
cef_trace_event_unique_##a##b
#define CEF_INTERNAL_TRACE_EVENT_UID2(a,b) \
CEF_INTERNAL_TRACE_EVENT_UID3(a,b)
#define CEF_INTERNAL_TRACE_EVENT_UID3(a, b) cef_trace_event_unique_##a##b
#define CEF_INTERNAL_TRACE_EVENT_UID2(a, b) CEF_INTERNAL_TRACE_EVENT_UID3(a, b)
#define CEF_INTERNAL_TRACE_EVENT_UID(name_prefix) \
CEF_INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
// Implementation detail: internal macro to end end event when the scope ends.
#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \
cef_trace_event::CefTraceEndOnScopeClose \
CEF_INTERNAL_TRACE_EVENT_UID(profileScope)(category, name)
#define CEF_INTERNAL_TRACE_END_ON_SCOPE_CLOSE(category, name) \
cef_trace_event::CefTraceEndOnScopeClose CEF_INTERNAL_TRACE_EVENT_UID( \
profileScope)(category, name)
// Records a single event called "name" immediately, with 0, 1 or 2
// associated arguments. If the category is not enabled, then this
@ -196,18 +193,18 @@
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, false)
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, false)
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false)
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false)
#define TRACE_EVENT_COPY_INSTANT0(category, name) \
cef_trace_event_instant(category, name, NULL, 0, NULL, 0, true)
#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \
cef_trace_event_instant(category, name, arg1_name, arg1_val, NULL, 0, true)
#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_instant(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, true)
arg2_val, true)
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2
// associated arguments. If the category is not enabled, then this
@ -218,18 +215,18 @@
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, false)
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, false)
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false)
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false)
#define TRACE_EVENT_COPY_BEGIN0(category, name) \
cef_trace_event_begin(category, name, NULL, 0, NULL, 0, true)
#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, NULL, 0, true)
#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_begin(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, true)
arg2_val, true)
// Records a single END event for "name" immediately. If the category
// is not enabled, then this does nothing.
@ -239,18 +236,18 @@
cef_trace_event_end(category, name, NULL, 0, NULL, 0, false)
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, false)
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false)
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, false)
#define TRACE_EVENT_COPY_END0(category, name) \
cef_trace_event_end(category, name, NULL, 0, NULL, 0, true)
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
cef_trace_event_end(category, name, arg1_name, arg1_val, NULL, 0, true)
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, true)
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val) \
cef_trace_event_end(category, name, arg1_name, arg1_val, arg2_name, \
arg2_val, true)
// Records the value of a counter called "name" immediately. Value
// must be representable as a 32 bit integer.
@ -266,14 +263,14 @@
// values as a stacked-bar chart.
// - category and name strings must have application lifetime (statics or
// literals). They may not include " chars.
#define TRACE_COUNTER2(category, name, value1_name, value1_val, \
value2_name, value2_val) \
#define TRACE_COUNTER2(category, name, value1_name, value1_val, value2_name, \
value2_val) \
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
value2_val, false)
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
value2_name, value2_val) \
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
value2_val, false)
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \
value2_name, value2_val) \
cef_trace_counter(category, name, value1_name, value1_val, value2_name, \
value2_val, true)
value2_val, true)
// Records the value of a counter called "name" immediately. Value
// must be representable as a 32 bit integer.
@ -298,14 +295,13 @@
// bits will be xored with a hash of the process ID so that the same pointer
// on two different processes will not collide.
#define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \
value2_name, value2_val) \
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
value2_name, value2_val, false)
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, \
value1_val, value2_name, value2_val) \
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
value2_name, value2_val, true)
value2_name, value2_val) \
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
value2_name, value2_val, false)
#define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \
value2_name, value2_val) \
cef_trace_counter_id(category, name, id, value1_name, value1_val, \
value2_name, value2_val, true)
// Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
// associated arguments. If the category is not enabled, then this
@ -325,23 +321,22 @@
// args.
#define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, false)
#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
#define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
0, false)
0, false)
#define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, false)
arg2_name, arg2_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, false)
#define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \
cef_trace_event_async_begin(category, name, id, NULL, 0, NULL, 0, true)
#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, \
arg1_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
0, true)
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, \
arg1_val, arg2_name, arg2_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, true)
#define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, NULL, \
0, true)
#define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_async_begin(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, true)
// Records a single ASYNC_STEP_INTO event for |step| immediately. If the
// category is not enabled, then this does nothing. The |name| and |id| must
@ -351,16 +346,16 @@
// ASYNC_STEP_PAST events.
#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, false)
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, \
arg1_name, arg1_val) \
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
arg1_val, false)
#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
arg1_val) \
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
arg1_val, false)
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO0(category, name, id, step) \
cef_trace_event_async_step_into(category, name, id, step, NULL, 0, true)
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, \
arg1_name, arg1_val) \
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
arg1_val, true)
#define TRACE_EVENT_COPY_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \
arg1_val) \
cef_trace_event_async_step_into(category, name, id, step, arg1_name, \
arg1_val, true)
// Records a single ASYNC_STEP_PAST event for |step| immediately. If the
// category is not enabled, then this does nothing. The |name| and |id| must
@ -370,38 +365,37 @@
// ASYNC_STEP_INTO events.
#define TRACE_EVENT_ASYNC_STEP_PAST0(category, name, id, step) \
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, false)
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, \
arg1_name, arg1_val) \
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
arg1_val, false)
#define TRACE_EVENT_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
arg1_val) \
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
arg1_val, false)
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST0(category, name, id, step) \
cef_trace_event_async_step_past(category, name, id, step, NULL, 0, true)
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, \
arg1_name, arg1_val) \
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
arg1_val, true)
#define TRACE_EVENT_COPY_ASYNC_STEP_PAST1(category, name, id, step, arg1_name, \
arg1_val) \
cef_trace_event_async_step_past(category, name, id, step, arg1_name, \
arg1_val, true)
// Records a single ASYNC_END event for "name" immediately. If the category
// is not enabled, then this does nothing.
#define TRACE_EVENT_ASYNC_END0(category, name, id) \
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, false)
#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
#define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
false)
false)
#define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, false)
arg2_name, arg2_val) \
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, false)
#define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \
cef_trace_event_async_end(category, name, id, NULL, 0, NULL, 0, true)
#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, \
arg1_val) \
#define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, NULL, 0, \
true)
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, \
arg1_val, arg2_name, arg2_val) \
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, true)
true)
#define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val) \
cef_trace_event_async_end(category, name, id, arg1_name, arg1_val, \
arg2_name, arg2_val, true)
namespace cef_trace_event {
@ -409,8 +403,7 @@ namespace cef_trace_event {
class CefTraceEndOnScopeClose {
public:
CefTraceEndOnScopeClose(const char* category, const char* name)
: category_(category), name_(name) {
}
: category_(category), name_(name) {}
~CefTraceEndOnScopeClose() {
cef_trace_event_end(category_, name_, NULL, 0, NULL, 0, false);
}

File diff suppressed because it is too large Load Diff

View File

@ -117,8 +117,10 @@
namespace base {
template <typename T> class SupportsWeakPtr;
template <typename T> class WeakPtr;
template <typename T>
class SupportsWeakPtr;
template <typename T>
class WeakPtr;
namespace cef_internal {
// These classes are part of the WeakPtr implementation.
@ -164,9 +166,7 @@ class WeakReferenceOwner {
WeakReference GetRef() const;
bool HasRefs() const {
return flag_.get() && !flag_->HasOneRef();
}
bool HasRefs() const { return flag_.get() && !flag_->HasOneRef(); }
void Invalidate();
@ -198,10 +198,10 @@ class SupportsWeakPtrBase {
// conversion will only compile if there is exists a Base which inherits
// from SupportsWeakPtr<Base>. See base::AsWeakPtr() below for a helper
// function that makes calling this easier.
template<typename Derived>
template <typename Derived>
static WeakPtr<Derived> StaticAsWeakPtr(Derived* t) {
typedef
is_convertible<Derived, cef_internal::SupportsWeakPtrBase&> convertible;
typedef is_convertible<Derived, cef_internal::SupportsWeakPtrBase&>
convertible;
COMPILE_ASSERT(convertible::value,
AsWeakPtr_argument_inherits_from_SupportsWeakPtr);
return AsWeakPtrImpl<Derived>(t, *t);
@ -212,8 +212,8 @@ class SupportsWeakPtrBase {
// which is an instance of SupportsWeakPtr<Base>. We can then safely
// static_cast the Base* to a Derived*.
template <typename Derived, typename Base>
static WeakPtr<Derived> AsWeakPtrImpl(
Derived* t, const SupportsWeakPtr<Base>&) {
static WeakPtr<Derived> AsWeakPtrImpl(Derived* t,
const SupportsWeakPtr<Base>&) {
WeakPtr<Base> ptr = t->Base::AsWeakPtr();
return WeakPtr<Derived>(ptr.ref_, static_cast<Derived*>(ptr.ptr_));
}
@ -221,7 +221,8 @@ class SupportsWeakPtrBase {
} // namespace cef_internal
template <typename T> class WeakPtrFactory;
template <typename T>
class WeakPtrFactory;
// The WeakPtr class holds a weak reference to |T*|.
//
@ -239,14 +240,12 @@ template <typename T> class WeakPtrFactory;
template <typename T>
class WeakPtr : public cef_internal::WeakPtrBase {
public:
WeakPtr() : ptr_(NULL) {
}
WeakPtr() : ptr_(NULL) {}
// Allow conversion from U to T provided U "is a" T. Note that this
// is separate from the (implicit) copy constructor.
template <typename U>
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other), ptr_(other.ptr_) {
}
WeakPtr(const WeakPtr<U>& other) : WeakPtrBase(other), ptr_(other.ptr_) {}
T* get() const { return ref_.is_valid() ? ptr_ : NULL; }
@ -280,18 +279,19 @@ class WeakPtr : public cef_internal::WeakPtrBase {
private:
// Explicitly declare comparison operators as required by the bool
// trick, but keep them private.
template <class U> bool operator==(WeakPtr<U> const&) const;
template <class U> bool operator!=(WeakPtr<U> const&) const;
template <class U>
bool operator==(WeakPtr<U> const&) const;
template <class U>
bool operator!=(WeakPtr<U> const&) const;
friend class cef_internal::SupportsWeakPtrBase;
template <typename U> friend class WeakPtr;
template <typename U>
friend class WeakPtr;
friend class SupportsWeakPtr<T>;
friend class WeakPtrFactory<T>;
WeakPtr(const cef_internal::WeakReference& ref, T* ptr)
: WeakPtrBase(ref),
ptr_(ptr) {
}
: WeakPtrBase(ref), ptr_(ptr) {}
// This pointer is only valid when ref_.is_valid() is true. Otherwise, its
// value is undefined (as opposed to NULL).
@ -306,12 +306,9 @@ class WeakPtr : public cef_internal::WeakPtrBase {
template <class T>
class WeakPtrFactory {
public:
explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {
}
explicit WeakPtrFactory(T* ptr) : ptr_(ptr) {}
~WeakPtrFactory() {
ptr_ = NULL;
}
~WeakPtrFactory() { ptr_ = NULL; }
WeakPtr<T> GetWeakPtr() {
DCHECK(ptr_);

View File

@ -85,9 +85,9 @@ inline void MemoryBarrier() {
// variant of the target architecture is being used. This tests against
// any known ARMv6 or ARMv7 variant, where it is possible to directly
// use ldrex/strex instructions to implement fast atomic operations.
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || \
defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || \
defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || \
defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || \
defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__)
@ -103,16 +103,17 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
// reloop = 0
// if (prev_value != old_value)
// reloop = STREX(ptr, new_value)
__asm__ __volatile__(" ldrex %0, [%3]\n"
" mov %1, #0\n"
" cmp %0, %4\n"
__asm__ __volatile__(
" ldrex %0, [%3]\n"
" mov %1, #0\n"
" cmp %0, %4\n"
#ifdef __thumb2__
" it eq\n"
" it eq\n"
#endif
" strexeq %1, %5, [%3]\n"
: "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr)
: "r"(ptr), "r"(old_value), "r"(new_value)
: "cc", "memory");
" strexeq %1, %5, [%3]\n"
: "=&r"(prev_value), "=&r"(reloop), "+m"(*ptr)
: "r"(ptr), "r"(old_value), "r"(new_value)
: "cc", "memory");
} while (reloop != 0);
return prev_value;
}
@ -143,12 +144,13 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
// value += increment
// reloop = STREX(ptr, value)
//
__asm__ __volatile__(" ldrex %0, [%3]\n"
" add %0, %0, %4\n"
" strex %1, %0, [%3]\n"
: "=&r"(value), "=&r"(reloop), "+m"(*ptr)
: "r"(ptr), "r"(increment)
: "cc", "memory");
__asm__ __volatile__(
" ldrex %0, [%3]\n"
" add %0, %0, %4\n"
" strex %1, %0, [%3]\n"
: "=&r"(value), "=&r"(reloop), "+m"(*ptr)
: "r"(ptr), "r"(increment)
: "cc", "memory");
} while (reloop);
return value;
}
@ -171,18 +173,19 @@ inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
do {
// old_value = LDREX(ptr)
// reloop = STREX(ptr, new_value)
__asm__ __volatile__(" ldrex %0, [%3]\n"
" strex %1, %4, [%3]\n"
: "=&r"(old_value), "=&r"(reloop), "+m"(*ptr)
: "r"(ptr), "r"(new_value)
: "cc", "memory");
__asm__ __volatile__(
" ldrex %0, [%3]\n"
" strex %1, %4, [%3]\n"
: "=&r"(old_value), "=&r"(reloop), "+m"(*ptr)
: "r"(ptr), "r"(new_value)
: "cc", "memory");
} while (reloop != 0);
return old_value;
}
// This tests against any known ARMv5 variant.
#elif defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) || \
defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
// The kernel also provides a helper function to perform an atomic
// compare-and-swap operation at the hard-wired address 0xffff0fc0.
@ -281,7 +284,7 @@ inline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,
}
#else
# error "Your CPU's ARM architecture is not supported yet"
#error "Your CPU's ARM architecture is not supported yet"
#endif
// NOTE: Atomicity of the following load and store operations is only
@ -301,7 +304,9 @@ inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value;
}
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) { return *ptr; }
inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
return *ptr;
}
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value = *ptr;

View File

@ -52,26 +52,26 @@ namespace subtle {
inline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,
AtomicWord old_value,
AtomicWord new_value) {
return NoBarrier_CompareAndSwap(
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
return NoBarrier_CompareAndSwap(reinterpret_cast<volatile Atomic32*>(ptr),
old_value, new_value);
}
inline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,
AtomicWord new_value) {
return NoBarrier_AtomicExchange(
reinterpret_cast<volatile Atomic32*>(ptr), new_value);
return NoBarrier_AtomicExchange(reinterpret_cast<volatile Atomic32*>(ptr),
new_value);
}
inline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,
AtomicWord increment) {
return NoBarrier_AtomicIncrement(
reinterpret_cast<volatile Atomic32*>(ptr), increment);
return NoBarrier_AtomicIncrement(reinterpret_cast<volatile Atomic32*>(ptr),
increment);
}
inline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,
AtomicWord increment) {
return Barrier_AtomicIncrement(
reinterpret_cast<volatile Atomic32*>(ptr), increment);
return Barrier_AtomicIncrement(reinterpret_cast<volatile Atomic32*>(ptr),
increment);
}
inline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,
@ -88,24 +88,22 @@ inline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,
reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);
}
inline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {
NoBarrier_Store(
reinterpret_cast<volatile Atomic32*>(ptr), value);
inline void NoBarrier_Store(volatile AtomicWord* ptr, AtomicWord value) {
NoBarrier_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);
}
inline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {
return base::subtle::Acquire_Store(
reinterpret_cast<volatile Atomic32*>(ptr), value);
return base::subtle::Acquire_Store(reinterpret_cast<volatile Atomic32*>(ptr),
value);
}
inline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {
return base::subtle::Release_Store(
reinterpret_cast<volatile Atomic32*>(ptr), value);
return base::subtle::Release_Store(reinterpret_cast<volatile Atomic32*>(ptr),
value);
}
inline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) {
return NoBarrier_Load(
reinterpret_cast<volatile const Atomic32*>(ptr));
inline AtomicWord NoBarrier_Load(volatile const AtomicWord* ptr) {
return NoBarrier_Load(reinterpret_cast<volatile const Atomic32*>(ptr));
}
inline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {
@ -118,8 +116,8 @@ inline AtomicWord Release_Load(volatile const AtomicWord* ptr) {
reinterpret_cast<volatile const Atomic32*>(ptr));
}
} // namespace base::subtle
} // namespace base
} // namespace base::subtle
} // namespace base
#endif // !defined(ARCH_CPU_64_BITS)

View File

@ -170,7 +170,7 @@ inline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 prev_value;
do {
if (OSAtomicCompareAndSwap64Barrier(
old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {
return old_value;
}
prev_value = *ptr;
@ -217,7 +217,7 @@ inline Atomic64 Release_Load(volatile const Atomic64* ptr) {
#endif // defined(__LP64__)
} // namespace base::subtle
} // namespace base
} // namespace base::subtle
} // namespace base
#endif // CEF_INCLUDE_BASE_INTERNAL_CEF_ATOMICOPS_MAC_H_

View File

@ -38,11 +38,10 @@
// Features of this x86. Values may not be correct before main() is run,
// but are set conservatively.
struct AtomicOps_x86CPUFeatureStruct {
bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence
// after acquire compare-and-swap.
bool has_amd_lock_mb_bug; // Processor has AMD memory-barrier bug; do lfence
// after acquire compare-and-swap.
};
extern struct AtomicOps_x86CPUFeatureStruct
AtomicOps_Internalx86CPUFeatures;
extern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures;
#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__("" : : : "memory")
@ -56,8 +55,8 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 new_value) {
Atomic32 prev;
__asm__ __volatile__("lock; cmpxchgl %1,%2"
: "=a" (prev)
: "q" (new_value), "m" (*ptr), "0" (old_value)
: "=a"(prev)
: "q"(new_value), "m"(*ptr), "0"(old_value)
: "memory");
return prev;
}
@ -65,8 +64,8 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
Atomic32 new_value) {
__asm__ __volatile__("xchgl %1,%0" // The lock prefix is implicit for xchg.
: "=r" (new_value)
: "m" (*ptr), "0" (new_value)
: "=r"(new_value)
: "m"(*ptr), "0"(new_value)
: "memory");
return new_value; // Now it's the previous value.
}
@ -75,8 +74,9 @@ inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
Atomic32 temp = increment;
__asm__ __volatile__("lock; xaddl %0,%1"
: "+r" (temp), "+m" (*ptr)
: : "memory");
: "+r"(temp), "+m"(*ptr)
:
: "memory");
// temp now holds the old value of *ptr
return temp + increment;
}
@ -85,8 +85,9 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
Atomic32 temp = increment;
__asm__ __volatile__("lock; xaddl %0,%1"
: "+r" (temp), "+m" (*ptr)
: : "memory");
: "+r"(temp), "+m"(*ptr)
:
: "memory");
// temp now holds the old value of *ptr
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
__asm__ __volatile__("lfence" : : : "memory");
@ -125,7 +126,7 @@ inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
ATOMICOPS_COMPILER_BARRIER();
*ptr = value; // An x86 store acts as a release barrier.
*ptr = value; // An x86 store acts as a release barrier.
// See comments in Atomic64 version of Release_Store(), below.
}
@ -134,7 +135,7 @@ inline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {
}
inline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {
Atomic32 value = *ptr; // An x86 load acts as a acquire barrier.
Atomic32 value = *ptr; // An x86 load acts as a acquire barrier.
// See comments in Atomic64 version of Release_Store(), below.
ATOMICOPS_COMPILER_BARRIER();
return value;
@ -154,8 +155,8 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 new_value) {
Atomic64 prev;
__asm__ __volatile__("lock; cmpxchgq %1,%2"
: "=a" (prev)
: "q" (new_value), "m" (*ptr), "0" (old_value)
: "=a"(prev)
: "q"(new_value), "m"(*ptr), "0"(old_value)
: "memory");
return prev;
}
@ -163,8 +164,8 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
Atomic64 new_value) {
__asm__ __volatile__("xchgq %1,%0" // The lock prefix is implicit for xchg.
: "=r" (new_value)
: "m" (*ptr), "0" (new_value)
: "=r"(new_value)
: "m"(*ptr), "0"(new_value)
: "memory");
return new_value; // Now it's the previous value.
}
@ -173,8 +174,9 @@ inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
Atomic64 temp = increment;
__asm__ __volatile__("lock; xaddq %0,%1"
: "+r" (temp), "+m" (*ptr)
: : "memory");
: "+r"(temp), "+m"(*ptr)
:
: "memory");
// temp now contains the previous value of *ptr
return temp + increment;
}
@ -183,8 +185,9 @@ inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
Atomic64 temp = increment;
__asm__ __volatile__("lock; xaddq %0,%1"
: "+r" (temp), "+m" (*ptr)
: : "memory");
: "+r"(temp), "+m"(*ptr)
:
: "memory");
// temp now contains the previous value of *ptr
if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {
__asm__ __volatile__("lfence" : : : "memory");
@ -204,9 +207,9 @@ inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
ATOMICOPS_COMPILER_BARRIER();
*ptr = value; // An x86 store acts as a release barrier
// for current AMD/Intel chips as of Jan 2008.
// See also Acquire_Load(), below.
*ptr = value; // An x86 store acts as a release barrier
// for current AMD/Intel chips as of Jan 2008.
// See also Acquire_Load(), below.
// When new chips come out, check:
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
@ -227,9 +230,9 @@ inline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {
}
inline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {
Atomic64 value = *ptr; // An x86 load acts as a acquire barrier,
// for current AMD/Intel chips as of Jan 2008.
// See also Release_Store(), above.
Atomic64 value = *ptr; // An x86 load acts as a acquire barrier,
// for current AMD/Intel chips as of Jan 2008.
// See also Release_Store(), above.
ATOMICOPS_COMPILER_BARRIER();
return value;
}
@ -257,8 +260,8 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
#endif // defined(__x86_64__)
} // namespace base::subtle
} // namespace base
} // namespace base::subtle
} // namespace base
#undef ATOMICOPS_COMPILER_BARRIER

View File

@ -55,25 +55,23 @@ inline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value,
Atomic32 new_value) {
LONG result = _InterlockedCompareExchange(
reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(new_value),
reinterpret_cast<volatile LONG*>(ptr), static_cast<LONG>(new_value),
static_cast<LONG>(old_value));
return static_cast<Atomic32>(result);
}
inline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,
Atomic32 new_value) {
LONG result = _InterlockedExchange(
reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(new_value));
LONG result = _InterlockedExchange(reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(new_value));
return static_cast<Atomic32>(result);
}
inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
Atomic32 increment) {
return _InterlockedExchangeAdd(
reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(increment)) + increment;
return _InterlockedExchangeAdd(reinterpret_cast<volatile LONG*>(ptr),
static_cast<LONG>(increment)) +
increment;
}
inline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,
@ -112,11 +110,11 @@ inline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {
inline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {
NoBarrier_AtomicExchange(ptr, value);
// acts as a barrier in this implementation
// acts as a barrier in this implementation
}
inline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
// See comments in Atomic64 version of Release_Store() below.
}
@ -144,24 +142,24 @@ inline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,
Atomic64 old_value,
Atomic64 new_value) {
PVOID result = InterlockedCompareExchangePointer(
reinterpret_cast<volatile PVOID*>(ptr),
reinterpret_cast<PVOID>(new_value), reinterpret_cast<PVOID>(old_value));
reinterpret_cast<volatile PVOID*>(ptr),
reinterpret_cast<PVOID>(new_value), reinterpret_cast<PVOID>(old_value));
return reinterpret_cast<Atomic64>(result);
}
inline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,
Atomic64 new_value) {
PVOID result = InterlockedExchangePointer(
reinterpret_cast<volatile PVOID*>(ptr),
reinterpret_cast<PVOID>(new_value));
PVOID result =
InterlockedExchangePointer(reinterpret_cast<volatile PVOID*>(ptr),
reinterpret_cast<PVOID>(new_value));
return reinterpret_cast<Atomic64>(result);
}
inline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,
Atomic64 increment) {
return InterlockedExchangeAdd64(
reinterpret_cast<volatile LONGLONG*>(ptr),
static_cast<LONGLONG>(increment)) + increment;
return InterlockedExchangeAdd64(reinterpret_cast<volatile LONGLONG*>(ptr),
static_cast<LONGLONG>(increment)) +
increment;
}
inline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,
@ -175,11 +173,11 @@ inline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {
inline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {
NoBarrier_AtomicExchange(ptr, value);
// acts as a barrier in this implementation
// acts as a barrier in this implementation
}
inline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
*ptr = value; // works w/o barrier for current Intel chips as of June 2005
// When new chips come out, check:
// IA-32 Intel Architecture Software Developer's Manual, Volume 3:
@ -215,7 +213,6 @@ inline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,
return NoBarrier_CompareAndSwap(ptr, old_value, new_value);
}
#endif // defined(_WIN64)
} // namespace base::subtle

File diff suppressed because it is too large Load Diff

View File

@ -48,338 +48,344 @@ class RunnableAdapter;
// __stdcall Function: Arity 0.
template <typename R>
class RunnableAdapter<R(__stdcall *)()> {
class RunnableAdapter<R(__stdcall*)()> {
public:
typedef R (RunType)();
typedef R(RunType)();
explicit RunnableAdapter(R(__stdcall *function)())
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)()) : function_(function) {}
R Run() {
return function_();
}
R Run() { return function_(); }
private:
R (__stdcall *function_)();
R(__stdcall* function_)();
};
// __fastcall Function: Arity 0.
template <typename R>
class RunnableAdapter<R(__fastcall *)()> {
class RunnableAdapter<R(__fastcall*)()> {
public:
typedef R (RunType)();
typedef R(RunType)();
explicit RunnableAdapter(R(__fastcall *function)())
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)()) : function_(function) {}
R Run() {
return function_();
}
R Run() { return function_(); }
private:
R (__fastcall *function_)();
R(__fastcall* function_)();
};
// __stdcall Function: Arity 1.
template <typename R, typename A1>
class RunnableAdapter<R(__stdcall *)(A1)> {
class RunnableAdapter<R(__stdcall*)(A1)> {
public:
typedef R (RunType)(A1);
typedef R(RunType)(A1);
explicit RunnableAdapter(R(__stdcall *function)(A1))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1)) : function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
return function_(a1);
}
private:
R (__stdcall *function_)(A1);
R(__stdcall* function_)(A1);
};
// __fastcall Function: Arity 1.
template <typename R, typename A1>
class RunnableAdapter<R(__fastcall *)(A1)> {
class RunnableAdapter<R(__fastcall*)(A1)> {
public:
typedef R (RunType)(A1);
typedef R(RunType)(A1);
explicit RunnableAdapter(R(__fastcall *function)(A1))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1)) : function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1) {
return function_(a1);
}
private:
R (__fastcall *function_)(A1);
R(__fastcall* function_)(A1);
};
// __stdcall Function: Arity 2.
template <typename R, typename A1, typename A2>
class RunnableAdapter<R(__stdcall *)(A1, A2)> {
class RunnableAdapter<R(__stdcall*)(A1, A2)> {
public:
typedef R (RunType)(A1, A2);
typedef R(RunType)(A1, A2);
explicit RunnableAdapter(R(__stdcall *function)(A1, A2))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1, A2))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2) {
typename CallbackParamTraits<A2>::ForwardType a2) {
return function_(a1, a2);
}
private:
R (__stdcall *function_)(A1, A2);
R(__stdcall* function_)(A1, A2);
};
// __fastcall Function: Arity 2.
template <typename R, typename A1, typename A2>
class RunnableAdapter<R(__fastcall *)(A1, A2)> {
class RunnableAdapter<R(__fastcall*)(A1, A2)> {
public:
typedef R (RunType)(A1, A2);
typedef R(RunType)(A1, A2);
explicit RunnableAdapter(R(__fastcall *function)(A1, A2))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1, A2))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2) {
typename CallbackParamTraits<A2>::ForwardType a2) {
return function_(a1, a2);
}
private:
R (__fastcall *function_)(A1, A2);
R(__fastcall* function_)(A1, A2);
};
// __stdcall Function: Arity 3.
template <typename R, typename A1, typename A2, typename A3>
class RunnableAdapter<R(__stdcall *)(A1, A2, A3)> {
class RunnableAdapter<R(__stdcall*)(A1, A2, A3)> {
public:
typedef R (RunType)(A1, A2, A3);
typedef R(RunType)(A1, A2, A3);
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3) {
return function_(a1, a2, a3);
}
private:
R (__stdcall *function_)(A1, A2, A3);
R(__stdcall* function_)(A1, A2, A3);
};
// __fastcall Function: Arity 3.
template <typename R, typename A1, typename A2, typename A3>
class RunnableAdapter<R(__fastcall *)(A1, A2, A3)> {
class RunnableAdapter<R(__fastcall*)(A1, A2, A3)> {
public:
typedef R (RunType)(A1, A2, A3);
typedef R(RunType)(A1, A2, A3);
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3) {
return function_(a1, a2, a3);
}
private:
R (__fastcall *function_)(A1, A2, A3);
R(__fastcall* function_)(A1, A2, A3);
};
// __stdcall Function: Arity 4.
template <typename R, typename A1, typename A2, typename A3, typename A4>
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4)> {
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4)> {
public:
typedef R (RunType)(A1, A2, A3, A4);
typedef R(RunType)(A1, A2, A3, A4);
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4) {
return function_(a1, a2, a3, a4);
}
private:
R (__stdcall *function_)(A1, A2, A3, A4);
R(__stdcall* function_)(A1, A2, A3, A4);
};
// __fastcall Function: Arity 4.
template <typename R, typename A1, typename A2, typename A3, typename A4>
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4)> {
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4)> {
public:
typedef R (RunType)(A1, A2, A3, A4);
typedef R(RunType)(A1, A2, A3, A4);
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4) {
return function_(a1, a2, a3, a4);
}
private:
R (__fastcall *function_)(A1, A2, A3, A4);
R(__fastcall* function_)(A1, A2, A3, A4);
};
// __stdcall Function: Arity 5.
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5>
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4, A5)> {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4, A5)> {
public:
typedef R (RunType)(A1, A2, A3, A4, A5);
typedef R(RunType)(A1, A2, A3, A4, A5);
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5) {
return function_(a1, a2, a3, a4, a5);
}
private:
R (__stdcall *function_)(A1, A2, A3, A4, A5);
R(__stdcall* function_)(A1, A2, A3, A4, A5);
};
// __fastcall Function: Arity 5.
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5>
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4, A5)> {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5>
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4, A5)> {
public:
typedef R (RunType)(A1, A2, A3, A4, A5);
typedef R(RunType)(A1, A2, A3, A4, A5);
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5) {
return function_(a1, a2, a3, a4, a5);
}
private:
R (__fastcall *function_)(A1, A2, A3, A4, A5);
R(__fastcall* function_)(A1, A2, A3, A4, A5);
};
// __stdcall Function: Arity 6.
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4, A5, A6)> {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4, A5, A6)> {
public:
typedef R (RunType)(A1, A2, A3, A4, A5, A6);
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5, A6))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6) {
return function_(a1, a2, a3, a4, a5, a6);
}
private:
R (__stdcall *function_)(A1, A2, A3, A4, A5, A6);
R(__stdcall* function_)(A1, A2, A3, A4, A5, A6);
};
// __fastcall Function: Arity 6.
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6>
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4, A5, A6)> {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6>
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4, A5, A6)> {
public:
typedef R (RunType)(A1, A2, A3, A4, A5, A6);
typedef R(RunType)(A1, A2, A3, A4, A5, A6);
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5, A6))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6) {
return function_(a1, a2, a3, a4, a5, a6);
}
private:
R (__fastcall *function_)(A1, A2, A3, A4, A5, A6);
R(__fastcall* function_)(A1, A2, A3, A4, A5, A6);
};
// __stdcall Function: Arity 7.
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
class RunnableAdapter<R(__stdcall *)(A1, A2, A3, A4, A5, A6, A7)> {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
class RunnableAdapter<R(__stdcall*)(A1, A2, A3, A4, A5, A6, A7)> {
public:
typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
explicit RunnableAdapter(R(__stdcall *function)(A1, A2, A3, A4, A5, A6, A7))
: function_(function) {
}
explicit RunnableAdapter(R(__stdcall* function)(A1, A2, A3, A4, A5, A6, A7))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6,
typename CallbackParamTraits<A7>::ForwardType a7) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6,
typename CallbackParamTraits<A7>::ForwardType a7) {
return function_(a1, a2, a3, a4, a5, a6, a7);
}
private:
R (__stdcall *function_)(A1, A2, A3, A4, A5, A6, A7);
R(__stdcall* function_)(A1, A2, A3, A4, A5, A6, A7);
};
// __fastcall Function: Arity 7.
template <typename R, typename A1, typename A2, typename A3, typename A4,
typename A5, typename A6, typename A7>
class RunnableAdapter<R(__fastcall *)(A1, A2, A3, A4, A5, A6, A7)> {
template <typename R,
typename A1,
typename A2,
typename A3,
typename A4,
typename A5,
typename A6,
typename A7>
class RunnableAdapter<R(__fastcall*)(A1, A2, A3, A4, A5, A6, A7)> {
public:
typedef R (RunType)(A1, A2, A3, A4, A5, A6, A7);
typedef R(RunType)(A1, A2, A3, A4, A5, A6, A7);
explicit RunnableAdapter(R(__fastcall *function)(A1, A2, A3, A4, A5, A6, A7))
: function_(function) {
}
explicit RunnableAdapter(R(__fastcall* function)(A1, A2, A3, A4, A5, A6, A7))
: function_(function) {}
R Run(typename CallbackParamTraits<A1>::ForwardType a1,
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6,
typename CallbackParamTraits<A7>::ForwardType a7) {
typename CallbackParamTraits<A2>::ForwardType a2,
typename CallbackParamTraits<A3>::ForwardType a3,
typename CallbackParamTraits<A4>::ForwardType a4,
typename CallbackParamTraits<A5>::ForwardType a5,
typename CallbackParamTraits<A6>::ForwardType a6,
typename CallbackParamTraits<A7>::ForwardType a7) {
return function_(a1, a2, a3, a4, a5, a6, a7);
}
private:
R (__fastcall *function_)(A1, A2, A3, A4, A5, A6, A7);
R(__fastcall* function_)(A1, A2, A3, A4, A5, A6, A7);
};
} // namespace cef_internal

View File

@ -92,7 +92,7 @@ class CallbackBase {
// another type. It is not okay to use void*. We create a InvokeFuncStorage
// that that can store our function pointer, and then cast it back to
// the original type on usage.
typedef void(*InvokeFuncStorage)(void);
typedef void (*InvokeFuncStorage)(void);
// Returns true if this callback equals |other|. |other| may be null.
bool Equals(const CallbackBase& other) const;
@ -115,15 +115,16 @@ class CallbackBase {
// A helper template to determine if given type is non-const move-only-type,
// i.e. if a value of the given type should be passed via .Pass() in a
// destructive way.
template <typename T> struct IsMoveOnlyType {
template <typename T>
struct IsMoveOnlyType {
template <typename U>
static YesType Test(const typename U::MoveOnlyTypeForCPP03*);
template <typename U>
static NoType Test(...);
static const bool value = sizeof(Test<T>(0)) == sizeof(YesType) &&
!is_const<T>::value;
static const bool value =
sizeof(Test<T>(0)) == sizeof(YesType) && !is_const<T>::value;
};
// This is a typetraits object that's used to take an argument type, and

View File

@ -51,9 +51,7 @@ namespace cef_internal {
template <typename T>
struct NeedsScopedRefptrButGetsRawPtr {
#if defined(OS_WIN)
enum {
value = base::false_type::value
};
enum { value = base::false_type::value };
#else
enum {
// Human readable translation: you needed to be a scoped_refptr if you are a
@ -77,74 +75,103 @@ struct ParamsUseScopedRefptrCorrectly<Tuple0> {
};
template <typename A>
struct ParamsUseScopedRefptrCorrectly<Tuple1<A> > {
struct ParamsUseScopedRefptrCorrectly<Tuple1<A>> {
enum { value = !NeedsScopedRefptrButGetsRawPtr<A>::value };
};
template <typename A, typename B>
struct ParamsUseScopedRefptrCorrectly<Tuple2<A, B> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value) };
struct ParamsUseScopedRefptrCorrectly<Tuple2<A, B>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value)
};
};
template <typename A, typename B, typename C>
struct ParamsUseScopedRefptrCorrectly<Tuple3<A, B, C> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value) };
struct ParamsUseScopedRefptrCorrectly<Tuple3<A, B, C>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value)
};
};
template <typename A, typename B, typename C, typename D>
struct ParamsUseScopedRefptrCorrectly<Tuple4<A, B, C, D> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value) };
struct ParamsUseScopedRefptrCorrectly<Tuple4<A, B, C, D>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value)
};
};
template <typename A, typename B, typename C, typename D, typename E>
struct ParamsUseScopedRefptrCorrectly<Tuple5<A, B, C, D, E> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value) };
struct ParamsUseScopedRefptrCorrectly<Tuple5<A, B, C, D, E>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value)
};
};
template <typename A, typename B, typename C, typename D, typename E,
template <typename A,
typename B,
typename C,
typename D,
typename E,
typename F>
struct ParamsUseScopedRefptrCorrectly<Tuple6<A, B, C, D, E, F> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
NeedsScopedRefptrButGetsRawPtr<F>::value) };
struct ParamsUseScopedRefptrCorrectly<Tuple6<A, B, C, D, E, F>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
NeedsScopedRefptrButGetsRawPtr<F>::value)
};
};
template <typename A, typename B, typename C, typename D, typename E,
typename F, typename G>
struct ParamsUseScopedRefptrCorrectly<Tuple7<A, B, C, D, E, F, G> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
NeedsScopedRefptrButGetsRawPtr<F>::value ||
NeedsScopedRefptrButGetsRawPtr<G>::value) };
template <typename A,
typename B,
typename C,
typename D,
typename E,
typename F,
typename G>
struct ParamsUseScopedRefptrCorrectly<Tuple7<A, B, C, D, E, F, G>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
NeedsScopedRefptrButGetsRawPtr<F>::value ||
NeedsScopedRefptrButGetsRawPtr<G>::value)
};
};
template <typename A, typename B, typename C, typename D, typename E,
typename F, typename G, typename H>
struct ParamsUseScopedRefptrCorrectly<Tuple8<A, B, C, D, E, F, G, H> > {
enum { value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
NeedsScopedRefptrButGetsRawPtr<F>::value ||
NeedsScopedRefptrButGetsRawPtr<G>::value ||
NeedsScopedRefptrButGetsRawPtr<H>::value) };
template <typename A,
typename B,
typename C,
typename D,
typename E,
typename F,
typename G,
typename H>
struct ParamsUseScopedRefptrCorrectly<Tuple8<A, B, C, D, E, F, G, H>> {
enum {
value = !(NeedsScopedRefptrButGetsRawPtr<A>::value ||
NeedsScopedRefptrButGetsRawPtr<B>::value ||
NeedsScopedRefptrButGetsRawPtr<C>::value ||
NeedsScopedRefptrButGetsRawPtr<D>::value ||
NeedsScopedRefptrButGetsRawPtr<E>::value ||
NeedsScopedRefptrButGetsRawPtr<F>::value ||
NeedsScopedRefptrButGetsRawPtr<G>::value ||
NeedsScopedRefptrButGetsRawPtr<H>::value)
};
};
} // namespace cef_internal