Skip to content

Commit

Permalink
cc: Chromify MemoryHistory
Browse files Browse the repository at this point in the history
R=danakj@chromium.org
BUG=none


Review URL: https://chromiumcodereview.appspot.com/12795002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187712 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
enne@chromium.org committed Mar 13, 2013
1 parent e407774 commit 4e8ee2c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
2 changes: 1 addition & 1 deletion cc/layer_tree_host_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
, m_pinchGestureActive(false)
, m_fpsCounter(FrameRateCounter::create(m_proxy->HasImplThread()))
, m_paintTimeCounter(PaintTimeCounter::create())
, m_memoryHistory(MemoryHistory::create())
, m_memoryHistory(MemoryHistory::Create())
, m_debugRectHistory(DebugRectHistory::create())
, m_numImplThreadScrolls(0)
, m_numMainThreadScrolls(0)
Expand Down
7 changes: 3 additions & 4 deletions cc/memory_history.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
namespace cc {

// static
scoped_ptr<MemoryHistory> MemoryHistory::create() {
scoped_ptr<MemoryHistory> MemoryHistory::Create() {
return make_scoped_ptr(new MemoryHistory());
}

MemoryHistory::MemoryHistory() {
}
MemoryHistory::MemoryHistory() {}

void MemoryHistory::SaveEntry(const MemoryHistory::Entry& entry) {
ring_buffer_.SaveToBuffer(entry);
Expand All @@ -28,7 +27,7 @@ void MemoryHistory::GetMinAndMax(size_t* min, size_t* max) const {
if (bytes_total < *min)
*min = bytes_total;
if (bytes_total > *max)
*max = bytes_total;
*max = bytes_total;
}

if (*min > *max)
Expand Down
32 changes: 15 additions & 17 deletions cc/memory_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,27 @@

namespace cc {

// Maintains a history of memory for each frame
// Maintains a history of memory for each frame.
class MemoryHistory {
public:
static scoped_ptr<MemoryHistory> create();
static scoped_ptr<MemoryHistory> Create();

size_t HistorySize() const { return ring_buffer_.BufferSize(); }

struct Entry {
Entry()
: total_budget_in_bytes(0),
bytes_allocated(0),
bytes_unreleasable(0),
bytes_over(0) { }

size_t total_budget_in_bytes;
size_t bytes_allocated;
size_t bytes_unreleasable;
size_t bytes_over;
size_t bytes_total() const {
return bytes_allocated +
bytes_unreleasable +
bytes_over;
}
Entry()
: total_budget_in_bytes(0),
bytes_allocated(0),
bytes_unreleasable(0),
bytes_over(0) {}

size_t total_budget_in_bytes;
size_t bytes_allocated;
size_t bytes_unreleasable;
size_t bytes_over;
size_t bytes_total() const {
return bytes_allocated + bytes_unreleasable + bytes_over;
}
};

void SaveEntry(const Entry& entry);
Expand Down

0 comments on commit 4e8ee2c

Please sign in to comment.