| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 CC_MEMORY_HISTORY_H_ | |
| 6 #define CC_MEMORY_HISTORY_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/time.h" | |
| 11 #include "cc/debug/ring_buffer.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 | |
| 15 // Maintains a history of memory for each frame. | |
| 16 class MemoryHistory { | |
| 17 public: | |
| 18 static scoped_ptr<MemoryHistory> Create(); | |
| 19 | |
| 20 size_t HistorySize() const { return ring_buffer_.BufferSize(); } | |
| 21 | |
| 22 struct Entry { | |
| 23 Entry() | |
| 24 : total_budget_in_bytes(0), | |
| 25 bytes_allocated(0), | |
| 26 bytes_unreleasable(0), | |
| 27 bytes_over(0) {} | |
| 28 | |
| 29 size_t total_budget_in_bytes; | |
| 30 size_t bytes_allocated; | |
| 31 size_t bytes_unreleasable; | |
| 32 size_t bytes_over; | |
| 33 size_t bytes_total() const { | |
| 34 return bytes_allocated + bytes_unreleasable + bytes_over; | |
| 35 } | |
| 36 }; | |
| 37 | |
| 38 void SaveEntry(const Entry& entry); | |
| 39 void GetMinAndMax(size_t* min, size_t* max) const; | |
| 40 | |
| 41 typedef RingBuffer<Entry, 80> RingBufferType; | |
| 42 RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); } | |
| 43 RingBufferType::Iterator End() const { return ring_buffer_.End(); } | |
| 44 | |
| 45 private: | |
| 46 MemoryHistory(); | |
| 47 | |
| 48 RingBufferType ring_buffer_; | |
| 49 | |
| 50 DISALLOW_COPY_AND_ASSIGN(MemoryHistory); | |
| 51 }; | |
| 52 | |
| 53 } // namespace cc | |
| 54 | |
| 55 #endif // CC_MEMORY_HISTORY_H_ | |
| OLD | NEW |