| 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 <vector> | 10 #include <vector> |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 EnableTracingWithTraceConfig( | 888 EnableTracingWithTraceConfig( |
| 889 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers( | 889 TraceConfigMemoryTestUtil::GetTraceConfig_PeriodicTriggers( |
| 890 kLightDumpPeriodMs, kHeavyDumpPeriodMs)); | 890 kLightDumpPeriodMs, kHeavyDumpPeriodMs)); |
| 891 run_loop.Run(); | 891 run_loop.Run(); |
| 892 DisableTracing(); | 892 DisableTracing(); |
| 893 } | 893 } |
| 894 | 894 |
| 895 // Tests against race conditions that might arise when disabling tracing in the | 895 // Tests against race conditions that might arise when disabling tracing in the |
| 896 // middle of a global memory dump. | 896 // middle of a global memory dump. |
| 897 TEST_F(MemoryDumpManagerTest, DisableTracingWhileDumping) { | 897 TEST_F(MemoryDumpManagerTest, DisableTracingWhileDumping) { |
| 898 base::WaitableEvent tracing_disabled_event(false, false); | 898 base::WaitableEvent tracing_disabled_event( |
| 899 WaitableEvent::ResetPolicy::AUTOMATIC, |
| 900 WaitableEvent::InitialState::NOT_SIGNALED); |
| 899 InitializeMemoryDumpManager(false /* is_coordinator */); | 901 InitializeMemoryDumpManager(false /* is_coordinator */); |
| 900 | 902 |
| 901 // Register a bound dump provider. | 903 // Register a bound dump provider. |
| 902 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); | 904 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); |
| 903 mdp_thread->Start(); | 905 mdp_thread->Start(); |
| 904 MockMemoryDumpProvider mdp_with_affinity; | 906 MockMemoryDumpProvider mdp_with_affinity; |
| 905 RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(), | 907 RegisterDumpProvider(&mdp_with_affinity, mdp_thread->task_runner(), |
| 906 kDefaultOptions); | 908 kDefaultOptions); |
| 907 | 909 |
| 908 // Register also an unbound dump provider. Unbound dump providers are always | 910 // Register also an unbound dump provider. Unbound dump providers are always |
| (...skipping 29 matching lines...) Expand all Loading... |
| 938 DisableTracing(); | 940 DisableTracing(); |
| 939 tracing_disabled_event.Signal(); | 941 tracing_disabled_event.Signal(); |
| 940 run_loop.Run(); | 942 run_loop.Run(); |
| 941 | 943 |
| 942 EXPECT_FALSE(last_callback_success_); | 944 EXPECT_FALSE(last_callback_success_); |
| 943 } | 945 } |
| 944 | 946 |
| 945 // Tests against race conditions that can happen if tracing is disabled before | 947 // Tests against race conditions that can happen if tracing is disabled before |
| 946 // the CreateProcessDump() call. Real-world regression: crbug.com/580295 . | 948 // the CreateProcessDump() call. Real-world regression: crbug.com/580295 . |
| 947 TEST_F(MemoryDumpManagerTest, DisableTracingRightBeforeStartOfDump) { | 949 TEST_F(MemoryDumpManagerTest, DisableTracingRightBeforeStartOfDump) { |
| 948 base::WaitableEvent tracing_disabled_event(false, false); | 950 base::WaitableEvent tracing_disabled_event( |
| 951 WaitableEvent::ResetPolicy::AUTOMATIC, |
| 952 WaitableEvent::InitialState::NOT_SIGNALED); |
| 949 InitializeMemoryDumpManager(false /* is_coordinator */); | 953 InitializeMemoryDumpManager(false /* is_coordinator */); |
| 950 | 954 |
| 951 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); | 955 std::unique_ptr<Thread> mdp_thread(new Thread("test thread")); |
| 952 mdp_thread->Start(); | 956 mdp_thread->Start(); |
| 953 | 957 |
| 954 // Create both same-thread MDP and another MDP with dedicated thread | 958 // Create both same-thread MDP and another MDP with dedicated thread |
| 955 MockMemoryDumpProvider mdp1; | 959 MockMemoryDumpProvider mdp1; |
| 956 RegisterDumpProvider(&mdp1); | 960 RegisterDumpProvider(&mdp1); |
| 957 MockMemoryDumpProvider mdp2; | 961 MockMemoryDumpProvider mdp2; |
| 958 RegisterDumpProvider(&mdp2, mdp_thread->task_runner(), kDefaultOptions); | 962 RegisterDumpProvider(&mdp2, mdp_thread->task_runner(), kDefaultOptions); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); | 1098 EXPECT_CALL(*delegate_, RequestGlobalMemoryDump(_, _)).Times(2); |
| 1095 for (int i = 0; i < 2; ++i) { | 1099 for (int i = 0; i < 2; ++i) { |
| 1096 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, | 1100 RequestGlobalDumpAndWait(MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 1097 MemoryDumpLevelOfDetail::DETAILED); | 1101 MemoryDumpLevelOfDetail::DETAILED); |
| 1098 } | 1102 } |
| 1099 DisableTracing(); | 1103 DisableTracing(); |
| 1100 } | 1104 } |
| 1101 | 1105 |
| 1102 } // namespace trace_event | 1106 } // namespace trace_event |
| 1103 } // namespace base | 1107 } // namespace base |
| OLD | NEW |