Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2906)

Unified Diff: base/trace_event/memory_usage_estimator.h

Issue 2723553002: Keep track of byte usage of the memory cache backend (Closed)
Patch Set: Address comments from PS3 Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/disk_cache/memory/mem_backend_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_usage_estimator.h
diff --git a/base/trace_event/memory_usage_estimator.h b/base/trace_event/memory_usage_estimator.h
index 1f4132bdcb2dcf29cd0396fe7c2ac691b0e6769b..6f02bb93bbbcd155764945f67ab5a1a6056dc6d5 100644
--- a/base/trace_event/memory_usage_estimator.h
+++ b/base/trace_event/memory_usage_estimator.h
@@ -22,6 +22,7 @@
#include <vector>
#include "base/base_export.h"
+#include "base/containers/linked_list.h"
#include "base/strings/string16.h"
#include "base/template_util.h"
@@ -111,6 +112,9 @@ size_t EstimateMemoryUsage(const std::vector<T, A>& vector);
template <class T, class A>
size_t EstimateMemoryUsage(const std::list<T, A>& list);
+template <class T>
+size_t EstimateMemoryUsage(const base::LinkedList<T>& list);
+
template <class T, class C, class A>
size_t EstimateMemoryUsage(const std::set<T, C, A>& set);
@@ -352,6 +356,18 @@ size_t EstimateMemoryUsage(const std::list<T, A>& list) {
EstimateIterableMemoryUsage(list);
}
+template <class T>
+size_t EstimateMemoryUsage(const base::LinkedList<T>& list) {
+ size_t memory_usage = 0u;
+ for (base::LinkNode<T>* node = list.head(); node != list.end();
+ node = node->next()) {
+ // Since we increment by calling node = node->next() we know that node
+ // isn't nullptr.
+ memory_usage += EstimateMemoryUsage(*node->value()) + sizeof(T);
+ }
+ return memory_usage;
+}
+
// Tree containers
template <class V>
« no previous file with comments | « no previous file | net/disk_cache/memory/mem_backend_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698