OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/trace_event/memory_dump_manager.h" | 5 #include "base/trace_event/memory_dump_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 EnableTracingWithTraceConfig( | 884 EnableTracingWithTraceConfig( |
885 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(1, 5)); | 885 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(1, 5)); |
886 EXPECT_FALSE(IsPeriodicDumpingEnabled()); | 886 EXPECT_FALSE(IsPeriodicDumpingEnabled()); |
887 DisableTracing(); | 887 DisableTracing(); |
888 } | 888 } |
889 | 889 |
890 TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) { | 890 TEST_F(MemoryDumpManagerTest, TraceConfigExpectationsWhenIsCoordinator) { |
891 InitializeMemoryDumpManagerForInProcessTesting(true /* is_coordinator */); | 891 InitializeMemoryDumpManagerForInProcessTesting(true /* is_coordinator */); |
892 | 892 |
893 // Enabling memory-infra with the legacy TraceConfig (category filter) in | 893 // Enabling memory-infra with the legacy TraceConfig (category filter) in |
894 // a coordinator process should enable periodic dumps. | 894 // a coordinator process should not enable periodic dumps. |
895 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); | 895 EnableTracingWithLegacyCategories(MemoryDumpManager::kTraceCategory); |
| 896 EXPECT_FALSE(IsPeriodicDumpingEnabled()); |
| 897 DisableTracing(); |
| 898 |
| 899 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator |
| 900 // process while specifying a "memory_dump_config" section should enable |
| 901 // periodic dumps. This is to preserve the behavior chrome://tracing UI, that |
| 902 // is: ticking memory-infra should dump periodically with an explicit config. |
| 903 EnableTracingWithTraceConfig( |
| 904 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers(100, 5)); |
896 EXPECT_TRUE(IsPeriodicDumpingEnabled()); | 905 EXPECT_TRUE(IsPeriodicDumpingEnabled()); |
897 DisableTracing(); | 906 DisableTracing(); |
898 | 907 |
899 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator | |
900 // process without specifying any "memory_dump_config" section should enable | |
901 // periodic dumps. This is to preserve the behavior chrome://tracing UI, that | |
902 // is: ticking memory-infra should dump periodically with the default config. | |
903 EnableTracingWithTraceConfig( | |
904 TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); | |
905 EXPECT_TRUE(IsPeriodicDumpingEnabled()); | |
906 DisableTracing(); | |
907 | |
908 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator | 908 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator |
909 // process with an empty "memory_dump_config" should NOT enable periodic | 909 // process with an empty "memory_dump_config" should NOT enable periodic |
910 // dumps. This is the way telemetry is supposed to use memory-infra with | 910 // dumps. This is the way telemetry is supposed to use memory-infra with |
911 // only explicitly triggered dumps. | 911 // only explicitly triggered dumps. |
912 EnableTracingWithTraceConfig( | 912 EnableTracingWithTraceConfig( |
913 TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers()); | 913 TraceConfigMemoryTestUtil::GetTraceConfig_EmptyTriggers()); |
914 EXPECT_FALSE(IsPeriodicDumpingEnabled()); | 914 EXPECT_FALSE(IsPeriodicDumpingEnabled()); |
915 DisableTracing(); | 915 DisableTracing(); |
916 | 916 |
917 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator | 917 // Enabling memory-infra with the new (JSON) TraceConfig in a coordinator |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 // partition_alloc has partition_alloc/allocated_objects/* which is a subset | 1290 // partition_alloc has partition_alloc/allocated_objects/* which is a subset |
1291 // of partition_alloc/partitions/* so we only count the latter. | 1291 // of partition_alloc/partitions/* so we only count the latter. |
1292 EXPECT_EQ(4u, result->chrome_dump.partition_alloc_total_kb); | 1292 EXPECT_EQ(4u, result->chrome_dump.partition_alloc_total_kb); |
1293 | 1293 |
1294 // resident_set_kb should read from process_totals. | 1294 // resident_set_kb should read from process_totals. |
1295 EXPECT_EQ(5u, result->os_dump.resident_set_kb); | 1295 EXPECT_EQ(5u, result->os_dump.resident_set_kb); |
1296 }; | 1296 }; |
1297 | 1297 |
1298 } // namespace trace_event | 1298 } // namespace trace_event |
1299 } // namespace base | 1299 } // namespace base |
OLD | NEW |