Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: cc/base/contiguous_container.h

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/base/container_util.h ('k') | cc/base/contiguous_container.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CONTIGUOUS_CONTAINER_H_ 5 #ifndef CC_BASE_CONTIGUOUS_CONTAINER_H_
6 #define CC_BASE_CONTIGUOUS_CONTAINER_H_ 6 #define CC_BASE_CONTIGUOUS_CONTAINER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9
10 #include <memory>
9 #include <utility> 11 #include <utility>
10 12
11 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
12 #include "base/logging.h" 14 #include "base/logging.h"
13 #include "base/macros.h" 15 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "cc/base/cc_export.h" 17 #include "cc/base/cc_export.h"
17 18
18 namespace cc { 19 namespace cc {
19 20
20 // ContiguousContainer is a container which stores a list of heterogeneous 21 // ContiguousContainer is a container which stores a list of heterogeneous
21 // objects (in particular, of varying sizes), packed next to one another in 22 // objects (in particular, of varying sizes), packed next to one another in
22 // memory. Objects are never relocated, so it is safe to store pointers to them 23 // memory. Objects are never relocated, so it is safe to store pointers to them
23 // for the lifetime of the container (unless the object is removed). 24 // for the lifetime of the container (unless the object is removed).
24 // 25 //
(...skipping 28 matching lines...) Expand all
53 void RemoveLast(); 54 void RemoveLast();
54 void Swap(ContiguousContainerBase& other); 55 void Swap(ContiguousContainerBase& other);
55 56
56 std::vector<void*> elements_; 57 std::vector<void*> elements_;
57 58
58 private: 59 private:
59 class Buffer; 60 class Buffer;
60 61
61 Buffer* AllocateNewBufferForNextAllocation(size_t buffer_size); 62 Buffer* AllocateNewBufferForNextAllocation(size_t buffer_size);
62 63
63 std::vector<scoped_ptr<Buffer>> buffers_; 64 std::vector<std::unique_ptr<Buffer>> buffers_;
64 size_t end_index_; 65 size_t end_index_;
65 size_t max_object_size_; 66 size_t max_object_size_;
66 67
67 DISALLOW_COPY_AND_ASSIGN(ContiguousContainerBase); 68 DISALLOW_COPY_AND_ASSIGN(ContiguousContainerBase);
68 }; 69 };
69 70
70 // For most cases, no alignment stricter than pointer alignment is required. If 71 // For most cases, no alignment stricter than pointer alignment is required. If
71 // one of the derived classes has stronger alignment requirements (and the 72 // one of the derived classes has stronger alignment requirements (and the
72 // static_assert fires), set alignment to the least common multiple of the 73 // static_assert fires), set alignment to the least common multiple of the
73 // derived class alignments. For small structs without pointers, it may be 74 // derived class alignments. For small structs without pointers, it may be
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 DCHECK_EQ(aligned_size % alignment, 0u); 210 DCHECK_EQ(aligned_size % alignment, 0u);
210 DCHECK_GE(aligned_size, size); 211 DCHECK_GE(aligned_size, size);
211 DCHECK_LT(aligned_size, size + alignment); 212 DCHECK_LT(aligned_size, size + alignment);
212 return aligned_size; 213 return aligned_size;
213 } 214 }
214 }; 215 };
215 216
216 } // namespace cc 217 } // namespace cc
217 218
218 #endif // CC_BASE_CONTIGUOUS_CONTAINER_H_ 219 #endif // CC_BASE_CONTIGUOUS_CONTAINER_H_
OLDNEW
« no previous file with comments | « cc/base/container_util.h ('k') | cc/base/contiguous_container.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698