summaryrefslogtreecommitdiff
path: root/chromium/cc/resources/memory_history.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/cc/resources/memory_history.cc')
-rw-r--r--chromium/cc/resources/memory_history.cc39
1 files changed, 39 insertions, 0 deletions
diff --git a/chromium/cc/resources/memory_history.cc b/chromium/cc/resources/memory_history.cc
new file mode 100644
index 00000000000..a2f8b6ee113
--- /dev/null
+++ b/chromium/cc/resources/memory_history.cc
@@ -0,0 +1,39 @@
+// Copyright 2012 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.
+
+#include "cc/resources/memory_history.h"
+
+#include <limits>
+
+namespace cc {
+
+// static
+scoped_ptr<MemoryHistory> MemoryHistory::Create() {
+ return make_scoped_ptr(new MemoryHistory());
+}
+
+MemoryHistory::MemoryHistory() {}
+
+void MemoryHistory::SaveEntry(const MemoryHistory::Entry& entry) {
+ ring_buffer_.SaveToBuffer(entry);
+}
+
+void MemoryHistory::GetMinAndMax(size_t* min, size_t* max) const {
+ *min = std::numeric_limits<size_t>::max();
+ *max = 0;
+
+ for (RingBufferType::Iterator it = ring_buffer_.Begin(); it; ++it) {
+ size_t bytes_total = it->bytes_total();
+
+ if (bytes_total < *min)
+ *min = bytes_total;
+ if (bytes_total > *max)
+ *max = bytes_total;
+ }
+
+ if (*min > *max)
+ *min = *max;
+}
+
+} // namespace cc