blob: 2ecdcd819d1f4f7a0207bf7098e08a4896fc3b94 [file] [log] [blame]
// 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.
#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 {
explicit LowMemoryListener(LowMemoryListenerDelegate* delegate);
void Start();
void Stop();
// 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_;
} // namespace chromeos