diff options
Diffstat (limited to 'chromium/base/containers')
-rw-r--r-- | chromium/base/containers/adapters.h | 5 | ||||
-rw-r--r-- | chromium/base/containers/checked_iterators.h | 2 | ||||
-rw-r--r-- | chromium/base/containers/circular_deque.h | 2 | ||||
-rw-r--r-- | chromium/base/containers/flat_map.h | 4 | ||||
-rw-r--r-- | chromium/base/containers/flat_tree.h | 7 | ||||
-rw-r--r-- | chromium/base/containers/flat_tree_unittest.cc | 5 | ||||
-rw-r--r-- | chromium/base/containers/id_map.h | 9 | ||||
-rw-r--r-- | chromium/base/containers/intrusive_heap.h | 2 | ||||
-rw-r--r-- | chromium/base/containers/linked_list.h | 11 | ||||
-rw-r--r-- | chromium/base/containers/mru_cache.h | 22 | ||||
-rw-r--r-- | chromium/base/containers/mru_cache_unittest.cc | 8 | ||||
-rw-r--r-- | chromium/base/containers/ring_buffer.h | 7 | ||||
-rw-r--r-- | chromium/base/containers/small_map.h | 2 | ||||
-rw-r--r-- | chromium/base/containers/span.h | 2 | ||||
-rw-r--r-- | chromium/base/containers/stack_container.h | 14 | ||||
-rw-r--r-- | chromium/base/containers/stack_container_unittest.cc | 20 | ||||
-rw-r--r-- | chromium/base/containers/vector_buffer.h | 14 |
17 files changed, 66 insertions, 70 deletions
diff --git a/chromium/base/containers/adapters.h b/chromium/base/containers/adapters.h index ec33481752f..ae22de2b473 100644 --- a/chromium/base/containers/adapters.h +++ b/chromium/base/containers/adapters.h @@ -10,8 +10,6 @@ #include <iterator> #include <utility> -#include "base/macros.h" - namespace base { namespace internal { @@ -24,14 +22,13 @@ class ReversedAdapter { explicit ReversedAdapter(T& t) : t_(t) {} ReversedAdapter(const ReversedAdapter& ra) : t_(ra.t_) {} + ReversedAdapter& operator=(const ReversedAdapter&) = delete; Iterator begin() const { return std::rbegin(t_); } Iterator end() const { return std::rend(t_); } private: T& t_; - - DISALLOW_ASSIGN(ReversedAdapter); }; } // namespace internal diff --git a/chromium/base/containers/checked_iterators.h b/chromium/base/containers/checked_iterators.h index 986f6fad102..ce3fcfc0322 100644 --- a/chromium/base/containers/checked_iterators.h +++ b/chromium/base/containers/checked_iterators.h @@ -9,8 +9,8 @@ #include <memory> #include <type_traits> +#include "base/check_op.h" #include "base/containers/util.h" -#include "base/logging.h" namespace base { diff --git a/chromium/base/containers/circular_deque.h b/chromium/base/containers/circular_deque.h index 6c2c3a885a6..4fc61c2346b 100644 --- a/chromium/base/containers/circular_deque.h +++ b/chromium/base/containers/circular_deque.h @@ -11,8 +11,8 @@ #include <type_traits> #include <utility> +#include "base/check_op.h" #include "base/containers/vector_buffer.h" -#include "base/logging.h" #include "base/macros.h" #include "base/stl_util.h" #include "base/template_util.h" diff --git a/chromium/base/containers/flat_map.h b/chromium/base/containers/flat_map.h index ed82c5d516c..4a0def5a378 100644 --- a/chromium/base/containers/flat_map.h +++ b/chromium/base/containers/flat_map.h @@ -9,8 +9,8 @@ #include <tuple> #include <utility> +#include "base/check.h" #include "base/containers/flat_tree.h" -#include "base/logging.h" #include "base/template_util.h" namespace base { @@ -202,7 +202,7 @@ class flat_map : public ::base::internal::flat_tree< ~flat_map() = default; flat_map& operator=(const flat_map&) = default; - flat_map& operator=(flat_map&&) = default; + flat_map& operator=(flat_map&&) noexcept = default; // Takes the first if there are duplicates in the initializer list. flat_map& operator=(std::initializer_list<value_type> ilist); diff --git a/chromium/base/containers/flat_tree.h b/chromium/base/containers/flat_tree.h index 9412ff6af74..ce6e92b4d36 100644 --- a/chromium/base/containers/flat_tree.h +++ b/chromium/base/containers/flat_tree.h @@ -125,7 +125,8 @@ class flat_tree { // Assume that move assignment invalidates iterators and references. flat_tree& operator=(const flat_tree&); - flat_tree& operator=(flat_tree&&); + flat_tree& operator=(flat_tree&&) noexcept( + std::is_nothrow_move_assignable<underlying_type>::value); // Takes the first if there are duplicates in the initializer list. flat_tree& operator=(std::initializer_list<value_type> ilist); @@ -518,7 +519,9 @@ auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::operator=( const flat_tree&) -> flat_tree& = default; template <class Key, class Value, class GetKeyFromValue, class KeyCompare> -auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>::operator=(flat_tree &&) +auto flat_tree<Key, Value, GetKeyFromValue, KeyCompare>:: +operator=(flat_tree&&) noexcept( + std::is_nothrow_move_assignable<underlying_type>::value) -> flat_tree& = default; template <class Key, class Value, class GetKeyFromValue, class KeyCompare> diff --git a/chromium/base/containers/flat_tree_unittest.cc b/chromium/base/containers/flat_tree_unittest.cc index ea6af1f76fc..8eab5b6f682 100644 --- a/chromium/base/containers/flat_tree_unittest.cc +++ b/chromium/base/containers/flat_tree_unittest.cc @@ -35,7 +35,6 @@ #include <string> #include <vector> -#include "base/macros.h" #include "base/template_util.h" #include "base/test/move_only_int.h" #include "testing/gmock/include/gmock/gmock.h" @@ -95,6 +94,8 @@ class Emplaceable { other.int_ = 0; other.double_ = 0.0; } + Emplaceable(const Emplaceable&) = delete; + Emplaceable& operator=(const Emplaceable&) = delete; Emplaceable& operator=(Emplaceable&& other) { int_ = other.int_; @@ -115,8 +116,6 @@ class Emplaceable { private: int int_; double double_; - - DISALLOW_COPY_AND_ASSIGN(Emplaceable); }; struct TemplateConstructor { diff --git a/chromium/base/containers/id_map.h b/chromium/base/containers/id_map.h index 4c816da3767..4caf8a2e2d3 100644 --- a/chromium/base/containers/id_map.h +++ b/chromium/base/containers/id_map.h @@ -14,9 +14,9 @@ #include <unordered_map> #include <utility> +#include "base/check_op.h" #include "base/containers/flat_set.h" -#include "base/logging.h" -#include "base/macros.h" +#include "base/notreached.h" #include "base/sequence_checker.h" namespace base { @@ -51,6 +51,9 @@ class IDMap final { DETACH_FROM_SEQUENCE(sequence_checker_); } + IDMap(const IDMap&) = delete; + IDMap& operator=(const IDMap&) = delete; + ~IDMap() { // Many IDMap's are static, and hence will be destroyed on the main // thread. However, all the accesses may take place on another thread (or @@ -281,8 +284,6 @@ class IDMap final { bool check_on_null_data_; SEQUENCE_CHECKER(sequence_checker_); - - DISALLOW_COPY_AND_ASSIGN(IDMap); }; } // namespace base diff --git a/chromium/base/containers/intrusive_heap.h b/chromium/base/containers/intrusive_heap.h index 96ad0b207d0..320eea0f364 100644 --- a/chromium/base/containers/intrusive_heap.h +++ b/chromium/base/containers/intrusive_heap.h @@ -137,7 +137,7 @@ #include <vector> #include "base/base_export.h" -#include "base/logging.h" +#include "base/check_op.h" #include "base/macros.h" #include "base/memory/ptr_util.h" diff --git a/chromium/base/containers/linked_list.h b/chromium/base/containers/linked_list.h index a913badb887..c18bda3268d 100644 --- a/chromium/base/containers/linked_list.h +++ b/chromium/base/containers/linked_list.h @@ -5,8 +5,6 @@ #ifndef BASE_CONTAINERS_LINKED_LIST_H_ #define BASE_CONTAINERS_LINKED_LIST_H_ -#include "base/macros.h" - // Simple LinkedList type. (See the Q&A section to understand how this // differs from std::list). // @@ -102,6 +100,9 @@ class LinkNode { } } + LinkNode(const LinkNode&) = delete; + LinkNode& operator=(const LinkNode&) = delete; + // Insert |this| into the linked list, before |e|. void InsertBefore(LinkNode<T>* e) { this->next_ = e; @@ -148,8 +149,6 @@ class LinkNode { private: LinkNode<T>* previous_; LinkNode<T>* next_; - - DISALLOW_COPY_AND_ASSIGN(LinkNode); }; template <typename T> @@ -159,6 +158,8 @@ class LinkedList { // list (root_.next() will point back to the start of the list, // and root_->previous() wraps around to the end of the list). LinkedList() : root_(&root_, &root_) {} + LinkedList(const LinkedList&) = delete; + LinkedList& operator=(const LinkedList&) = delete; // Appends |e| to the end of the linked list. void Append(LinkNode<T>* e) { @@ -181,8 +182,6 @@ class LinkedList { private: LinkNode<T> root_; - - DISALLOW_COPY_AND_ASSIGN(LinkedList); }; } // namespace base diff --git a/chromium/base/containers/mru_cache.h b/chromium/base/containers/mru_cache.h index 4a9f44e868e..fac49e909af 100644 --- a/chromium/base/containers/mru_cache.h +++ b/chromium/base/containers/mru_cache.h @@ -25,8 +25,7 @@ #include <unordered_map> #include <utility> -#include "base/logging.h" -#include "base/macros.h" +#include "base/check.h" namespace base { namespace trace_event { @@ -82,6 +81,9 @@ class MRUCacheBase { // can pass NO_AUTO_EVICT to not restrict the cache size. explicit MRUCacheBase(size_type max_size) : max_size_(max_size) {} + MRUCacheBase(const MRUCacheBase&) = delete; + MRUCacheBase& operator=(const MRUCacheBase&) = delete; + virtual ~MRUCacheBase() = default; size_type max_size() const { return max_size_; } @@ -211,8 +213,6 @@ class MRUCacheBase { KeyIndex index_; size_type max_size_; - - DISALLOW_COPY_AND_ASSIGN(MRUCacheBase); }; // MRUCache -------------------------------------------------------------------- @@ -230,10 +230,9 @@ class MRUCache : public MRUCacheBase<KeyType, PayloadType, CompareType> { // See MRUCacheBase, noting the possibility of using NO_AUTO_EVICT. explicit MRUCache(typename ParentType::size_type max_size) : ParentType(max_size) {} - virtual ~MRUCache() = default; - - private: - DISALLOW_COPY_AND_ASSIGN(MRUCache); + MRUCache(const MRUCache&) = delete; + MRUCache& operator=(const MRUCache&) = delete; + ~MRUCache() override = default; }; // HashingMRUCache ------------------------------------------------------------ @@ -257,10 +256,9 @@ class HashingMRUCache // See MRUCacheBase, noting the possibility of using NO_AUTO_EVICT. explicit HashingMRUCache(typename ParentType::size_type max_size) : ParentType(max_size) {} - virtual ~HashingMRUCache() = default; - - private: - DISALLOW_COPY_AND_ASSIGN(HashingMRUCache); + HashingMRUCache(const HashingMRUCache&) = delete; + HashingMRUCache& operator=(const HashingMRUCache&) = delete; + ~HashingMRUCache() override = default; }; } // namespace base diff --git a/chromium/base/containers/mru_cache_unittest.cc b/chromium/base/containers/mru_cache_unittest.cc index d4ee4827d56..cd4330e247a 100644 --- a/chromium/base/containers/mru_cache_unittest.cc +++ b/chromium/base/containers/mru_cache_unittest.cc @@ -7,9 +7,13 @@ #include <cstddef> #include <memory> -#include "base/trace_event/memory_usage_estimator.h" +#include "base/tracing_buildflags.h" #include "testing/gtest/include/gtest/gtest.h" +#if BUILDFLAG(ENABLE_BASE_TRACING) +#include "base/trace_event/memory_usage_estimator.h" +#endif // BUILDFLAG(ENABLE_BASE_TRACING) + namespace base { namespace { @@ -380,6 +384,7 @@ TEST(MRUCacheTest, Swap) { } } +#if BUILDFLAG(ENABLE_BASE_TRACING) TEST(MRUCacheTest, EstimateMemory) { base::MRUCache<std::string, int> cache(10); @@ -389,5 +394,6 @@ TEST(MRUCacheTest, EstimateMemory) { EXPECT_GT(trace_event::EstimateMemoryUsage(cache), trace_event::EstimateMemoryUsage(key)); } +#endif // BUILDFLAG(ENABLE_BASE_TRACING) } // namespace base diff --git a/chromium/base/containers/ring_buffer.h b/chromium/base/containers/ring_buffer.h index ca4a48ddc9e..5c4e0aeb1e9 100644 --- a/chromium/base/containers/ring_buffer.h +++ b/chromium/base/containers/ring_buffer.h @@ -7,8 +7,7 @@ #include <stddef.h> -#include "base/logging.h" -#include "base/macros.h" +#include "base/check.h" namespace base { @@ -25,6 +24,8 @@ template <typename T, size_t kSize> class RingBuffer { public: RingBuffer() : current_index_(0) {} + RingBuffer(const RingBuffer&) = delete; + RingBuffer& operator=(const RingBuffer&) = delete; size_t BufferSize() const { return kSize; } @@ -124,8 +125,6 @@ class RingBuffer { T buffer_[kSize]; size_t current_index_; - - DISALLOW_COPY_AND_ASSIGN(RingBuffer); }; } // namespace base diff --git a/chromium/base/containers/small_map.h b/chromium/base/containers/small_map.h index 50ce7646dfe..e4433d3012a 100644 --- a/chromium/base/containers/small_map.h +++ b/chromium/base/containers/small_map.h @@ -14,7 +14,7 @@ #include <unordered_map> #include <utility> -#include "base/logging.h" +#include "base/check_op.h" namespace { constexpr size_t kUsingFullMapSentinel = std::numeric_limits<size_t>::max(); diff --git a/chromium/base/containers/span.h b/chromium/base/containers/span.h index 5aa95aae582..b322c85904d 100644 --- a/chromium/base/containers/span.h +++ b/chromium/base/containers/span.h @@ -14,8 +14,8 @@ #include <type_traits> #include <utility> +#include "base/check_op.h" #include "base/containers/checked_iterators.h" -#include "base/logging.h" #include "base/macros.h" #include "base/stl_util.h" #include "base/template_util.h" diff --git a/chromium/base/containers/stack_container.h b/chromium/base/containers/stack_container.h index 46ced5b1879..c58558e3944 100644 --- a/chromium/base/containers/stack_container.h +++ b/chromium/base/containers/stack_container.h @@ -9,7 +9,6 @@ #include <vector> -#include "base/macros.h" #include "build/build_config.h" namespace base { @@ -84,17 +83,15 @@ class StackAllocator : public std::allocator<T> { // for Us. // TODO: If we were fancy pants, perhaps we could share storage // iff sizeof(T) == sizeof(U). - template<typename U, size_t other_capacity> + template <typename U, size_t other_capacity> StackAllocator(const StackAllocator<U, other_capacity>& other) - : source_(NULL) { - } + : source_(nullptr) {} // This constructor must exist. It creates a default allocator that doesn't // actually have a stack buffer. glibc's std::string() will compare the // current allocator against the default-constructed allocator, so this // should be fast. - StackAllocator() : source_(NULL) { - } + StackAllocator() : source_(nullptr) {} explicit StackAllocator(Source* source) : source_(source) { } @@ -149,6 +146,8 @@ class StackContainer { // before doing anything else. container_.reserve(stack_capacity); } + StackContainer(const StackContainer&) = delete; + StackContainer& operator=(const StackContainer&) = delete; // Getters for the actual container. // @@ -177,9 +176,6 @@ class StackContainer { typename Allocator::Source stack_data_; Allocator allocator_; ContainerType container_; - - private: - DISALLOW_COPY_AND_ASSIGN(StackContainer); }; // Range-based iteration support for StackContainer. diff --git a/chromium/base/containers/stack_container_unittest.cc b/chromium/base/containers/stack_container_unittest.cc index 7fa609556a7..e0f5dc5baeb 100644 --- a/chromium/base/containers/stack_container_unittest.cc +++ b/chromium/base/containers/stack_container_unittest.cc @@ -8,6 +8,7 @@ #include <algorithm> +#include "base/memory/aligned_memory.h" #include "base/memory/ref_counted.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" @@ -16,14 +17,14 @@ namespace base { namespace { -class Dummy : public base::RefCounted<Dummy> { +class Dummy : public RefCounted<Dummy> { public: explicit Dummy(int* alive) : alive_(alive) { ++*alive_; } private: - friend class base::RefCounted<Dummy>; + friend class RefCounted<Dummy>; ~Dummy() { --*alive_; @@ -110,31 +111,28 @@ class AlignedData { alignas(alignment) char data_[alignment]; }; -} // anonymous namespace - -#define EXPECT_ALIGNED(ptr, align) \ - EXPECT_EQ(0u, reinterpret_cast<uintptr_t>(ptr) & (align - 1)) +} // namespace TEST(StackContainer, BufferAlignment) { StackVector<wchar_t, 16> text; text->push_back(L'A'); - EXPECT_ALIGNED(&text[0], alignof(wchar_t)); + EXPECT_TRUE(IsAligned(&text[0], alignof(wchar_t))); StackVector<double, 1> doubles; doubles->push_back(0.0); - EXPECT_ALIGNED(&doubles[0], alignof(double)); + EXPECT_TRUE(IsAligned(&doubles[0], alignof(double))); StackVector<AlignedData<16>, 1> aligned16; aligned16->push_back(AlignedData<16>()); - EXPECT_ALIGNED(&aligned16[0], 16); + EXPECT_TRUE(IsAligned(&aligned16[0], 16)); #if !defined(__GNUC__) || defined(ARCH_CPU_X86_FAMILY) // It seems that non-X86 gcc doesn't respect greater than 16 byte alignment. // See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33721 for details. - // TODO(sbc):re-enable this if GCC starts respecting higher alignments. + // TODO(sbc): Re-enable this if GCC starts respecting higher alignments. StackVector<AlignedData<256>, 1> aligned256; aligned256->push_back(AlignedData<256>()); - EXPECT_ALIGNED(&aligned256[0], 256); + EXPECT_TRUE(IsAligned(&aligned256[0], 256)); #endif } diff --git a/chromium/base/containers/vector_buffer.h b/chromium/base/containers/vector_buffer.h index 83cd2ac139e..019913cce23 100644 --- a/chromium/base/containers/vector_buffer.h +++ b/chromium/base/containers/vector_buffer.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef BASE_CONTAINERS_VECTOR_BUFFERS_H_ -#define BASE_CONTAINERS_VECTOR_BUFFERS_H_ +#ifndef BASE_CONTAINERS_VECTOR_BUFFER_H_ +#define BASE_CONTAINERS_VECTOR_BUFFER_H_ #include <stdlib.h> #include <string.h> @@ -11,9 +11,8 @@ #include <type_traits> #include <utility> +#include "base/check_op.h" #include "base/containers/util.h" -#include "base/logging.h" -#include "base/macros.h" #include "base/numerics/checked_math.h" namespace base { @@ -57,6 +56,9 @@ class VectorBuffer { other.capacity_ = 0; } + VectorBuffer(const VectorBuffer&) = delete; + VectorBuffer& operator=(const VectorBuffer&) = delete; + ~VectorBuffer() { free(buffer_); } VectorBuffer& operator=(VectorBuffer&& other) { @@ -178,11 +180,9 @@ class VectorBuffer { T* buffer_ = nullptr; size_t capacity_ = 0; - - DISALLOW_COPY_AND_ASSIGN(VectorBuffer); }; } // namespace internal } // namespace base -#endif // BASE_CONTAINERS_VECTOR_BUFFERS_H_ +#endif // BASE_CONTAINERS_VECTOR_BUFFER_H_ |