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

Unified Diff: net/url_request/url_request_context_unittest.cc

Issue 2536723009: Make net::URLRequestContext a MemoryDumpProvider (Closed)
Patch Set: fix compile 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
« no previous file with comments | « net/url_request/url_request_context.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_context_unittest.cc
diff --git a/net/url_request/url_request_context_unittest.cc b/net/url_request/url_request_context_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..627e6f9a1e85f29737f5b321a1109236b8ab3b26
--- /dev/null
+++ b/net/url_request/url_request_context_unittest.cc
@@ -0,0 +1,44 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/url_request/url_request_context.h"
+
+#include <memory>
+
+#include "base/trace_event/process_memory_dump.h"
+#include "net/proxy/proxy_config_service_fixed.h"
+#include "net/url_request/url_request_context_builder.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+// Checks if the dump provider runs without crashing and dumps root objects.
+TEST(URLRequestContextTest, MemoryDumpProvider) {
+ base::trace_event::MemoryDumpArgs dump_args = {
+ base::trace_event::MemoryDumpLevelOfDetail::DETAILED};
+ std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump(
+ new base::trace_event::ProcessMemoryDump(nullptr, dump_args));
+ URLRequestContextBuilder builder;
+#if defined(OS_LINUX) || defined(OS_ANDROID)
+ builder.set_proxy_config_service(
+ base::MakeUnique<ProxyConfigServiceFixed>(ProxyConfig::CreateDirect()));
+#endif // defined(OS_LINUX) || defined(OS_ANDROID)
+ std::unique_ptr<URLRequestContext> context(builder.Build());
+ context->OnMemoryDump(dump_args, process_memory_dump.get());
+ const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap&
+ allocator_dumps = process_memory_dump->allocator_dumps();
+
+ bool did_dump_url_request_context = false;
+ // bool did_dump_space_stats = false;
+ // bool did_dump_objects_stats = false;
+ for (const auto& it : allocator_dumps) {
+ const std::string& dump_name = it.first;
+ if (dump_name.find("net/url_request_context") != std::string::npos)
+ did_dump_url_request_context = true;
+ }
+
+ ASSERT_TRUE(did_dump_url_request_context);
+}
+
+} // namespace net
« no previous file with comments | « net/url_request/url_request_context.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698