| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_RESOURCES_MEMORY_HISTORY_H_ | 5 #ifndef CC_RESOURCES_MEMORY_HISTORY_H_ |
| 6 #define CC_RESOURCES_MEMORY_HISTORY_H_ | 6 #define CC_RESOURCES_MEMORY_HISTORY_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 11 #include "cc/debug/ring_buffer.h" | 14 #include "cc/debug/ring_buffer.h" |
| 12 | 15 |
| 13 namespace cc { | 16 namespace cc { |
| 14 | 17 |
| 15 // Maintains a history of memory for each frame. | 18 // Maintains a history of memory for each frame. |
| 16 class MemoryHistory { | 19 class MemoryHistory { |
| 17 public: | 20 public: |
| 18 static scoped_ptr<MemoryHistory> Create(); | 21 static scoped_ptr<MemoryHistory> Create(); |
| 19 | 22 |
| 20 size_t HistorySize() const { return ring_buffer_.BufferSize(); } | 23 size_t HistorySize() const { return ring_buffer_.BufferSize(); } |
| 21 | 24 |
| 22 struct Entry { | 25 struct Entry { |
| 23 Entry() | 26 Entry() |
| 24 : total_budget_in_bytes(0), | 27 : total_budget_in_bytes(0), |
| 25 total_bytes_used(0), | 28 total_bytes_used(0), |
| 26 had_enough_memory(false) {} | 29 had_enough_memory(false) {} |
| 27 | 30 |
| 28 size_t total_budget_in_bytes; | 31 size_t total_budget_in_bytes; |
| 29 int64 total_bytes_used; | 32 int64_t total_bytes_used; |
| 30 bool had_enough_memory; | 33 bool had_enough_memory; |
| 31 }; | 34 }; |
| 32 | 35 |
| 33 void SaveEntry(const Entry& entry); | 36 void SaveEntry(const Entry& entry); |
| 34 | 37 |
| 35 typedef RingBuffer<Entry, 80> RingBufferType; | 38 typedef RingBuffer<Entry, 80> RingBufferType; |
| 36 RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); } | 39 RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); } |
| 37 RingBufferType::Iterator End() const { return ring_buffer_.End(); } | 40 RingBufferType::Iterator End() const { return ring_buffer_.End(); } |
| 38 | 41 |
| 39 private: | 42 private: |
| 40 MemoryHistory(); | 43 MemoryHistory(); |
| 41 | 44 |
| 42 RingBufferType ring_buffer_; | 45 RingBufferType ring_buffer_; |
| 43 | 46 |
| 44 DISALLOW_COPY_AND_ASSIGN(MemoryHistory); | 47 DISALLOW_COPY_AND_ASSIGN(MemoryHistory); |
| 45 }; | 48 }; |
| 46 | 49 |
| 47 } // namespace cc | 50 } // namespace cc |
| 48 | 51 |
| 49 #endif // CC_RESOURCES_MEMORY_HISTORY_H_ | 52 #endif // CC_RESOURCES_MEMORY_HISTORY_H_ |
| OLD | NEW |