Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(514)

Unified Diff: content/browser/memory/memory_pressure_controller_impl.cc

Issue 2872743002: Add an experiment to avoid memory pressure broadcasts. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/flag_descriptions.cc ('k') | content/public/common/content_features.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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())
« no previous file with comments | « chrome/browser/flag_descriptions.cc ('k') | content/public/common/content_features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698