| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 HeapTerminatedArray_h | 5 #ifndef HeapTerminatedArray_h |
| 6 #define HeapTerminatedArray_h | 6 #define HeapTerminatedArray_h |
| 7 | 7 |
| 8 #include "platform/heap/Heap.h" | 8 #include "platform/heap/Heap.h" |
| 9 #include "wtf/TerminatedArray.h" | 9 #include "wtf/TerminatedArray.h" |
| 10 #include "wtf/TerminatedArrayBuilder.h" | 10 #include "wtf/TerminatedArrayBuilder.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 template <typename T> | 14 template <typename T> |
| 15 class HeapTerminatedArray : public TerminatedArray<T> { | 15 class HeapTerminatedArray : public TerminatedArray<T> { |
| 16 DISALLOW_NEW(); | 16 DISALLOW_NEW(); |
| 17 IS_GARBAGE_COLLECTED_TYPE(); | 17 IS_GARBAGE_COLLECTED_TYPE(); |
| 18 | 18 |
| 19 public: | 19 public: |
| 20 using TerminatedArray<T>::begin; | 20 using TerminatedArray<T>::begin; |
| 21 using TerminatedArray<T>::end; | 21 using TerminatedArray<T>::end; |
| 22 | 22 |
| 23 DEFINE_INLINE_TRACE() { | 23 DEFINE_INLINE_TRACE() { |
| 24 for (typename TerminatedArray<T>::iterator it = begin(); it != end(); ++it) | 24 for (typename TerminatedArray<T>::iterator it = begin(); it != end(); ++it) |
| 25 visitor->trace(*it); | 25 visitor->trace(*it); |
| 26 } | 26 } |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // Allocator describes how HeapTerminatedArrayBuilder should create new intanc
es | 29 // Allocator describes how HeapTerminatedArrayBuilder should create new |
| 30 // of HeapTerminatedArray and manage their lifetimes. | 30 // instances of HeapTerminatedArray and manage their lifetimes. |
| 31 struct Allocator final { | 31 struct Allocator final { |
| 32 STATIC_ONLY(Allocator); | 32 STATIC_ONLY(Allocator); |
| 33 using PassPtr = HeapTerminatedArray*; | 33 using PassPtr = HeapTerminatedArray*; |
| 34 using Ptr = Member<HeapTerminatedArray>; | 34 using Ptr = Member<HeapTerminatedArray>; |
| 35 | 35 |
| 36 static PassPtr release(Ptr& ptr) { return ptr; } | 36 static PassPtr release(Ptr& ptr) { return ptr; } |
| 37 | 37 |
| 38 static PassPtr create(size_t capacity) { | 38 static PassPtr create(size_t capacity) { |
| 39 return reinterpret_cast<HeapTerminatedArray*>( | 39 return reinterpret_cast<HeapTerminatedArray*>( |
| 40 ThreadHeap::allocate<HeapTerminatedArray>( | 40 ThreadHeap::allocate<HeapTerminatedArray>( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 template <typename T> | 59 template <typename T> |
| 60 class TraceEagerlyTrait<HeapTerminatedArray<T>> { | 60 class TraceEagerlyTrait<HeapTerminatedArray<T>> { |
| 61 public: | 61 public: |
| 62 static const bool value = TraceEagerlyTrait<T>::value; | 62 static const bool value = TraceEagerlyTrait<T>::value; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 } // namespace blink | 65 } // namespace blink |
| 66 | 66 |
| 67 #endif // HeapTerminatedArray_h | 67 #endif // HeapTerminatedArray_h |
| OLD | NEW |