Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: base/trace_event/memory_peak_detector_unittest.cc

Issue 2799023002: memory-infra: Switch to MemoryPeakDetector and simplify MemoryDumpScheduler (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698