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

Unified Diff: base/trace_event/memory_dump_manager_unittest.cc

Issue 2876543002: memory-infra: Don't invoke all dump providers in SUMMARY_ONLY mode (Closed)
Patch Set: address comments Created 3 years, 7 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
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_provider_info.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_dump_manager_unittest.cc
diff --git a/base/trace_event/memory_dump_manager_unittest.cc b/base/trace_event/memory_dump_manager_unittest.cc
index dbb16a691dffc84fe4fe03eaa6c8587acdb14c4f..8e163b4b9c6c2b4801e0ee38777594fcd1287d22 100644
--- a/base/trace_event/memory_dump_manager_unittest.cc
+++ b/base/trace_event/memory_dump_manager_unittest.cc
@@ -63,7 +63,12 @@ namespace {
const char* kMDPName = "TestDumpProvider";
const char* kWhitelistedMDPName = "WhitelistedTestDumpProvider";
-const char* const kTestMDPWhitelist[] = {kWhitelistedMDPName, nullptr};
+const char* kBackgroundButNotSummaryWhitelistedMDPName =
+ "BackgroundButNotSummaryWhitelistedTestDumpProvider";
+const char* const kTestMDPWhitelist[] = {
+ kWhitelistedMDPName, kBackgroundButNotSummaryWhitelistedMDPName, nullptr};
+const char* const kTestMDPWhitelistForSummary[] = {kWhitelistedMDPName,
+ nullptr};
void RegisterDumpProvider(
MemoryDumpProvider* mdp,
@@ -1081,10 +1086,34 @@ TEST_F(MemoryDumpManagerTest, DumpOnBehalfOfOtherProcess) {
ASSERT_EQ(events[0]->id, events[2]->id);
}
+TEST_F(MemoryDumpManagerTest, SummaryOnlyWhitelisting) {
+ InitializeMemoryDumpManager(false /* is_coordinator */);
+ // Summary only MDPs are a subset of background MDPs.
+ SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
+ SetDumpProviderSummaryWhitelistForTesting(kTestMDPWhitelistForSummary);
+
+ // Standard provider with default options (create dump for current process).
+ MockMemoryDumpProvider summaryMdp;
+ RegisterDumpProvider(&summaryMdp, nullptr, kDefaultOptions,
+ kWhitelistedMDPName);
+ MockMemoryDumpProvider backgroundMdp;
+ RegisterDumpProvider(&backgroundMdp, nullptr, kDefaultOptions,
+ kBackgroundButNotSummaryWhitelistedMDPName);
+
+ EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory);
+ EXPECT_CALL(global_dump_handler_, RequestGlobalMemoryDump(_, _)).Times(1);
+ EXPECT_CALL(backgroundMdp, OnMemoryDump(_, _)).Times(0);
+ EXPECT_CALL(summaryMdp, OnMemoryDump(_, _)).Times(1);
+ RequestGlobalDumpAndWait(MemoryDumpType::SUMMARY_ONLY,
+ MemoryDumpLevelOfDetail::BACKGROUND);
+ DisableTracing();
+}
+
TEST_F(MemoryDumpManagerTest, SummaryOnlyDumpsArentAddedToTrace) {
using trace_analyzer::Query;
InitializeMemoryDumpManager(false /* is_coordinator */);
+ SetDumpProviderSummaryWhitelistForTesting(kTestMDPWhitelistForSummary);
SetDumpProviderWhitelistForTesting(kTestMDPWhitelist);
// Standard provider with default options (create dump for current process).
« no previous file with comments | « base/trace_event/memory_dump_manager.cc ('k') | base/trace_event/memory_dump_provider_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698