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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/sys_info.h" | 9 #include "base/sys_info.h" |
10 #include "base/threading/sequenced_task_runner_handle.h" | 10 #include "base/threading/sequenced_task_runner_handle.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // ReloadDumpProvidersAndStartPollingIfNeeded(). | 111 // ReloadDumpProvidersAndStartPollingIfNeeded(). |
112 // Depending on the sandbox model, it is possible that no polling-capable | 112 // Depending on the sandbox model, it is possible that no polling-capable |
113 // dump providers will be ever available. | 113 // dump providers will be ever available. |
114 ReloadDumpProvidersAndStartPollingIfNeeded(); | 114 ReloadDumpProvidersAndStartPollingIfNeeded(); |
115 } | 115 } |
116 | 116 |
117 void MemoryPeakDetector::StopInternal() { | 117 void MemoryPeakDetector::StopInternal() { |
118 DCHECK_NE(NOT_INITIALIZED, state_); | 118 DCHECK_NE(NOT_INITIALIZED, state_); |
119 state_ = DISABLED; | 119 state_ = DISABLED; |
120 ++generation_; | 120 ++generation_; |
| 121 for (const scoped_refptr<MemoryDumpProviderInfo>& mdp_info : dump_providers_) |
| 122 mdp_info->dump_provider->SuspendFastMemoryPolling(); |
121 dump_providers_.clear(); | 123 dump_providers_.clear(); |
122 } | 124 } |
123 | 125 |
124 void MemoryPeakDetector::TearDownInternal() { | 126 void MemoryPeakDetector::TearDownInternal() { |
125 StopInternal(); | 127 StopInternal(); |
126 get_dump_providers_function_.Reset(); | 128 get_dump_providers_function_.Reset(); |
127 on_peak_detected_callback_.Reset(); | 129 on_peak_detected_callback_.Reset(); |
128 state_ = NOT_INITIALIZED; | 130 state_ = NOT_INITIALIZED; |
129 } | 131 } |
130 | 132 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 config_.polling_interval_ms; | 251 config_.polling_interval_ms; |
250 } | 252 } |
251 } | 253 } |
252 | 254 |
253 void MemoryPeakDetector::SetStaticThresholdForTesting( | 255 void MemoryPeakDetector::SetStaticThresholdForTesting( |
254 uint64_t static_threshold_bytes) { | 256 uint64_t static_threshold_bytes) { |
255 DCHECK_EQ(DISABLED, state_); | 257 DCHECK_EQ(DISABLED, state_); |
256 static_threshold_bytes_ = static_threshold_bytes; | 258 static_threshold_bytes_ = static_threshold_bytes; |
257 } | 259 } |
258 | 260 |
| 261 MemoryPeakDetector::MemoryPeakDetector::Config::Config() |
| 262 : Config(0, 0, false) {} |
| 263 |
| 264 MemoryPeakDetector::MemoryPeakDetector::Config::Config( |
| 265 uint32_t polling_interval_ms, |
| 266 uint32_t min_time_between_peaks_ms, |
| 267 bool enable_verbose_poll_tracing) |
| 268 : polling_interval_ms(polling_interval_ms), |
| 269 min_time_between_peaks_ms(min_time_between_peaks_ms), |
| 270 enable_verbose_poll_tracing(enable_verbose_poll_tracing) {} |
| 271 |
259 } // namespace trace_event | 272 } // namespace trace_event |
260 } // namespace base | 273 } // namespace base |
OLD | NEW |