OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_BASE_SIDECAR_LIST_CONTAINER_H_ | 5 #ifndef CC_BASE_SIDECAR_LIST_CONTAINER_H_ |
6 #define CC_BASE_SIDECAR_LIST_CONTAINER_H_ | 6 #define CC_BASE_SIDECAR_LIST_CONTAINER_H_ |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "cc/base/list_container.h" | 9 #include "cc/base/list_container.h" |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 SidecarDestroyer destroyer) | 40 SidecarDestroyer destroyer) |
41 : list_(max_size_for_derived_class + max_size_for_sidecar, | 41 : list_(max_size_for_derived_class + max_size_for_sidecar, |
42 num_of_elements_to_reserve_for), | 42 num_of_elements_to_reserve_for), |
43 destroyer_(destroyer), | 43 destroyer_(destroyer), |
44 sidecar_offset_(max_size_for_derived_class) {} | 44 sidecar_offset_(max_size_for_derived_class) {} |
45 ~SidecarListContainer() { DestroyAllSidecars(); } | 45 ~SidecarListContainer() { DestroyAllSidecars(); } |
46 | 46 |
47 // Forward most of the reading logic to ListContainer. | 47 // Forward most of the reading logic to ListContainer. |
48 bool empty() const { return list_.empty(); } | 48 bool empty() const { return list_.empty(); } |
49 size_t size() const { return list_.size(); } | 49 size_t size() const { return list_.size(); } |
| 50 size_t GetCapacityInBytes() const { return list_.GetCapacityInBytes(); } |
50 ConstIterator begin() const { return list_.begin(); } | 51 ConstIterator begin() const { return list_.begin(); } |
51 ConstIterator end() const { return list_.end(); } | 52 ConstIterator end() const { return list_.end(); } |
52 | 53 |
53 template <typename DerivedElementType> | 54 template <typename DerivedElementType> |
54 DerivedElementType* AllocateAndConstruct() { | 55 DerivedElementType* AllocateAndConstruct() { |
55 return list_.template AllocateAndConstruct<DerivedElementType>(); | 56 return list_.template AllocateAndConstruct<DerivedElementType>(); |
56 } | 57 } |
57 template <typename DerivedElementType> | 58 template <typename DerivedElementType> |
58 DerivedElementType* AllocateAndCopyFrom(const DerivedElementType* source) { | 59 DerivedElementType* AllocateAndCopyFrom(const DerivedElementType* source) { |
59 return list_.template AllocateAndCopyFrom<DerivedElementType>(source); | 60 return list_.template AllocateAndCopyFrom<DerivedElementType>(source); |
(...skipping 27 matching lines...) Expand all Loading... |
87 } | 88 } |
88 | 89 |
89 ListContainer<BaseElementType> list_; | 90 ListContainer<BaseElementType> list_; |
90 SidecarDestroyer destroyer_; | 91 SidecarDestroyer destroyer_; |
91 size_t sidecar_offset_; | 92 size_t sidecar_offset_; |
92 }; | 93 }; |
93 | 94 |
94 } // namespace cc | 95 } // namespace cc |
95 | 96 |
96 #endif // CC_BASE_SIDECAR_LIST_CONTAINER_H_ | 97 #endif // CC_BASE_SIDECAR_LIST_CONTAINER_H_ |
OLD | NEW |