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

Unified Diff: net/disk_cache/simple/simple_backend_impl.cc

Issue 2661333002: Track SimpleCache memory usage in net/ MemoryDumpProvider (Closed)
Patch Set: address comments 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 | « net/disk_cache/simple/simple_backend_impl.h ('k') | net/disk_cache/simple/simple_entry_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_backend_impl.cc
diff --git a/net/disk_cache/simple/simple_backend_impl.cc b/net/disk_cache/simple/simple_backend_impl.cc
index e5645e357ebd44aecac4b580e3fb88444f7dc7b9..e81877c9017bef6324ef7883b2daa1357ca74456 100644
--- a/net/disk_cache/simple/simple_backend_impl.cc
+++ b/net/disk_cache/simple/simple_backend_impl.cc
@@ -30,6 +30,7 @@
#include "base/threading/sequenced_worker_pool.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
+#include "base/trace_event/memory_usage_estimator.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/cache_util.h"
#include "net/disk_cache/simple/simple_entry_format.h"
@@ -204,6 +205,13 @@ void RecordIndexLoad(net::CacheType cache_type,
} // namespace
+// Static function which is called by base::trace_event::EstimateMemoryUsage()
+// to estimate the memory of SimpleEntryImpl* type.
+// This needs to be in disk_cache namespace.
+size_t EstimateMemoryUsage(const SimpleEntryImpl* const& entry_impl) {
jkarlin 2017/02/24 18:38:09 Have you verified that this actually gets called?
xunjieli 2017/02/24 18:42:17 I verified manually that this is called. (build ch
+ return sizeof(SimpleEntryImpl) + entry_impl->EstimateMemoryUsage();
+}
+
class SimpleBackendImpl::ActiveEntryProxy
: public SimpleEntryImpl::ActiveEntryProxy {
public:
@@ -552,6 +560,13 @@ void SimpleBackendImpl::OnExternalCacheHit(const std::string& key) {
index_->UseIfExists(simple_util::GetEntryHashKey(key));
}
+size_t SimpleBackendImpl::EstimateMemoryUsage() const {
+ // TODO(xunjieli): crbug.com/669108. Track |entries_pending_doom_| once
+ // base::Closure is suppported in memory_usage_estimator.h.
+ return base::trace_event::EstimateMemoryUsage(index_) +
+ base::trace_event::EstimateMemoryUsage(active_entries_);
+}
+
void SimpleBackendImpl::InitializeIndex(const CompletionCallback& callback,
const DiskStatResult& result) {
if (result.net_error == net::OK) {
« no previous file with comments | « net/disk_cache/simple/simple_backend_impl.h ('k') | net/disk_cache/simple/simple_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698