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

Side by Side Diff: chrome/browser/metrics/metrics_memory_details.h

Issue 823533004: Move memory histograms generation to MetricsMemoryDetails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_
6 #define CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_
7
8 #include <map>
9
10 #include "base/callback.h"
11 #include "chrome/browser/memory_details.h"
12
13 // MemoryGrowthTracker tracks latest metrics about record time and memory usage
14 // at that time per process.
15 class MemoryGrowthTracker {
16 public:
17 MemoryGrowthTracker();
18 ~MemoryGrowthTracker();
19
20 // If 30 minutes have passed since last UMA record, UpdateSample() computes
21 // a difference between current memory usage |sample| of process |pid| and
22 // stored memory usage at the time of last UMA record. Then, it updates the
23 // stored memory usage to |sample|, stores the difference in |diff| and
24 // returns true.
25 // If no memory usage of |pid| has not been recorded so far or 30 minutes
26 // have not passed since last record, it just returns false.
27 // |sample| is memory usage in kB.
28 bool UpdateSample(base::ProcessId pid, int sample, int* diff);
29
30 private:
31 // Latest metrics about record time and memory usage at that time per process.
32 // The second values of |memory_sizes_| are in kB.
33 std::map<base::ProcessId, base::TimeTicks> times_;
34 std::map<base::ProcessId, int> memory_sizes_;
35
36 DISALLOW_COPY_AND_ASSIGN(MemoryGrowthTracker);
37 };
38
39 // Handles asynchronous fetching of memory details.
40 // Will run the provided task after finished.
Lei Zhang 2015/01/17 01:41:53 nit: task -> callback, "after finished" -> "after
Alexei Svitkine (slow) 2015/01/17 06:06:21 Done.
41 class MetricsMemoryDetails : public MemoryDetails {
42 public:
43 MetricsMemoryDetails(const base::Closure& callback,
44 MemoryGrowthTracker* memory_growth_tracker);
45
46 protected:
47 ~MetricsMemoryDetails() override;
48
49 // MemoryDetails:
50 void OnDetailsAvailable() override;
51
52 private:
53 // Updates the global histograms for tracking memory usage.
54 void UpdateHistograms();
55
56 #if defined(OS_CHROMEOS)
57 void UpdateSwapHistograms();
58 #endif
59
60 base::Closure callback_;
61
62 // A pointer to MemoryGrowthTracker which is contained in a longer-lived
63 // owner of MetricsMemoryDetails, for example, ChromeMetricsServiceClient.
64 // If it is null, nothing is tracked.
65 MemoryGrowthTracker* memory_growth_tracker_;
66
67 DISALLOW_COPY_AND_ASSIGN(MetricsMemoryDetails);
68 };
69
70 #endif // CHROME_BROWSER_METRICS_METRICS_MEMORY_DETAILS_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.cc ('k') | chrome/browser/metrics/metrics_memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698