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 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 MockMemoryDumpProvider mdp; | 1251 MockMemoryDumpProvider mdp; |
1252 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); | 1252 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); |
1253 | 1253 |
1254 DisableTracing(); | 1254 DisableTracing(); |
1255 | 1255 |
1256 const TraceConfig& trace_config = | 1256 const TraceConfig& trace_config = |
1257 TraceConfig(TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); | 1257 TraceConfig(TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); |
1258 const TraceConfig::MemoryDumpConfig& memory_dump_config = | 1258 const TraceConfig::MemoryDumpConfig& memory_dump_config = |
1259 trace_config.memory_dump_config(); | 1259 trace_config.memory_dump_config(); |
1260 | 1260 |
1261 mdm_->Enable(memory_dump_config); | 1261 mdm_->SetupForTracing(memory_dump_config); |
1262 | 1262 |
1263 EXPECT_CALL(global_dump_handler_, RequestGlobalMemoryDump(_, _)).Times(3); | 1263 EXPECT_CALL(global_dump_handler_, RequestGlobalMemoryDump(_, _)).Times(3); |
1264 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true)); | 1264 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true)); |
1265 last_callback_success_ = true; | 1265 last_callback_success_ = true; |
1266 for (int i = 0; i < 3; ++i) | 1266 for (int i = 0; i < 3; ++i) |
1267 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 1267 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
1268 MemoryDumpLevelOfDetail::DETAILED); | 1268 MemoryDumpLevelOfDetail::DETAILED); |
1269 // The callback result should actually be false since (for the moment at | 1269 // The callback result should actually be false since (for the moment at |
1270 // least) a true result means that as well as the dump generally being | 1270 // least) a true result means that as well as the dump generally being |
1271 // successful we also managed to add the dump to the trace. | 1271 // successful we also managed to add the dump to the trace. |
1272 EXPECT_FALSE(last_callback_success_); | 1272 EXPECT_FALSE(last_callback_success_); |
1273 | 1273 |
1274 mdm_->Disable(); | 1274 mdm_->TeardownForTracing(); |
1275 | 1275 |
1276 mdm_->UnregisterDumpProvider(&mdp); | 1276 mdm_->UnregisterDumpProvider(&mdp); |
1277 } | 1277 } |
1278 | 1278 |
1279 // Tests that we can do a dump without enabling/disabling. | 1279 // Tests that we can do a dump without enabling/disabling. |
1280 TEST_F(MemoryDumpManagerTest, DumpWithoutTracing) { | 1280 TEST_F(MemoryDumpManagerTest, DumpWithoutTracing) { |
1281 InitializeMemoryDumpManager(false /* is_coordinator */); | 1281 InitializeMemoryDumpManager(false /* is_coordinator */); |
1282 MockMemoryDumpProvider mdp; | 1282 MockMemoryDumpProvider mdp; |
1283 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); | 1283 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); |
1284 | 1284 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 EXPECT_EQ(3u, result.chrome_dump.v8_total_kb); | 1374 EXPECT_EQ(3u, result.chrome_dump.v8_total_kb); |
1375 // partition_alloc has partition_alloc/allocated_objects/* which is a subset | 1375 // partition_alloc has partition_alloc/allocated_objects/* which is a subset |
1376 // of partition_alloc/partitions/* so we only count the latter. | 1376 // of partition_alloc/partitions/* so we only count the latter. |
1377 EXPECT_EQ(4u, result.chrome_dump.partition_alloc_total_kb); | 1377 EXPECT_EQ(4u, result.chrome_dump.partition_alloc_total_kb); |
1378 // resident_set_kb should read from process_totals. | 1378 // resident_set_kb should read from process_totals. |
1379 EXPECT_EQ(5u, result.os_dump.resident_set_kb); | 1379 EXPECT_EQ(5u, result.os_dump.resident_set_kb); |
1380 }; | 1380 }; |
1381 | 1381 |
1382 } // namespace trace_event | 1382 } // namespace trace_event |
1383 } // namespace base | 1383 } // namespace base |
OLD | NEW |