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

Unified Diff: base/trace_event/memory_peak_detector.cc

Issue 2799023002: memory-infra: Switch to MemoryPeakDetector and simplify MemoryDumpScheduler (Closed)
Patch Set: rebase bind -> bindonce 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/trace_event/memory_peak_detector.h ('k') | base/trace_event/memory_peak_detector_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/trace_event/memory_peak_detector.cc
diff --git a/base/trace_event/memory_peak_detector.cc b/base/trace_event/memory_peak_detector.cc
index 2423fa3361795846dc0e30b97dd768c4373f0d3f..541959406caddf96690dc13d24573355aedfa558 100644
--- a/base/trace_event/memory_peak_detector.cc
+++ b/base/trace_event/memory_peak_detector.cc
@@ -68,7 +68,7 @@ void MemoryPeakDetector::TearDown() {
if (task_runner_) {
task_runner_->PostTask(
FROM_HERE,
- Bind(&MemoryPeakDetector::TearDownInternal, Unretained(this)));
+ BindOnce(&MemoryPeakDetector::TearDownInternal, Unretained(this)));
}
task_runner_ = nullptr;
}
@@ -78,21 +78,21 @@ void MemoryPeakDetector::Start(MemoryPeakDetector::Config config) {
NOTREACHED();
return;
}
- task_runner_->PostTask(FROM_HERE, Bind(&MemoryPeakDetector::StartInternal,
- Unretained(this), config));
+ task_runner_->PostTask(FROM_HERE, BindOnce(&MemoryPeakDetector::StartInternal,
+ Unretained(this), config));
}
void MemoryPeakDetector::Stop() {
task_runner_->PostTask(
- FROM_HERE, Bind(&MemoryPeakDetector::StopInternal, Unretained(this)));
+ FROM_HERE, BindOnce(&MemoryPeakDetector::StopInternal, Unretained(this)));
}
void MemoryPeakDetector::Throttle() {
if (!task_runner_)
return; // Can be called before Setup().
task_runner_->PostTask(
- FROM_HERE, Bind(&MemoryPeakDetector::ResetPollHistory, Unretained(this),
- true /* keep_last_sample */));
+ FROM_HERE, BindOnce(&MemoryPeakDetector::ResetPollHistory,
+ Unretained(this), true /* keep_last_sample */));
}
void MemoryPeakDetector::NotifyMemoryDumpProvidersChanged() {
@@ -100,8 +100,8 @@ void MemoryPeakDetector::NotifyMemoryDumpProvidersChanged() {
return; // Can be called before Setup().
task_runner_->PostTask(
FROM_HERE,
- Bind(&MemoryPeakDetector::ReloadDumpProvidersAndStartPollingIfNeeded,
- Unretained(this)));
+ BindOnce(&MemoryPeakDetector::ReloadDumpProvidersAndStartPollingIfNeeded,
+ Unretained(this)));
}
void MemoryPeakDetector::StartInternal(MemoryPeakDetector::Config config) {
@@ -124,6 +124,8 @@ void MemoryPeakDetector::StopInternal() {
DCHECK_NE(NOT_INITIALIZED, state_);
state_ = DISABLED;
++generation_;
+ for (const scoped_refptr<MemoryDumpProviderInfo>& mdp_info : dump_providers_)
+ mdp_info->dump_provider->SuspendFastMemoryPolling();
dump_providers_.clear();
}
@@ -149,9 +151,9 @@ void MemoryPeakDetector::ReloadDumpProvidersAndStartPollingIfNeeded() {
if (state_ == ENABLED && !dump_providers_.empty()) {
// It's now time to start polling for realz.
state_ = RUNNING;
- task_runner_->PostTask(FROM_HERE,
- Bind(&MemoryPeakDetector::PollMemoryAndDetectPeak,
- Unretained(this), ++generation_));
+ task_runner_->PostTask(
+ FROM_HERE, BindOnce(&MemoryPeakDetector::PollMemoryAndDetectPeak,
+ Unretained(this), ++generation_));
} else if (state_ == RUNNING && dump_providers_.empty()) {
// Will cause the next PollMemoryAndDetectPeak() task to early return.
state_ = ENABLED;
@@ -201,8 +203,8 @@ void MemoryPeakDetector::PollMemoryAndDetectPeak(uint32_t expected_generation) {
DCHECK_GT(config_.polling_interval_ms, 0u);
SequencedTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
- Bind(&MemoryPeakDetector::PollMemoryAndDetectPeak, Unretained(this),
- expected_generation),
+ BindOnce(&MemoryPeakDetector::PollMemoryAndDetectPeak, Unretained(this),
+ expected_generation),
TimeDelta::FromMilliseconds(config_.polling_interval_ms));
if (!is_peak)
@@ -271,5 +273,16 @@ void MemoryPeakDetector::SetStaticThresholdForTesting(
static_threshold_bytes_ = static_threshold_bytes;
}
+MemoryPeakDetector::MemoryPeakDetector::Config::Config()
+ : Config(0, 0, false) {}
+
+MemoryPeakDetector::MemoryPeakDetector::Config::Config(
+ uint32_t polling_interval_ms,
+ uint32_t min_time_between_peaks_ms,
+ bool enable_verbose_poll_tracing)
+ : polling_interval_ms(polling_interval_ms),
+ min_time_between_peaks_ms(min_time_between_peaks_ms),
+ enable_verbose_poll_tracing(enable_verbose_poll_tracing) {}
+
} // namespace trace_event
} // namespace base
« no previous file with comments | « base/trace_event/memory_peak_detector.h ('k') | base/trace_event/memory_peak_detector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698