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

Unified Diff: net/url_request/url_request_context.cc

Issue 2536723009: Make net::URLRequestContext a MemoryDumpProvider (Closed)
Patch Set: Created 4 years 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/url_request/url_request_context.cc
diff --git a/net/url_request/url_request_context.cc b/net/url_request/url_request_context.cc
index 1e3dc4ead60cf6f6e5bfbeb349b0808af2e2db36..e77a3a99f9d8ec7bd53996702fb1c4c0e83c6d0d 100644
--- a/net/url_request/url_request_context.cc
+++ b/net/url_request/url_request_context.cc
@@ -8,9 +8,15 @@
#include "base/debug/alias.h"
#include "base/memory/ptr_util.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
+#include "base/trace_event/memory_allocator_dump.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
+#include "net/base/sdch_manager.h"
#include "net/cookies/cookie_store.h"
#include "net/dns/host_resolver.h"
#include "net/http/http_transaction_factory.h"
+#include "net/socket/ssl_client_socket_impl.h"
#include "net/url_request/http_user_agent_settings.h"
#include "net/url_request/url_request.h"
@@ -37,10 +43,15 @@ URLRequestContext::URLRequestContext()
sdch_manager_(nullptr),
network_quality_estimator_(nullptr),
url_requests_(new std::set<const URLRequest*>),
- enable_brotli_(false) {}
+ enable_brotli_(false) {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this, "URLRequestContext", base::ThreadTaskRunnerHandle::Get());
+}
URLRequestContext::~URLRequestContext() {
AssertNoURLRequests();
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
}
void URLRequestContext::CopyFrom(const URLRequestContext* other) {
@@ -108,4 +119,18 @@ void URLRequestContext::AssertNoURLRequests() const {
}
}
+bool URLRequestContext::OnMemoryDump(
+ const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ if (name_string_.empty())
+ name_string_ = "unknown";
+ base::trace_event::MemoryAllocatorDump* dump =
+ pmd->CreateAllocatorDump(base::StringPrintf(
+ "net/url_request_context/%s_%p", name_string_.c_str(), this));
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameObjectCount,
+ base::trace_event::MemoryAllocatorDump::kUnitsObjects,
+ url_requests_->size());
+ return true;
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698