Commit 1e9276e8 authored by Sebastien Marchand's avatar Sebastien Marchand Committed by Commit Bot

Make FakeMemoryPressureMonitor work with the multi source monitor

The MultiSourceMemoryPressureMonitor is the new default memory pressure
monitor and this class will eventually be merged with the
MemoryPressureMonitor one, in the meantime this change will allow
downcasting the fake monitor into a multi source monitor.

Change-Id: I6ccd1f196a6e50f1fa7f2a7a547fc326732f97aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1835161Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Sébastien Marchand <sebmarchand@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703538}
parent 977e7324
......@@ -27,8 +27,6 @@ static_library("test_config") {
static_library("test_support") {
testonly = true
sources = [
"../memory/fake_memory_pressure_monitor.cc",
"../memory/fake_memory_pressure_monitor.h",
"../task/sequence_manager/test/fake_task.cc",
"../task/sequence_manager/test/fake_task.h",
"../task/sequence_manager/test/mock_time_domain.cc",
......
......@@ -41,3 +41,16 @@ source_set("unittests") {
"//testing/gtest",
]
}
static_library("test_support") {
testonly = true
sources = [
"fake_memory_pressure_monitor.cc",
"fake_memory_pressure_monitor.h",
]
public_deps = [
":memory_pressure",
"//base",
]
}
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/fake_memory_pressure_monitor.h"
#include "base/util/memory_pressure/fake_memory_pressure_monitor.h"
namespace base {
namespace util {
namespace test {
FakeMemoryPressureMonitor::FakeMemoryPressureMonitor()
: MemoryPressureMonitor(),
: MultiSourceMemoryPressureMonitor(),
memory_pressure_level_(MemoryPressureLevel::MEMORY_PRESSURE_LEVEL_NONE) {}
FakeMemoryPressureMonitor::~FakeMemoryPressureMonitor() {}
......@@ -30,4 +30,4 @@ void FakeMemoryPressureMonitor::SetDispatchCallback(
}
} // namespace test
} // namespace base
} // namespace util
......@@ -2,17 +2,23 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_MEMORY_FAKE_MEMORY_PRESSURE_MONITOR_H_
#define BASE_MEMORY_FAKE_MEMORY_PRESSURE_MONITOR_H_
#ifndef BASE_UTIL_MEMORY_PRESSURE_FAKE_MEMORY_PRESSURE_MONITOR_H_
#define BASE_UTIL_MEMORY_PRESSURE_FAKE_MEMORY_PRESSURE_MONITOR_H_
#include "base/macros.h"
#include "base/memory/memory_pressure_monitor.h"
#include "base/util/memory_pressure/multi_source_memory_pressure_monitor.h"
namespace base {
namespace util {
namespace test {
class FakeMemoryPressureMonitor : public base::MemoryPressureMonitor {
class FakeMemoryPressureMonitor
: public ::util::MultiSourceMemoryPressureMonitor {
public:
using MemoryPressureLevel =
::util::MultiSourceMemoryPressureMonitor::MemoryPressureLevel;
using DispatchCallback =
::util::MultiSourceMemoryPressureMonitor::DispatchCallback;
FakeMemoryPressureMonitor();
~FakeMemoryPressureMonitor() override;
......@@ -29,6 +35,6 @@ class FakeMemoryPressureMonitor : public base::MemoryPressureMonitor {
};
} // namespace test
} // namespace base
} // namespace util
#endif // BASE_MEMORY_FAKE_MEMORY_PRESSURE_MONITOR_H_
#endif // BASE_UTIL_MEMORY_PRESSURE_FAKE_MEMORY_PRESSURE_MONITOR_H_
......@@ -10,12 +10,12 @@
#include <string>
#include <vector>
#include "base/memory/fake_memory_pressure_monitor.h"
#include "base/run_loop.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/system/sys_info.h"
#include "base/timer/mock_timer.h"
#include "base/util/memory_pressure/fake_memory_pressure_monitor.h"
#include "chrome/browser/chromeos/resource_reporter/resource_reporter.h"
#include "chrome/browser/task_manager/test_task_manager.h"
#include "content/public/test/browser_task_environment.h"
......@@ -140,12 +140,12 @@ class ResourceReporterTest : public testing::Test {
return ResourceReporter::GetInstance();
}
base::test::FakeMemoryPressureMonitor* monitor() { return &monitor_; }
util::test::FakeMemoryPressureMonitor* monitor() { return &monitor_; }
private:
content::BrowserTaskEnvironment task_environment_;
base::test::FakeMemoryPressureMonitor monitor_;
util::test::FakeMemoryPressureMonitor monitor_;
DummyTaskManager task_manager_;
......
......@@ -6,12 +6,12 @@
#include "base/bind.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/memory/fake_memory_pressure_monitor.h"
#include "base/memory/memory_pressure_listener.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/util/memory_pressure/fake_memory_pressure_monitor.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window_testing.h"
......@@ -315,7 +315,7 @@ class TabManagerTest : public InProcessBrowserTest {
GetWebContentsAt(index));
}
base::test::FakeMemoryPressureMonitor fake_memory_pressure_monitor_;
util::test::FakeMemoryPressureMonitor fake_memory_pressure_monitor_;
base::SimpleTestTickClock test_clock_;
ScopedSetTickClockForTesting scoped_set_tick_clock_for_testing_;
base::test::ScopedFeatureList scoped_feature_list_;
......
......@@ -13,13 +13,13 @@
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/macros.h"
#include "base/memory/fake_memory_pressure_monitor.h"
#include "base/process/launch.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind_test_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "base/util/memory_pressure/fake_memory_pressure_monitor.h"
#include "build/build_config.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/first_run/first_run.h"
......@@ -234,7 +234,7 @@ class SessionRestoreTest : public InProcessBrowserTest {
const BrowserList* active_browser_list_ = nullptr;
private:
base::test::FakeMemoryPressureMonitor fake_memory_pressure_monitor_;
util::test::FakeMemoryPressureMonitor fake_memory_pressure_monitor_;
};
// Activates the smart restore behaviour and tracks the loading of tabs.
......
......@@ -653,6 +653,7 @@ if (!is_android) {
"//base",
"//base:i18n",
"//base/test:test_support",
"//base/util/memory_pressure:test_support",
"//build:branding_buildflags",
"//chrome:browser_tests_pak",
"//chrome:packed_resources",
......@@ -3444,6 +3445,7 @@ test("unit_tests") {
":test_support_unit",
"//base:base_stack_sampling_profiler_test_util",
"//base/test:test_support",
"//base/util/memory_pressure:test_support",
"//chrome:browser_dependencies",
"//chrome:child_dependencies",
"//chrome:resources",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment