OLD | NEW |
---|---|
(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 #include "content/browser/memory/swap_metrics_observer.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/threading/thread_task_runner_handle.h" | |
9 | |
10 namespace content { | |
11 | |
12 namespace { | |
13 | |
14 // Time between updating swap rates. | |
15 const int kSwapMetricsIntervalSeconds = 60; | |
16 } | |
Ilya Sherman
2017/04/28 21:10:20
nit: Please leave a blank line before this closing
bashi
2017/05/01 01:14:13
Done.
| |
17 | |
18 SwapMetricsObserver::SwapMetricsObserver() | |
19 : update_interval_( | |
20 base::TimeDelta::FromSeconds(kSwapMetricsIntervalSeconds)) {} | |
21 | |
22 SwapMetricsObserver::~SwapMetricsObserver() {} | |
23 | |
24 void SwapMetricsObserver::Start() { | |
25 timer_.Start(FROM_HERE, update_interval_, this, | |
26 &SwapMetricsObserver::UpdateMetrics); | |
27 } | |
28 | |
29 void SwapMetricsObserver::Stop() { | |
30 last_ticks_ = base::TimeTicks(); | |
31 timer_.Stop(); | |
32 } | |
33 | |
34 void SwapMetricsObserver::UpdateMetrics() { | |
35 base::TimeTicks now = base::TimeTicks::Now(); | |
36 base::TimeDelta interval = | |
37 last_ticks_.is_null() ? base::TimeDelta() : now - last_ticks_; | |
38 UpdateMetricsInternal(interval); | |
39 last_ticks_ = now; | |
40 } | |
41 | |
42 } // namespace content | |
OLD | NEW |