| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 691a0f6 commit 9306e89
145 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,14 +39,49 @@ | |||
| 39 | 39 | #define CEF_INCLUDE_BASE_CEF_ATOMIC_REF_COUNT_H_ | |
| 40 | 40 | #pragma once | |
| 41 | 41 | ||
| 42 | - #if defined(BASE_ATOMIC_REF_COUNT_H_) | ||
| 43 | - // Do nothing if the Chromium header has already been included. | ||
| 44 | - // This can happen in cases where Chromium code is used directly by the | ||
| 45 | - // client application. When using Chromium code directly always include | ||
| 46 | - // the Chromium header first to avoid type conflicts. | ||
| 47 | - #elif defined(USING_CHROMIUM_INCLUDES) | ||
| 42 | + #if defined(USING_CHROMIUM_INCLUDES) | ||
| 48 | 43 | // When building CEF include the Chromium header directly. | |
| 49 | 44 | #include "base/atomic_ref_count.h" | |
| 45 | + | ||
| 46 | + // Used when declaring a base::AtomicRefCount value. This is an object type with | ||
| 47 | + // Chromium headers. | ||
| 48 | + #define ATOMIC_DECLARATION (0) | ||
| 49 | + | ||
| 50 | + // Maintaining compatibility with AtompicRefCount* functions that were removed | ||
| 51 | + // from Chromium in http://crrev.com/ee96d561. | ||
| 52 | + namespace base { | ||
| 53 | + | ||
| 54 | + // Increment a reference count by 1. | ||
| 55 | + inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { | ||
| 56 | + const_cast<AtomicRefCount*>(ptr)->Increment(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + // Decrement a reference count by 1 and return whether the result is non-zero. | ||
| 60 | + // Insert barriers to ensure that state written before the reference count | ||
| 61 | + // became zero will be visible to a thread that has just made the count zero. | ||
| 62 | + inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { | ||
| 63 | + return const_cast<AtomicRefCount*>(ptr)->Decrement(); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + // Return whether the reference count is one. If the reference count is used | ||
| 67 | + // in the conventional way, a refrerence count of 1 implies that the current | ||
| 68 | + // thread owns the reference and no other thread shares it. This call performs | ||
| 69 | + // the test for a reference count of one, and performs the memory barrier | ||
| 70 | + // needed for the owning thread to act on the object, knowing that it has | ||
| 71 | + // exclusive access to the object. | ||
| 72 | + inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { | ||
| 73 | + return const_cast<AtomicRefCount*>(ptr)->IsOne(); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + // Return whether the reference count is zero. With conventional object | ||
| 77 | + // referencing counting, the object will be destroyed, so the reference count | ||
| 78 | + // should never be zero. Hence this is generally used for a debug check. | ||
| 79 | + inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { | ||
| 80 | + return const_cast<AtomicRefCount*>(ptr)->IsZero(); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + } // namespace base | ||
| 84 | + | ||
| 50 | 85 | #else // !USING_CHROMIUM_INCLUDES | |
| 51 | 86 | // The following is substantially similar to the Chromium implementation. | |
| 52 | 87 | // If the Chromium implementation diverges the below implementation should be | |
@@ -56,14 +91,18 @@ | |||
| 56 | 91 | ||
| 57 | 92 | // Annotations are not currently supported. | |
| 58 | 93 | #define ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ | |
| 59 | - #define ANNOTATE_HAPPENS_AFTER(obj) /* empty */ | ||
| 94 | + #define ANNOTATE_HAPPENS_AFTER(obj) /* empty */ | ||
| 95 | + | ||
| 96 | + // Used when declaring a base::AtomicRefCount value. This is an integer/ptr type | ||
| 97 | + // with CEF headers. | ||
| 98 | + #define ATOMIC_DECLARATION = 0 | ||
| 60 | 99 | ||
| 61 | 100 | namespace base { | |
| 62 | 101 | ||
| 63 | 102 | typedef subtle::Atomic32 AtomicRefCount; | |
| 64 | 103 | ||
| 65 | 104 | // Increment a reference count by "increment", which must exceed 0. | |
| 66 | - inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, | ||
| 105 | + inline void AtomicRefCountIncN(volatile AtomicRefCount* ptr, | ||
| 67 | 106 | AtomicRefCount increment) { | |
| 68 | 107 | subtle::NoBarrier_AtomicIncrement(ptr, increment); | |
| 69 | 108 | } | |
@@ -72,7 +111,7 @@ inline void AtomicRefCountIncN(volatile AtomicRefCount *ptr, | |||
| 72 | 111 | // and return whether the result is non-zero. | |
| 73 | 112 | // Insert barriers to ensure that state written before the reference count | |
| 74 | 113 | // became zero will be visible to a thread that has just made the count zero. | |
| 75 | - inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr, | ||
| 114 | + inline bool AtomicRefCountDecN(volatile AtomicRefCount* ptr, | ||
| 76 | 115 | AtomicRefCount decrement) { | |
| 77 | 116 | ANNOTATE_HAPPENS_BEFORE(ptr); | |
| 78 | 117 | bool res = (subtle::Barrier_AtomicIncrement(ptr, -decrement) != 0); | |
@@ -83,14 +122,14 @@ inline bool AtomicRefCountDecN(volatile AtomicRefCount *ptr, | |||
| 83 | 122 | } | |
| 84 | 123 | ||
| 85 | 124 | // Increment a reference count by 1. | |
| 86 | - inline void AtomicRefCountInc(volatile AtomicRefCount *ptr) { | ||
| 125 | + inline void AtomicRefCountInc(volatile AtomicRefCount* ptr) { | ||
| 87 | 126 | base::AtomicRefCountIncN(ptr, 1); | |
| 88 | 127 | } | |
| 89 | 128 | ||
| 90 | 129 | // Decrement a reference count by 1 and return whether the result is non-zero. | |
| 91 | 130 | // Insert barriers to ensure that state written before the reference count | |
| 92 | 131 | // became zero will be visible to a thread that has just made the count zero. | |
| 93 | - inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) { | ||
| 132 | + inline bool AtomicRefCountDec(volatile AtomicRefCount* ptr) { | ||
| 94 | 133 | return base::AtomicRefCountDecN(ptr, 1); | |
| 95 | 134 | } | |
| 96 | 135 | ||
@@ -100,7 +139,7 @@ inline bool AtomicRefCountDec(volatile AtomicRefCount *ptr) { | |||
| 100 | 139 | // the test for a reference count of one, and performs the memory barrier | |
| 101 | 140 | // needed for the owning thread to act on the object, knowing that it has | |
| 102 | 141 | // exclusive access to the object. | |
| 103 | - inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) { | ||
| 142 | + inline bool AtomicRefCountIsOne(volatile AtomicRefCount* ptr) { | ||
| 104 | 143 | bool res = (subtle::Acquire_Load(ptr) == 1); | |
| 105 | 144 | if (res) { | |
| 106 | 145 | ANNOTATE_HAPPENS_AFTER(ptr); | |
@@ -111,7 +150,7 @@ inline bool AtomicRefCountIsOne(volatile AtomicRefCount *ptr) { | |||
| 111 | 150 | // Return whether the reference count is zero. With conventional object | |
| 112 | 151 | // referencing counting, the object will be destroyed, so the reference count | |
| 113 | 152 | // should never be zero. Hence this is generally used for a debug check. | |
| 114 | - inline bool AtomicRefCountIsZero(volatile AtomicRefCount *ptr) { | ||
| 153 | + inline bool AtomicRefCountIsZero(volatile AtomicRefCount* ptr) { | ||
| 115 | 154 | bool res = (subtle::Acquire_Load(ptr) == 0); | |
| 116 | 155 | if (res) { | |
| 117 | 156 | ANNOTATE_HAPPENS_AFTER(ptr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -122,8 +122,7 @@ Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value); | |||
| 122 | 122 | // *ptr with the increment applied. This routine implies no memory barriers. | |
| 123 | 123 | Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); | |
| 124 | 124 | ||
| 125 | - Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, | ||
| 126 | - Atomic32 increment); | ||
| 125 | + Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment); | ||
| 127 | 126 | ||
| 128 | 127 | // These following lower-level operations are typically useful only to people | |
| 129 | 128 | // implementing higher-level synchronization operations like spinlocks, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,8 +32,8 @@ | |||
| 32 | 32 | #define CEF_INCLUDE_BASE_CEF_BASICTYPES_H_ | |
| 33 | 33 | #pragma once | |
| 34 | 34 | ||
| 35 | - #include <limits.h> // For UINT_MAX | ||
| 36 | - #include <stddef.h> // For size_t | ||
| 35 | + #include <limits.h> // For UINT_MAX | ||
| 36 | + #include <stddef.h> // For size_t | ||
| 37 | 37 | ||
| 38 | 38 | #include "include/base/cef_build.h" | |
| 39 | 39 | ||
@@ -43,34 +43,44 @@ | |||
| 43 | 43 | // On Mac OS X, |long long| is used for 64-bit types for compatibility with | |
| 44 | 44 | // <inttypes.h> format macros even in the LP64 model. | |
| 45 | 45 | #if defined(__LP64__) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) | |
| 46 | - typedef long int64; // NOLINT(runtime/int) | ||
| 47 | - typedef unsigned long uint64; // NOLINT(runtime/int) | ||
| 46 | + typedef long int64; | ||
| 47 | + typedef unsigned long uint64; | ||
| 48 | 48 | #else | |
| 49 | - typedef long long int64; // NOLINT(runtime/int) | ||
| 50 | - typedef unsigned long long uint64; // NOLINT(runtime/int) | ||
| 49 | + typedef long long int64; | ||
| 50 | + typedef unsigned long long uint64; | ||
| 51 | 51 | #endif | |
| 52 | 52 | ||
| 53 | 53 | // TODO: Remove these type guards. These are to avoid conflicts with | |
| 54 | 54 | // obsolete/protypes.h in the Gecko SDK. | |
| 55 | 55 | #ifndef _INT32 | |
| 56 | 56 | #define _INT32 | |
| 57 | - typedef int int32; | ||
| 57 | + typedef int int32; | ||
| 58 | 58 | #endif | |
| 59 | 59 | ||
| 60 | 60 | // TODO: Remove these type guards. These are to avoid conflicts with | |
| 61 | 61 | // obsolete/protypes.h in the Gecko SDK. | |
| 62 | 62 | #ifndef _UINT32 | |
| 63 | 63 | #define _UINT32 | |
| 64 | - typedef unsigned int uint32; | ||
| 64 | + typedef unsigned int uint32; | ||
| 65 | + #endif | ||
| 66 | + | ||
| 67 | + #ifndef _INT16 | ||
| 68 | + #define _INT16 | ||
| 69 | + typedef short int16; | ||
| 70 | + #endif | ||
| 71 | + | ||
| 72 | + #ifndef _UINT16 | ||
| 73 | + #define _UINT16 | ||
| 74 | + typedef unsigned short uint16; | ||
| 65 | 75 | #endif | |
| 66 | 76 | ||
| 67 | 77 | // UTF-16 character type. | |
| 68 | 78 | // This should be kept synchronized with base/strings/string16.h | |
| 69 | 79 | #ifndef char16 | |
| 70 | 80 | #if defined(WCHAR_T_IS_UTF16) | |
| 71 | - typedef wchar_t char16; | ||
| 81 | + typedef wchar_t char16; | ||
| 72 | 82 | #elif defined(WCHAR_T_IS_UTF32) | |
| 73 | - typedef unsigned short char16; | ||
| 83 | + typedef unsigned short char16; | ||
| 74 | 84 | #endif | |
| 75 | 85 | #endif | |
| 76 | 86 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments