OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/threading/sequenced_worker_pool.h" | |
12 | |
13 namespace arc { | |
14 | |
15 // Trace lowmemorykiller events and report to UMA. | |
16 // | |
17 // If kernel lowmemorykiller is enabled, it would kill processes automatically | |
18 // on memory pressure. ArcLowMemoryKillerMonitor listens on lowmemorykiller log | |
19 // from kernel space and reports to UMA. | |
20 // | |
21 // Note: There should be only one ArcLowMemoryKillerMonitor instance during the | |
22 // power cycle of a Chrome OS device, otherwise an lowmemorykiller event would | |
23 // be reported twice since it reads in the entire kernel log from head. | |
24 // On Chrome OS, it should live within a main browser thread. | |
25 class ArcLowMemoryKillerMonitor { | |
26 public: | |
27 ArcLowMemoryKillerMonitor(); | |
28 ~ArcLowMemoryKillerMonitor(); | |
29 | |
30 void Start(); | |
31 void Stop(); | |
32 | |
33 private: | |
34 // Keep a reference to worker_pool_ in case |this| is deleted in | |
35 // shutdown process while this thread returns from a blocking read. | |
36 void Run(scoped_refptr<base::SequencedWorkerPool> worker_pool); | |
Yusuke Sato
2016/03/15 16:59:45
Can this function be static now? If so, I think yo
cylee1
2016/03/15 18:26:57
True. Thanks !
| |
37 | |
38 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | |
39 | |
40 // Always keep this the last member of this class to make sure it's the | |
41 // first thing to be destructed. | |
42 base::WeakPtrFactory<ArcLowMemoryKillerMonitor> weak_ptr_factory_; | |
43 | |
44 DISALLOW_COPY_AND_ASSIGN(ArcLowMemoryKillerMonitor); | |
45 }; | |
46 | |
47 } // namespace arc | |
48 | |
49 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_" | |
OLD | NEW |