Chromium Code Reviews| Index: net/http/http_cache.cc |
| diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc |
| index b02ddf02adf0a12669426d13131ce0e33839fe58..860c4c4fcc57ca430e359a354c444a57354a26dc 100644 |
| --- a/net/http/http_cache.cc |
| +++ b/net/http/http_cache.cc |
| @@ -28,6 +28,9 @@ |
| #include "base/threading/worker_pool.h" |
| #include "base/time/default_clock.h" |
| #include "base/time/time.h" |
| +#include "base/trace_event/memory_allocator_dump.h" |
| +#include "base/trace_event/memory_usage_estimator.h" |
| +#include "base/trace_event/process_memory_dump.h" |
| #include "net/base/cache_type.h" |
| #include "net/base/io_buffer.h" |
| #include "net/base/load_flags.h" |
| @@ -106,6 +109,11 @@ HttpCache::ActiveEntry::~ActiveEntry() { |
| } |
| } |
| +size_t HttpCache::ActiveEntry::EstimateMemoryUsage() const { |
| + return base::trace_event::EstimateMemoryUsage(readers) + |
|
jkarlin
2017/02/17 18:13:08
You'll need to EMU HttpCache::Transaction, which t
xunjieli
2017/02/21 15:20:39
Acknowledged. We aren't tracking ActiveEntry per o
|
| + base::trace_event::EstimateMemoryUsage(pending_queue); |
|
jkarlin
2017/02/17 17:43:05
+ writer ? EMU(writer) : 0
xunjieli
2017/02/21 15:20:39
Acknowledged.
|
| +} |
| + |
| //----------------------------------------------------------------------------- |
| // This structure keeps track of work items that are attempting to create or |
| @@ -114,6 +122,13 @@ struct HttpCache::PendingOp { |
| PendingOp() : disk_entry(NULL) {} |
| ~PendingOp() {} |
| + // Returns the estimate of dynamically allocated memory in bytes. |
| + size_t EstimateMemoryUsage() const { |
| + return base::trace_event::EstimateMemoryUsage(backend) + |
| + base::trace_event::EstimateMemoryUsage(writer) + |
| + base::trace_event::EstimateMemoryUsage(pending_queue); |
|
jkarlin
2017/02/17 17:43:06
+ disk_entry ? EMU(disk_entry) : 0
jkarlin
2017/02/17 18:03:43
Actually, don't do this. We're going to count the
xunjieli
2017/02/21 15:20:39
Acknowledged.
|
| + } |
| + |
| disk_cache::Entry* disk_entry; |
| std::unique_ptr<disk_cache::Backend> backend; |
| std::unique_ptr<WorkItem> writer; |
| @@ -178,6 +193,8 @@ class HttpCache::WorkItem { |
| void ClearCallback() { callback_.Reset(); } |
| bool Matches(Transaction* trans) const { return trans == trans_; } |
| bool IsValid() const { return trans_ || entry_ || !callback_.is_null(); } |
| + // Returns the estimate of dynamically allocated memory in bytes. |
|
jkarlin
2017/02/17 17:43:06
Newline above the comment
xunjieli
2017/02/21 15:20:39
Done.
|
| + size_t EstimateMemoryUsage() const { return 0; } |
| private: |
| WorkItemOperation operation_; |
| @@ -481,6 +498,21 @@ HttpCache::SetHttpNetworkTransactionFactoryForTesting( |
| return old_network_layer; |
| } |
| +void HttpCache::DumpMemoryStats(base::trace_event::ProcessMemoryDump* pmd, |
| + const std::string& parent_absolute_name) const { |
| + size_t memory_estimate = |
| + base::trace_event::EstimateMemoryUsage(disk_cache_) + |
| + base::trace_event::EstimateMemoryUsage(active_entries_) + |
| + base::trace_event::EstimateMemoryUsage(doomed_entries_) + |
| + base::trace_event::EstimateMemoryUsage(playback_cache_map_) + |
| + base::trace_event::EstimateMemoryUsage(pending_ops_); |
|
jkarlin
2017/02/17 17:43:06
After F2F w/ Helen we discussed that members that
xunjieli
2017/02/21 15:20:39
Acknowledged. I added a comment
|
| + base::trace_event::MemoryAllocatorDump* dump = |
| + pmd->CreateAllocatorDump(parent_absolute_name + "/http_cache"); |
| + dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| + base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| + memory_estimate); |
| +} |
| + |
| //----------------------------------------------------------------------------- |
| int HttpCache::CreateBackend(disk_cache::Backend** backend, |