Index: content/browser/memory/memory_pressure_controller_impl.cc |
diff --git a/content/browser/memory/memory_pressure_controller_impl.cc b/content/browser/memory/memory_pressure_controller_impl.cc |
index 13d5cfd2d372ff0d86aa68c340ba368db5f0218b..e26e502d22fe302502c47da5003cb264a964369e 100644 |
--- a/content/browser/memory/memory_pressure_controller_impl.cc |
+++ b/content/browser/memory/memory_pressure_controller_impl.cc |
@@ -5,8 +5,20 @@ |
#include "content/browser/memory/memory_pressure_controller_impl.h" |
#include "base/bind.h" |
+#include "base/feature_list.h" |
#include "content/browser/memory/memory_message_filter.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/common/content_features.h" |
+ |
+namespace features { |
+ |
+// This experiment controls whether memory pressure notifications to |
+// renderers are broadcast. |
+const base::Feature kEnableBroadcastMemoryPressure = { |
+ "EnableBroadcastMemoryPressure", base::FEATURE_ENABLED_BY_DEFAULT, |
+}; |
+ |
+} // namespace features |
namespace content { |
@@ -21,8 +33,8 @@ void MemoryPressureControllerImpl::OnMemoryMessageFilterAdded( |
// Add the message filter to the set of all memory message filters and check |
// that it wasn't there beforehand. |
const bool success = |
- memory_message_filters_.insert( |
- std::make_pair(filter->process_host(), filter)) |
+ memory_message_filters_ |
+ .insert(std::make_pair(filter->process_host(), filter)) |
.second; |
DCHECK(success); |
@@ -127,6 +139,13 @@ void MemoryPressureControllerImpl::SendPressureNotificationImpl( |
if (base::MemoryPressureListener::AreNotificationsSuppressed()) |
return; |
+// This desktop-only experiment can disable the memory pressure broadcasts. |
+#if defined(OS_MACOSX) || (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || \ |
+ defined(OS_WIN) |
+ if (!base::FeatureList::IsEnabled(features::kEnableBroadcastMemoryPressure)) |
+ return; |
+#endif |
+ |
// Find the appropriate message filter and dispatch the message. |
auto it = memory_message_filters_.find(child_process_host); |
if (it != memory_message_filters_.end()) |