| 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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 MockMemoryDumpProvider mdp; | 1305 MockMemoryDumpProvider mdp; |
| 1306 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); | 1306 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); |
| 1307 | 1307 |
| 1308 DisableTracing(); | 1308 DisableTracing(); |
| 1309 | 1309 |
| 1310 const TraceConfig& trace_config = | 1310 const TraceConfig& trace_config = |
| 1311 TraceConfig(TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); | 1311 TraceConfig(TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); |
| 1312 const TraceConfig::MemoryDumpConfig& memory_dump_config = | 1312 const TraceConfig::MemoryDumpConfig& memory_dump_config = |
| 1313 trace_config.memory_dump_config(); | 1313 trace_config.memory_dump_config(); |
| 1314 | 1314 |
| 1315 mdm_->Enable(memory_dump_config); | 1315 mdm_->SetupForTracing(memory_dump_config); |
| 1316 | 1316 |
| 1317 EXPECT_CALL(global_dump_handler_, RequestGlobalMemoryDump(_, _)).Times(3); | 1317 EXPECT_CALL(global_dump_handler_, RequestGlobalMemoryDump(_, _)).Times(3); |
| 1318 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true)); | 1318 EXPECT_CALL(mdp, OnMemoryDump(_, _)).Times(3).WillRepeatedly(Return(true)); |
| 1319 last_callback_success_ = true; | 1319 last_callback_success_ = true; |
| 1320 for (int i = 0; i < 3; ++i) | 1320 for (int i = 0; i < 3; ++i) |
| 1321 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 1321 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 1322 MemoryDumpLevelOfDetail::DETAILED); | 1322 MemoryDumpLevelOfDetail::DETAILED); |
| 1323 // The callback result should actually be false since (for the moment at | 1323 // The callback result should actually be false since (for the moment at |
| 1324 // least) a true result means that as well as the dump generally being | 1324 // least) a true result means that as well as the dump generally being |
| 1325 // successful we also managed to add the dump to the trace. | 1325 // successful we also managed to add the dump to the trace. |
| 1326 EXPECT_FALSE(last_callback_success_); | 1326 EXPECT_FALSE(last_callback_success_); |
| 1327 | 1327 |
| 1328 mdm_->Disable(); | 1328 mdm_->TeardownForTracing(); |
| 1329 | 1329 |
| 1330 mdm_->UnregisterDumpProvider(&mdp); | 1330 mdm_->UnregisterDumpProvider(&mdp); |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 TEST_F(MemoryDumpManagerTest, TestSummaryComputation) { | 1333 TEST_F(MemoryDumpManagerTest, TestSummaryComputation) { |
| 1334 InitializeMemoryDumpManager(false /* is_coordinator */); | 1334 InitializeMemoryDumpManager(false /* is_coordinator */); |
| 1335 MockMemoryDumpProvider mdp; | 1335 MockMemoryDumpProvider mdp; |
| 1336 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); | 1336 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); |
| 1337 | 1337 |
| 1338 const HeapProfilerSerializationState* heap_profiler_serialization_state = | 1338 const HeapProfilerSerializationState* heap_profiler_serialization_state = |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1405 EXPECT_EQ(3u, result.chrome_dump.v8_total_kb); | 1405 EXPECT_EQ(3u, result.chrome_dump.v8_total_kb); |
| 1406 // partition_alloc has partition_alloc/allocated_objects/* which is a subset | 1406 // partition_alloc has partition_alloc/allocated_objects/* which is a subset |
| 1407 // of partition_alloc/partitions/* so we only count the latter. | 1407 // of partition_alloc/partitions/* so we only count the latter. |
| 1408 EXPECT_EQ(4u, result.chrome_dump.partition_alloc_total_kb); | 1408 EXPECT_EQ(4u, result.chrome_dump.partition_alloc_total_kb); |
| 1409 // resident_set_kb should read from process_totals. | 1409 // resident_set_kb should read from process_totals. |
| 1410 EXPECT_EQ(5u, result.os_dump.resident_set_kb); | 1410 EXPECT_EQ(5u, result.os_dump.resident_set_kb); |
| 1411 }; | 1411 }; |
| 1412 | 1412 |
| 1413 } // namespace trace_event | 1413 } // namespace trace_event |
| 1414 } // namespace base | 1414 } // namespace base |
| OLD | NEW |