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

Unified Diff: chromeos/memory/low_memory_listener.h

Issue 14727005: Moves LowMemoryObserver into chromeos and renames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review feedback again Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/memory/chromeos_memory_export.h ('k') | chromeos/memory/low_memory_listener.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/memory/low_memory_listener.h
diff --git a/chromeos/memory/low_memory_listener.h b/chromeos/memory/low_memory_listener.h
new file mode 100644
index 0000000000000000000000000000000000000000..2ecdcd819d1f4f7a0207bf7098e08a4896fc3b94
--- /dev/null
+++ b/chromeos/memory/low_memory_listener.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2013 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 CHROMEOS_MEMORY_LOW_MEMORY_LISTENER_H_
+#define CHROMEOS_MEMORY_LOW_MEMORY_LISTENER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "chromeos/memory/chromeos_memory_export.h"
+
+namespace chromeos {
+
+class LowMemoryListenerDelegate;
+class LowMemoryListenerImpl;
+
+////////////////////////////////////////////////////////////////////////////////
+// LowMemoryListener
+//
+// Class to handle observation of low memory device for changes so that we
+// can get a signal from the kernel about low memory conditions and notify
+// our delegate, who can take actions such as discarding tabs.
+//
+// This object is intended to be created and used on the UI thread. All
+// notifications are dispatched on the UI thread.
+class CHROMEOS_MEMORY_EXPORT LowMemoryListener {
+ public:
+ explicit LowMemoryListener(LowMemoryListenerDelegate* delegate);
+ ~LowMemoryListener();
+
+ void Start();
+ void Stop();
+
+ private:
+ // Callback from LowMemoryListenerImpl when memory is low. Called on the UI
+ // thread.
+ void OnMemoryLow();
+
+ scoped_refptr<LowMemoryListenerImpl> observer_;
+ LowMemoryListenerDelegate* delegate_;
+ base::WeakPtrFactory<LowMemoryListener> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(LowMemoryListener);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_MEMORY_LOW_MEMORY_LISTENER_H_
« no previous file with comments | « chromeos/memory/chromeos_memory_export.h ('k') | chromeos/memory/low_memory_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698