| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/url_request/url_request_context.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/trace_event/process_memory_dump.h" |
| 10 #include "net/proxy/proxy_config_service_fixed.h" |
| 11 #include "net/url_request/url_request_context_builder.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace net { |
| 15 |
| 16 // Checks if the dump provider runs without crashing and dumps root objects. |
| 17 TEST(URLRequestContextTest, MemoryDumpProvider) { |
| 18 base::trace_event::MemoryDumpArgs dump_args = { |
| 19 base::trace_event::MemoryDumpLevelOfDetail::DETAILED}; |
| 20 std::unique_ptr<base::trace_event::ProcessMemoryDump> process_memory_dump( |
| 21 new base::trace_event::ProcessMemoryDump(nullptr, dump_args)); |
| 22 URLRequestContextBuilder builder; |
| 23 #if defined(OS_LINUX) || defined(OS_ANDROID) |
| 24 builder.set_proxy_config_service( |
| 25 base::MakeUnique<ProxyConfigServiceFixed>(ProxyConfig::CreateDirect())); |
| 26 #endif // defined(OS_LINUX) || defined(OS_ANDROID) |
| 27 std::unique_ptr<URLRequestContext> context(builder.Build()); |
| 28 context->OnMemoryDump(dump_args, process_memory_dump.get()); |
| 29 const base::trace_event::ProcessMemoryDump::AllocatorDumpsMap& |
| 30 allocator_dumps = process_memory_dump->allocator_dumps(); |
| 31 |
| 32 bool did_dump_url_request_context = false; |
| 33 // bool did_dump_space_stats = false; |
| 34 // bool did_dump_objects_stats = false; |
| 35 for (const auto& it : allocator_dumps) { |
| 36 const std::string& dump_name = it.first; |
| 37 if (dump_name.find("net/url_request_context") != std::string::npos) |
| 38 did_dump_url_request_context = true; |
| 39 } |
| 40 |
| 41 ASSERT_TRUE(did_dump_url_request_context); |
| 42 } |
| 43 |
| 44 } // namespace net |
| OLD | NEW |