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/threading/sequenced_worker_pool.h" | |
11 | |
12 namespace arc { | |
13 | |
14 // Trace lowmemorykiller events and report to UMA. | |
15 // | |
16 // If kernel lowmemorykiller is enabled, it would kill processes automatically | |
17 // on memory pressure. ArcLowMemoryKillerMonitor listens on lowmemorykiller log | |
18 // from kernel space and reports to UMA. | |
19 // | |
20 // Note: There should be only one ArcLowMemoryKillerMonitor instance during the | |
21 // power cycle of a Chrome OS device, otherwise an lowmemorykiller event would | |
22 // be reported twice since it reads in the entire kernel log from head. | |
23 // On Chrome OS, it should live within a main browser thread. | |
24 class ArcLowMemoryKillerMonitor { | |
25 public: | |
26 ArcLowMemoryKillerMonitor(); | |
27 ~ArcLowMemoryKillerMonitor(); | |
28 | |
29 void Start(); | |
30 void Stop(); | |
31 | |
32 private: | |
33 // Keep a reference to worker_pool_ in case |this| is deleted in | |
34 // shutdown process while this thread returns from a blocking read. | |
35 static void Run(scoped_refptr<base::SequencedWorkerPool> worker_pool); | |
36 | |
37 scoped_refptr<base::SequencedWorkerPool> worker_pool_; | |
38 | |
39 DISALLOW_COPY_AND_ASSIGN(ArcLowMemoryKillerMonitor); | |
40 }; | |
41 | |
42 } // namespace arc | |
43 | |
44 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_" | |
OLD | NEW |