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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/ContiguousContainer.h

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
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 ContiguousContainer_h 5 #ifndef ContiguousContainer_h
6 #define ContiguousContainer_h 6 #define ContiguousContainer_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "wtf/Alignment.h" 9 #include "wtf/Alignment.h"
10 #include "wtf/Allocator.h" 10 #include "wtf/Allocator.h"
11 #include "wtf/Compiler.h" 11 #include "wtf/Compiler.h"
12 #include "wtf/Noncopyable.h" 12 #include "wtf/Noncopyable.h"
13 #include "wtf/OwnPtr.h"
13 #include "wtf/TypeTraits.h" 14 #include "wtf/TypeTraits.h"
14 #include "wtf/Vector.h" 15 #include "wtf/Vector.h"
15 #include <cstddef> 16 #include <cstddef>
16 #include <iterator> 17 #include <iterator>
17 #include <memory>
18 #include <utility> 18 #include <utility>
19 19
20 namespace blink { 20 namespace blink {
21 21
22 // ContiguousContainer is a container which stores a list of heterogeneous 22 // ContiguousContainer is a container which stores a list of heterogeneous
23 // objects (in particular, of varying sizes), packed next to one another in 23 // objects (in particular, of varying sizes), packed next to one another in
24 // memory. Objects are never relocated, so it is safe to store pointers to them 24 // memory. Objects are never relocated, so it is safe to store pointers to them
25 // for the lifetime of the container (unless the object is removed). 25 // for the lifetime of the container (unless the object is removed).
26 // 26 //
27 // Memory is allocated in a series of buffers (with exponential growth). When an 27 // Memory is allocated in a series of buffers (with exponential growth). When an
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void clear(); 60 void clear();
61 void swap(ContiguousContainerBase&); 61 void swap(ContiguousContainerBase&);
62 62
63 Vector<void*> m_elements; 63 Vector<void*> m_elements;
64 64
65 private: 65 private:
66 class Buffer; 66 class Buffer;
67 67
68 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName); 68 Buffer* allocateNewBufferForNextAllocation(size_t, const char* typeName);
69 69
70 Vector<std::unique_ptr<Buffer>> m_buffers; 70 Vector<OwnPtr<Buffer>> m_buffers;
71 unsigned m_endIndex; 71 unsigned m_endIndex;
72 size_t m_maxObjectSize; 72 size_t m_maxObjectSize;
73 }; 73 };
74 74
75 // For most cases, no alignment stricter than pointer alignment is required. If 75 // For most cases, no alignment stricter than pointer alignment is required. If
76 // one of the derived classes has stronger alignment requirements (and the 76 // one of the derived classes has stronger alignment requirements (and the
77 // static_assert fires), set alignment to the LCM of the derived class 77 // static_assert fires), set alignment to the LCM of the derived class
78 // alignments. For small structs without pointers, it may be possible to reduce 78 // alignments. For small structs without pointers, it may be possible to reduce
79 // alignment for tighter packing. 79 // alignment for tighter packing.
80 80
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 ASSERT(alignedSize % alignment == 0); 211 ASSERT(alignedSize % alignment == 0);
212 ASSERT(alignedSize >= size); 212 ASSERT(alignedSize >= size);
213 ASSERT(alignedSize < size + alignment); 213 ASSERT(alignedSize < size + alignment);
214 return alignedSize; 214 return alignedSize;
215 } 215 }
216 }; 216 };
217 217
218 } // namespace blink 218 } // namespace blink
219 219
220 #endif // ContiguousContainer_h 220 #endif // ContiguousContainer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698