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

Unified Diff: net/disk_cache/simple/simple_entry_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
Index: net/disk_cache/simple/simple_entry_impl.cc
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc
index 23136ba60e541c91b9d5cfccfe0bffb1651df214..2b354cd0f68043a93b4f70956991a7261a2e422b 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -20,6 +20,7 @@
#include "base/task_runner_util.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/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/net_log_parameters.h"
@@ -149,6 +150,13 @@ using base::FilePath;
using base::Time;
using base::TaskRunner;
+// Static function called by base::trace_event::EstimateMemoryUsage() to
+// estimate the memory of SimpleEntryOperation.
+// This needs to be in disk_cache namespace.
+size_t EstimateMemoryUsage(const SimpleEntryOperation& op) {
+ return 0;
+}
+
// A helper class to insure that RunNextOperationIfNeeded() is called when
// exiting the current stack frame.
class SimpleEntryImpl::ScopedOperationRunner {
@@ -543,6 +551,15 @@ int SimpleEntryImpl::ReadyForSparseIO(const CompletionCallback& callback) {
return net::OK;
}
+size_t SimpleEntryImpl::EstimateMemoryUsage() const {
+ // TODO(xunjieli): crbug.com/669108. It'd be nice to have the rest of |entry|
+ // measured, but the ownership of SimpleSynchronousEntry isn't straightforward
+ return sizeof(SimpleSynchronousEntry) +
+ base::trace_event::EstimateMemoryUsage(pending_operations_) +
+ base::trace_event::EstimateMemoryUsage(executing_operation_) +
+ (stream_0_data_ ? stream_0_data_->capacity() : 0);
+}
+
SimpleEntryImpl::~SimpleEntryImpl() {
DCHECK(io_thread_checker_.CalledOnValidThread());
DCHECK_EQ(0U, pending_operations_.size());

Powered by Google App Engine
This is Rietveld 408576698