fake_memory_pressure_monitor.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright 2018 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. #ifndef COMPONENTS_MEMORY_PRESSURE_FAKE_MEMORY_PRESSURE_MONITOR_H_
  5. #define COMPONENTS_MEMORY_PRESSURE_FAKE_MEMORY_PRESSURE_MONITOR_H_
  6. #include "components/memory_pressure/multi_source_memory_pressure_monitor.h"
  7. namespace memory_pressure {
  8. namespace test {
  9. class FakeMemoryPressureMonitor
  10. : public ::memory_pressure::MultiSourceMemoryPressureMonitor {
  11. public:
  12. using MemoryPressureLevel =
  13. ::memory_pressure::MultiSourceMemoryPressureMonitor::MemoryPressureLevel;
  14. using DispatchCallback =
  15. ::memory_pressure::MultiSourceMemoryPressureMonitor::DispatchCallback;
  16. FakeMemoryPressureMonitor();
  17. ~FakeMemoryPressureMonitor() override;
  18. FakeMemoryPressureMonitor(const FakeMemoryPressureMonitor&) = delete;
  19. FakeMemoryPressureMonitor& operator=(const FakeMemoryPressureMonitor&) =
  20. delete;
  21. void SetAndNotifyMemoryPressure(MemoryPressureLevel level);
  22. // base::MemoryPressureMonitor overrides:
  23. MemoryPressureLevel GetCurrentPressureLevel() const override;
  24. void SetDispatchCallback(const DispatchCallback& callback) override;
  25. private:
  26. MemoryPressureLevel memory_pressure_level_{
  27. MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_NONE};
  28. };
  29. } // namespace test
  30. } // namespace memory_pressure
  31. #endif // COMPONENTS_MEMORY_PRESSURE_FAKE_MEMORY_PRESSURE_MONITOR_H_