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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
12 #include "base/threading/sequenced_task_runner_handle.h" | 12 #include "base/threading/sequenced_task_runner_handle.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "base/trace_event/memory_dump_manager.h" | 14 #include "base/trace_event/memory_dump_manager.h" |
15 #include "base/trace_event/memory_dump_provider_info.h" | 15 #include "base/trace_event/memory_dump_provider_info.h" |
16 #include "base/trace_event/trace_event.h" | 16 #include "base/trace_event/trace_event.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 namespace trace_event { | 19 namespace trace_event { |
20 | 20 |
21 // static | 21 // static |
22 MemoryPeakDetector* MemoryPeakDetector::GetInstance() { | 22 MemoryPeakDetector* MemoryPeakDetector::GetInstance() { |
23 static MemoryPeakDetector* instance = new MemoryPeakDetector(); | 23 static MemoryPeakDetector* instance = new MemoryPeakDetector(); |
24 return instance; | 24 return instance; |
25 } | 25 } |
26 | 26 |
| 27 // TODO call SuspendFastMemoryPolling, both when unregistering and stopping. |
| 28 |
27 MemoryPeakDetector::MemoryPeakDetector() | 29 MemoryPeakDetector::MemoryPeakDetector() |
28 : generation_(0), | 30 : generation_(0), |
29 state_(NOT_INITIALIZED), | 31 state_(NOT_INITIALIZED), |
30 poll_tasks_count_for_testing_(0) {} | 32 poll_tasks_count_for_testing_(0) {} |
31 | 33 |
32 MemoryPeakDetector::~MemoryPeakDetector() { | 34 MemoryPeakDetector::~MemoryPeakDetector() { |
33 // This is hit only in tests, in which case the test is expected to TearDown() | 35 // This is hit only in tests, in which case the test is expected to TearDown() |
34 // cleanly and not leave the peak detector running. | 36 // cleanly and not leave the peak detector running. |
35 DCHECK_EQ(NOT_INITIALIZED, state_); | 37 DCHECK_EQ(NOT_INITIALIZED, state_); |
36 } | 38 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 249 } |
248 | 250 |
249 void MemoryPeakDetector::SetStaticThresholdForTesting( | 251 void MemoryPeakDetector::SetStaticThresholdForTesting( |
250 uint64_t static_threshold_bytes) { | 252 uint64_t static_threshold_bytes) { |
251 DCHECK_EQ(DISABLED, state_); | 253 DCHECK_EQ(DISABLED, state_); |
252 static_threshold_bytes_ = static_threshold_bytes; | 254 static_threshold_bytes_ = static_threshold_bytes; |
253 } | 255 } |
254 | 256 |
255 } // namespace trace_event | 257 } // namespace trace_event |
256 } // namespace base | 258 } // namespace base |
OLD | NEW |