diff options
author | danakj <danakj@chromium.org> | 2015-01-08 15:35:58 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-08 23:37:17 +0000 |
commit | e649f573a38b00bb20fe0925098251a4ff184566 (patch) | |
tree | 6f400822726e85def4cad5a1ee704e232a6364ad /base/memory | |
parent | 95bc5b1779dcf8e4a9e37ef600c0ea76293307e3 (diff) | |
download | chromium_src-e649f573a38b00bb20fe0925098251a4ff184566.zip chromium_src-e649f573a38b00bb20fe0925098251a4ff184566.tar.gz chromium_src-e649f573a38b00bb20fe0925098251a4ff184566.tar.bz2 |
base: Change DCHECK_IS_ON to a macro DCHECK_IS_ON().
This ensures that if the header is not included, and a DCHECK is guarded
by this check, that the file will fail to compile instead of silently
compiling the DCHECK out.
For example:
#if DCHECK_IS_ON
DCHECK(SomeThing());
#endif
This example would be compiled out if DCHECK_IS_ON was not defined due
to not including the logging.h header.
Instead, this will fail to compile:
#if DCHECK_IS_ON()
DCHECK(SomeThing());
#endif
R=thakis@chromium.org
Review URL: https://codereview.chromium.org/842523002
Cr-Commit-Position: refs/heads/master@{#310626}
Diffstat (limited to 'base/memory')
-rw-r--r-- | base/memory/discardable_shared_memory.cc | 8 | ||||
-rw-r--r-- | base/memory/discardable_shared_memory.h | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/base/memory/discardable_shared_memory.cc b/base/memory/discardable_shared_memory.cc index 82bc983..e04377e 100644 --- a/base/memory/discardable_shared_memory.cc +++ b/base/memory/discardable_shared_memory.cc @@ -129,7 +129,7 @@ bool DiscardableSharedMemory::CreateAndMap(size_t size) { shared_memory_.mapped_size() - AlignToPageSize(sizeof(SharedState)); locked_page_count_ = AlignToPageSize(mapped_size_) / base::GetPageSize(); -#if DCHECK_IS_ON +#if DCHECK_IS_ON() for (size_t page = 0; page < locked_page_count_; ++page) locked_pages_.insert(page); #endif @@ -149,7 +149,7 @@ bool DiscardableSharedMemory::Map(size_t size) { shared_memory_.mapped_size() - AlignToPageSize(sizeof(SharedState)); locked_page_count_ = AlignToPageSize(mapped_size_) / base::GetPageSize(); -#if DCHECK_IS_ON +#if DCHECK_IS_ON() for (size_t page = 0; page < locked_page_count_; ++page) locked_pages_.insert(page); #endif @@ -200,7 +200,7 @@ bool DiscardableSharedMemory::Lock(size_t offset, size_t length) { // Add pages to |locked_page_count_|. // Note: Locking a page that is already locked is an error. locked_page_count_ += end - start; -#if DCHECK_IS_ON +#if DCHECK_IS_ON() // Detect incorrect usage by keeping track of exactly what pages are locked. for (auto page = start; page < end; ++page) { auto result = locked_pages_.insert(page); @@ -252,7 +252,7 @@ void DiscardableSharedMemory::Unlock(size_t offset, size_t length) { // Note: Unlocking a page that is not locked is an error. DCHECK_GE(locked_page_count_, end - start); locked_page_count_ -= end - start; -#if DCHECK_IS_ON +#if DCHECK_IS_ON() // Detect incorrect usage by keeping track of exactly what pages are locked. for (auto page = start; page < end; ++page) { auto erased_count = locked_pages_.erase(page); diff --git a/base/memory/discardable_shared_memory.h b/base/memory/discardable_shared_memory.h index c69c970..abee868 100644 --- a/base/memory/discardable_shared_memory.h +++ b/base/memory/discardable_shared_memory.h @@ -11,7 +11,7 @@ #include "base/threading/thread_collision_warner.h" #include "base/time/time.h" -#if DCHECK_IS_ON +#if DCHECK_IS_ON() #include <set> #endif @@ -119,7 +119,7 @@ class BASE_EXPORT DiscardableSharedMemory { SharedMemory shared_memory_; size_t mapped_size_; size_t locked_page_count_; -#if DCHECK_IS_ON +#if DCHECK_IS_ON() std::set<size_t> locked_pages_; #endif // Implementation is not thread-safe but still usable if clients are |