Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_ | 5 #ifndef CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_ |
| 6 #define CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_ | 6 #define CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/memory_details.h" | 13 #include "chrome/browser/memory_details.h" |
| 14 | 14 |
| 15 // MemoryGrowthTracker tracks latest metrics about record time and memory usage | 15 // MemoryGrowthTracker tracks latest metrics about record time and memory usage |
| 16 // at that time per process. | 16 // at that time per process. |
| 17 class MemoryGrowthTracker { | 17 class MemoryGrowthTracker { |
| 18 public: | 18 public: |
| 19 MemoryGrowthTracker(); | 19 MemoryGrowthTracker(); |
| 20 ~MemoryGrowthTracker(); | 20 ~MemoryGrowthTracker(); |
|
Alexei Svitkine (slow)
2016/10/11 16:47:48
Make this virtual and mark it override in the subc
mwlodar
2016/10/12 21:50:51
Done.
| |
| 21 | 21 |
| 22 // If 30 minutes have passed since last UMA record, UpdateSample() computes | 22 // If 30 minutes have passed since last UMA record, UpdateSample() computes |
| 23 // a difference between current memory usage |sample| of process |pid| and | 23 // a difference between current memory usage |sample| of process |pid| and |
| 24 // stored memory usage at the time of last UMA record. Then, it updates the | 24 // stored memory usage at the time of last UMA record. Then, it updates the |
| 25 // stored memory usage to |sample|, stores the difference in |diff| and | 25 // stored memory usage to |sample|, stores the difference in |diff| and |
| 26 // returns true. | 26 // returns true. |
| 27 // If no memory usage of |pid| has not been recorded so far or 30 minutes | 27 // If no memory usage of |pid| has not been recorded so far or 30 minutes |
| 28 // have not passed since last record, it just returns false. | 28 // have not passed since last record, it just returns false. |
| 29 // |sample| is memory usage in kB. | 29 // |sample| is memory usage in kB. |
| 30 bool UpdateSample(base::ProcessId pid, int sample, int* diff); | 30 virtual bool UpdateSample(base::ProcessId pid, int sample, int* diff); |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 // Latest metrics about record time and memory usage at that time per process. | 33 // Latest metrics about record time and memory usage at that time per process. |
| 34 // The second values of |memory_sizes_| are in kB. | 34 // The second values of |memory_sizes_| are in kB. |
| 35 std::map<base::ProcessId, base::TimeTicks> times_; | 35 std::map<base::ProcessId, base::TimeTicks> times_; |
| 36 std::map<base::ProcessId, int> memory_sizes_; | 36 std::map<base::ProcessId, int> memory_sizes_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(MemoryGrowthTracker); | 38 DISALLOW_COPY_AND_ASSIGN(MemoryGrowthTracker); |
| 39 }; | 39 }; |
| 40 | 40 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 64 | 64 |
| 65 // A pointer to MemoryGrowthTracker which is contained in a longer-lived | 65 // A pointer to MemoryGrowthTracker which is contained in a longer-lived |
| 66 // owner of MetricsMemoryDetails, for example, ChromeMetricsServiceClient. | 66 // owner of MetricsMemoryDetails, for example, ChromeMetricsServiceClient. |
| 67 // If it is null, nothing is tracked. | 67 // If it is null, nothing is tracked. |
| 68 MemoryGrowthTracker* memory_growth_tracker_; | 68 MemoryGrowthTracker* memory_growth_tracker_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); | 70 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 #endif // CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_ | 73 #endif // CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_ |
| OLD | NEW |