| Index: chromeos/memory/low_memory_listener.h
|
| diff --git a/chrome/browser/chromeos/memory/low_memory_observer.h b/chromeos/memory/low_memory_listener.h
|
| similarity index 36%
|
| rename from chrome/browser/chromeos/memory/low_memory_observer.h
|
| rename to chromeos/memory/low_memory_listener.h
|
| index 65f0235ff36198fd2ae9731afaee3e29d016904d..9d1fe4c5b40f898a4229fa9da318d4839b5feb17 100644
|
| --- a/chrome/browser/chromeos/memory/low_memory_observer.h
|
| +++ b/chromeos/memory/low_memory_listener.h
|
| @@ -2,44 +2,47 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_CHROMEOS_MEMORY_LOW_MEMORY_OBSERVER_H_
|
| -#define CHROME_BROWSER_CHROMEOS_MEMORY_LOW_MEMORY_OBSERVER_H_
|
| +#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 LowMemoryObserverImpl;
|
| +class LowMemoryListenerDelegate;
|
| +class LowMemoryListenerImpl;
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// LowMemoryObserver
|
| +// 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 discard tabs
|
| -// when that happens, instead of waiting for the OOM killer to kill renderers
|
| -// (which is more drastic, but still necessary and possible).
|
| +// 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 starts and stops the observation, and can be created or deleted
|
| -// from any thread, but the observation occurs on the FILE thread, and tabs are
|
| -// discarded on the UI thread.
|
| -class LowMemoryObserver {
|
| +// 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:
|
| - LowMemoryObserver();
|
| - ~LowMemoryObserver();
|
| + explicit LowMemoryListener(LowMemoryListenerDelegate* delegate);
|
| + ~LowMemoryListener();
|
|
|
| void Start();
|
| void Stop();
|
|
|
| - // Sets the threshold level of the low memory notifier in megabytes. Setting
|
| - // to -1 will turn off the low memory notifier.
|
| - static void SetLowMemoryMargin(int64 margin_mb);
|
| -
|
| private:
|
| - scoped_refptr<LowMemoryObserverImpl> observer_;
|
| + // 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(LowMemoryObserver);
|
| + DISALLOW_COPY_AND_ASSIGN(LowMemoryListener);
|
| };
|
|
|
| } // namespace chromeos
|
|
|
| -#endif // CHROME_BROWSER_CHROMEOS_MEMORY_LOW_MEMORY_OBSERVER_H_
|
| +#endif // CHROMEOS_MEMORY_LOW_MEMORY_LISTENER_H_
|
|
|