forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemory_history.h
52 lines (36 loc) · 1.24 KB
/
memory_history.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CC_RESOURCES_MEMORY_HISTORY_H_
#define CC_RESOURCES_MEMORY_HISTORY_H_
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include "base/containers/ring_buffer.h"
namespace cc {
// Maintains a history of memory for each frame.
class MemoryHistory {
public:
static std::unique_ptr<MemoryHistory> Create();
MemoryHistory(const MemoryHistory&) = delete;
MemoryHistory& operator=(const MemoryHistory&) = delete;
size_t HistorySize() const { return ring_buffer_.BufferSize(); }
struct Entry {
Entry()
: total_budget_in_bytes(0),
total_bytes_used(0),
had_enough_memory(false) {}
size_t total_budget_in_bytes;
int64_t total_bytes_used;
bool had_enough_memory;
};
void SaveEntry(const Entry& entry);
typedef base::RingBuffer<Entry, 80> RingBufferType;
RingBufferType::Iterator Begin() const { return ring_buffer_.Begin(); }
RingBufferType::Iterator End() const { return ring_buffer_.End(); }
private:
MemoryHistory();
RingBufferType ring_buffer_;
};
} // namespace cc
#endif // CC_RESOURCES_MEMORY_HISTORY_H_