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

Side by Side Diff: sky/engine/platform/heap/HeapTerminatedArray.h

Issue 678003003: Begin to remove heap/* (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef HeapTerminatedArray_h
6 #define HeapTerminatedArray_h
7
8 #include "platform/heap/Heap.h"
9 #include "wtf/TerminatedArray.h"
10 #include "wtf/TerminatedArrayBuilder.h"
11
12 namespace blink {
13
14 template<typename T>
15 class HeapTerminatedArray : public TerminatedArray<T> {
16 DISALLOW_ALLOCATION();
17 public:
18 using TerminatedArray<T>::begin;
19 using TerminatedArray<T>::end;
20
21 void trace(Visitor* visitor)
22 {
23 for (typename TerminatedArray<T>::iterator it = begin(); it != end(); ++ it)
24 visitor->trace(*it);
25 }
26
27 private:
28 // Allocator describes how HeapTerminatedArrayBuilder should create new inta nces
29 // of TerminateArray and manage their lifetimes.
30 struct Allocator {
31 typedef HeapTerminatedArray* PassPtr;
32 typedef RawPtr<HeapTerminatedArray> Ptr;
33
34 static PassPtr create(size_t capacity)
35 {
36 return reinterpret_cast<HeapTerminatedArray*>(Heap::allocate<HeapTer minatedArray>(capacity * sizeof(T)));
37 }
38
39 static PassPtr resize(PassPtr ptr, size_t capacity)
40 {
41 return reinterpret_cast<HeapTerminatedArray*>(Heap::reallocate<HeapT erminatedArray>(ptr, capacity * sizeof(T)));
42 }
43 };
44
45 // Prohibit construction. Allocator makes HeapTerminatedArray instances for
46 // HeapTerminatedArrayBuilder by pointer casting.
47 HeapTerminatedArray();
48
49 template<typename U, template <typename> class> friend class WTF::Terminated ArrayBuilder;
50 };
51
52 } // namespace blink
53
54 #endif // HeapTerminatedArray_h
OLDNEW
« no previous file with comments | « sky/engine/platform/heap/Heap.cpp ('k') | sky/engine/platform/heap/HeapTerminatedArrayBuilder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698