| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_scheduler.h" | 5 #include "base/trace_event/memory_dump_scheduler.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const double time_ms = (TimeTicks::Now() - tstart).InMillisecondsF(); | 81 const double time_ms = (TimeTicks::Now() - tstart).InMillisecondsF(); |
| 82 | 82 |
| 83 // It takes N-1 ms to perform N ticks of 1ms each. | 83 // It takes N-1 ms to perform N ticks of 1ms each. |
| 84 EXPECT_GE(time_ms, kPeriodMs * (kTicks - 1)); | 84 EXPECT_GE(time_ms, kPeriodMs * (kTicks - 1)); |
| 85 | 85 |
| 86 // Check that stopping twice doesn't cause any problems. | 86 // Check that stopping twice doesn't cause any problems. |
| 87 scheduler_->Stop(); | 87 scheduler_->Stop(); |
| 88 scheduler_->Stop(); | 88 scheduler_->Stop(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(MemoryDumpSchedulerTest, MultipleTriggers) { | 91 // Flaky on Linux. http://crbug.com/732861 |
| 92 #if defined(OS_LINUX) |
| 93 #define MAYBE_MultipleTriggers DISABLED_MultipleTriggers |
| 94 #else |
| 95 #define MAYBE_MultipleTriggers MultipleTriggers |
| 96 #endif |
| 97 TEST_F(MemoryDumpSchedulerTest, MAYBE_MultipleTriggers) { |
| 92 const uint32_t kPeriodLightMs = 3; | 98 const uint32_t kPeriodLightMs = 3; |
| 93 const uint32_t kPeriodDetailedMs = 9; | 99 const uint32_t kPeriodDetailedMs = 9; |
| 94 WaitableEvent evt(WaitableEvent::ResetPolicy::MANUAL, | 100 WaitableEvent evt(WaitableEvent::ResetPolicy::MANUAL, |
| 95 WaitableEvent::InitialState::NOT_SIGNALED); | 101 WaitableEvent::InitialState::NOT_SIGNALED); |
| 96 MemoryDumpScheduler::Config config; | 102 MemoryDumpScheduler::Config config; |
| 97 const MemoryDumpLevelOfDetail kLight = MemoryDumpLevelOfDetail::LIGHT; | 103 const MemoryDumpLevelOfDetail kLight = MemoryDumpLevelOfDetail::LIGHT; |
| 98 const MemoryDumpLevelOfDetail kDetailed = MemoryDumpLevelOfDetail::DETAILED; | 104 const MemoryDumpLevelOfDetail kDetailed = MemoryDumpLevelOfDetail::DETAILED; |
| 99 config.triggers.push_back({kLight, kPeriodLightMs}); | 105 config.triggers.push_back({kLight, kPeriodLightMs}); |
| 100 config.triggers.push_back({kDetailed, kPeriodDetailedMs}); | 106 config.triggers.push_back({kDetailed, kPeriodDetailedMs}); |
| 101 config.callback = Bind(&CallbackWrapper::OnTick, Unretained(&on_tick_)); | 107 config.callback = Bind(&CallbackWrapper::OnTick, Unretained(&on_tick_)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 Invoke([&evt, expected_task_runner](MemoryDumpLevelOfDetail) { | 198 Invoke([&evt, expected_task_runner](MemoryDumpLevelOfDetail) { |
| 193 EXPECT_TRUE(expected_task_runner->RunsTasksOnCurrentThread()); | 199 EXPECT_TRUE(expected_task_runner->RunsTasksOnCurrentThread()); |
| 194 evt.Signal(); | 200 evt.Signal(); |
| 195 })); | 201 })); |
| 196 evt.Wait(); | 202 evt.Wait(); |
| 197 scheduler_->Stop(); | 203 scheduler_->Stop(); |
| 198 } | 204 } |
| 199 | 205 |
| 200 } // namespace trace_event | 206 } // namespace trace_event |
| 201 } // namespace base | 207 } // namespace base |
| OLD | NEW |