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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1263 last_callback_success_ = false; | 1263 last_callback_success_ = false; |
1264 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 1264 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
1265 MemoryDumpLevelOfDetail::DETAILED); | 1265 MemoryDumpLevelOfDetail::DETAILED); |
1266 EXPECT_FALSE(last_callback_success_); | 1266 EXPECT_FALSE(last_callback_success_); |
1267 | 1267 |
1268 ASSERT_TRUE(IsPeriodicDumpingEnabled()); | 1268 ASSERT_TRUE(IsPeriodicDumpingEnabled()); |
1269 run_loop.Run(); | 1269 run_loop.Run(); |
1270 DisableTracing(); | 1270 DisableTracing(); |
1271 } | 1271 } |
1272 | 1272 |
1273 TEST_F(MemoryDumpManagerTest, TestBlacklistedUnsafeUnregistration) { | |
1274 InitializeMemoryDumpManager(false /* is_coordinator */); | |
1275 MockMemoryDumpProvider mdp1; | |
1276 RegisterDumpProvider(&mdp1, nullptr, kDefaultOptions, | |
1277 "BlacklistTestDumpProvider"); | |
1278 // Not calling UnregisterAndDeleteDumpProviderSoon() should not crash. | |
1279 mdm_->UnregisterDumpProvider(&mdp1); | |
1280 | |
1281 Thread thread("test thread"); | |
1282 thread.Start(); | |
1283 RegisterDumpProvider(&mdp1, thread.task_runner(), kDefaultOptions, | |
1284 "BlacklistTestDumpProvider"); | |
1285 // Unregistering on wrong thread should not crash. | |
1286 mdm_->UnregisterDumpProvider(&mdp1); | |
1287 thread.Stop(); | |
1288 } | |
1289 | |
1290 // Tests that we can manually take a dump without enabling tracing. | 1273 // Tests that we can manually take a dump without enabling tracing. |
1291 TEST_F(MemoryDumpManagerTest, DumpWithTracingDisabled) { | 1274 TEST_F(MemoryDumpManagerTest, DumpWithTracingDisabled) { |
1292 InitializeMemoryDumpManager(false /* is_coordinator */); | 1275 InitializeMemoryDumpManager(false /* is_coordinator */); |
1293 MockMemoryDumpProvider mdp; | 1276 MockMemoryDumpProvider mdp; |
1294 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); | 1277 RegisterDumpProvider(&mdp, ThreadTaskRunnerHandle::Get()); |
1295 | 1278 |
1296 DisableTracing(); | 1279 DisableTracing(); |
1297 | 1280 |
1298 const TraceConfig& trace_config = | 1281 const TraceConfig& trace_config = |
1299 TraceConfig(TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); | 1282 TraceConfig(TraceConfigMemoryTestUtil::GetTraceConfig_NoTriggers()); |
(...skipping 13 matching lines...) Expand all Loading... |
1313 // successful we also managed to add the dump to the trace. | 1296 // successful we also managed to add the dump to the trace. |
1314 EXPECT_FALSE(last_callback_success_); | 1297 EXPECT_FALSE(last_callback_success_); |
1315 | 1298 |
1316 mdm_->Disable(); | 1299 mdm_->Disable(); |
1317 | 1300 |
1318 mdm_->UnregisterDumpProvider(&mdp); | 1301 mdm_->UnregisterDumpProvider(&mdp); |
1319 } | 1302 } |
1320 | 1303 |
1321 } // namespace trace_event | 1304 } // namespace trace_event |
1322 } // namespace base | 1305 } // namespace base |
OLD | NEW |