| 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_peak_detector.h" | 5 #include "base/trace_event/memory_peak_detector.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 void SetUp() override { | 78 void SetUp() override { |
| 79 get_mdp_call_count_ = 0; | 79 get_mdp_call_count_ = 0; |
| 80 RestartThreadAndReinitializePeakDetector(); | 80 RestartThreadAndReinitializePeakDetector(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void TearDown() override { | 83 void TearDown() override { |
| 84 peak_detector_->TearDown(); | 84 peak_detector_->TearDown(); |
| 85 bg_thread_->FlushForTesting(); | 85 bg_thread_->FlushForTesting(); |
| 86 EXPECT_EQ(MemoryPeakDetector::NOT_INITIALIZED, GetPeakDetectorState()); | 86 EXPECT_EQ(MemoryPeakDetector::NOT_INITIALIZED, GetPeakDetectorState()); |
| 87 bg_thread_.reset(); |
| 87 dump_providers_.clear(); | 88 dump_providers_.clear(); |
| 88 } | 89 } |
| 89 | 90 |
| 90 // Calls MemoryPeakDetector::state_for_testing() on the bg thread and returns | 91 // Calls MemoryPeakDetector::state_for_testing() on the bg thread and returns |
| 91 // the result on the current thread. | 92 // the result on the current thread. |
| 92 MemoryPeakDetector::State GetPeakDetectorState() { | 93 MemoryPeakDetector::State GetPeakDetectorState() { |
| 93 WaitableEvent evt(WaitableEvent::ResetPolicy::MANUAL, | 94 WaitableEvent evt(WaitableEvent::ResetPolicy::MANUAL, |
| 94 WaitableEvent::InitialState::NOT_SIGNALED); | 95 WaitableEvent::InitialState::NOT_SIGNALED); |
| 95 MemoryPeakDetector::State res = MemoryPeakDetector::NOT_INITIALIZED; | 96 MemoryPeakDetector::State res = MemoryPeakDetector::NOT_INITIALIZED; |
| 96 auto get_fn = [](MemoryPeakDetector* peak_detector, WaitableEvent* evt, | 97 auto get_fn = [](MemoryPeakDetector* peak_detector, WaitableEvent* evt, |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 peak_detector->Clear(); | 520 peak_detector->Clear(); |
| 520 return PollFunctionThatCausesPeakViaStdDev(sample_idx); | 521 return PollFunctionThatCausesPeakViaStdDev(sample_idx); |
| 521 }, | 522 }, |
| 522 Unretained(&*peak_detector_)); | 523 Unretained(&*peak_detector_)); |
| 523 uint32_t num_peaks = RunWithCustomPollFunction(kConfig, kNumSamples, poll_fn); | 524 uint32_t num_peaks = RunWithCustomPollFunction(kConfig, kNumSamples, poll_fn); |
| 524 EXPECT_EQ(0u, num_peaks); | 525 EXPECT_EQ(0u, num_peaks); |
| 525 } | 526 } |
| 526 | 527 |
| 527 } // namespace trace_event | 528 } // namespace trace_event |
| 528 } // namespace base | 529 } // namespace base |
| OLD | NEW |