Webkit roll 143935:143980
[chromium-blink-merge.git] / cc / memory_history.cc
blob0638810429a75198350da06b02ea694edf32da6b
1 // Copyright 2012 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.
5 #include "cc/memory_history.h"
7 namespace cc {
9 // static
10 scoped_ptr<MemoryHistory> MemoryHistory::create() {
11 return make_scoped_ptr(new MemoryHistory());
14 MemoryHistory::MemoryHistory() {
17 void MemoryHistory::SaveEntry(const MemoryHistory::Entry& entry) {
18 ring_buffer_.SaveToBuffer(entry);
21 void MemoryHistory::GetMinAndMax(size_t* min, size_t* max) const {
22 *min = std::numeric_limits<size_t>::max();
23 *max = 0;
25 for (RingBufferType::Iterator it = ring_buffer_.Begin(); it; ++it) {
26 size_t bytes_total = it->bytes_total();
28 if (bytes_total < *min)
29 *min = bytes_total;
30 if (bytes_total > *max)
31 *max = bytes_total;
34 if (*min > *max)
35 *min = *max;
38 } // namespace cc