Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_low_memory_killer_monitor.h |
| diff --git a/chrome/browser/chromeos/arc/arc_low_memory_killer_monitor.h b/chrome/browser/chromeos/arc/arc_low_memory_killer_monitor.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84432351d339f4436938df032d8975de6d6d0a5e |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/arc_low_memory_killer_monitor.h |
| @@ -0,0 +1,49 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_ |
| + |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/threading/sequenced_worker_pool.h" |
| + |
| +namespace arc { |
| + |
| +// Trace lowmemorykiller events and report to UMA. |
| +// |
| +// If kernel lowmemorykiller is enabled, it would kill processes automatically |
| +// on memory pressure. ArcLowMemoryKillerMonitor listens on lowmemorykiller log |
| +// from kernel space and reports to UMA. |
| +// |
| +// Note: There should be only one ArcLowMemoryKillerMonitor instance during the |
| +// power cycle of a Chrome OS device, otherwise an lowmemorykiller event would |
| +// be reported twice since it reads in the entire kernel log from head. |
| +// On Chrome OS, it should live within a main browser thread. |
| +class ArcLowMemoryKillerMonitor { |
| + public: |
| + ArcLowMemoryKillerMonitor(); |
| + ~ArcLowMemoryKillerMonitor(); |
| + |
| + void Start(); |
| + void Stop(); |
| + |
| + private: |
| + // Keep a reference to worker_pool_ in case |this| is deleted in |
| + // shutdown process while this thread returns from a blocking read. |
| + 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 !
|
| + |
| + scoped_refptr<base::SequencedWorkerPool> worker_pool_; |
| + |
| + // Always keep this the last member of this class to make sure it's the |
| + // first thing to be destructed. |
| + base::WeakPtrFactory<ArcLowMemoryKillerMonitor> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcLowMemoryKillerMonitor); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_LOW_MEMORY_KILLER_MONITOR_H_" |