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

Side by Side Diff: content/browser/memory/swap_metrics_observer.h

Issue 2824133002: Record swap metrics (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_BROWSER_MEMORY_SWAP_METRICS_OBSERVER_H_
6 #define CONTENT_BROWSER_MEMORY_SWAP_METRICS_OBSERVER_H_
7
8 #include "base/memory/singleton.h"
9 #include "base/time/time.h"
10 #include "base/timer/timer.h"
11
12 namespace content {
13
14 // This class observes system's swapping behavior to collect metrics.
15 // Metrics can be platform-specific.
16 class SwapMetricsObserver {
17 public:
18 // This returns nullptr when swap metrics are not available on the system.
19 static SwapMetricsObserver* GetInstance();
20
21 // Starts observing swap metrics.
22 void Start();
23
24 // Stop observing swap metrics.
25 void Stop();
26
27 protected:
28 SwapMetricsObserver();
29 virtual ~SwapMetricsObserver();
30
31 // Periodically called to update swap metrics.
32 void UpdateMetrics();
33
34 // Platform-dependent parts of UpdateMetrics(). |interval| is the elapsed time
35 // since the last UpdateMetrics() call. |interval| will be zero when this
36 // function is called for the first time.
37 virtual void UpdateMetricsInternal(base::TimeDelta interval) = 0;
38
39 private:
40 // The interval between metrics updates.
41 base::TimeDelta update_interval_;
42
43 // A periodic timer to update swap metrics.
44 base::RepeatingTimer timer_;
45
46 // Holds the last TimeTicks when swap metrics are updated.
47 base::TimeTicks last_ticks_;
48
49 DISALLOW_COPY_AND_ASSIGN(SwapMetricsObserver);
50 };
51
52 } // namespace
53
54 #endif // CONTENT_BROWSER_MEMORY_SWAP_METRICS_OBSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698