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

Side by Side Diff: content/browser/devtools/protocol/memory_handler.cc

Issue 2411423004: Disable MemoryPressureListener when memory coordinator is enabled (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/devtools/protocol/memory_handler.h" 5 #include "content/browser/devtools/protocol/memory_handler.h"
6 6
7 #include "base/memory/memory_pressure_listener.h" 7 #include "base/memory/memory_pressure_listener.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "content/browser/memory/memory_pressure_controller_impl.h" 9 #include "content/browser/memory/memory_pressure_controller_impl.h"
10 #include "content/public/common/content_features.h"
10 11
11 namespace content { 12 namespace content {
12 namespace devtools { 13 namespace devtools {
13 namespace memory { 14 namespace memory {
14 15
15 MemoryHandler::MemoryHandler() {} 16 MemoryHandler::MemoryHandler() {}
16 17
17 MemoryHandler::~MemoryHandler() {} 18 MemoryHandler::~MemoryHandler() {}
18 19
19 MemoryHandler::Response MemoryHandler::SetPressureNotificationsSuppressed( 20 MemoryHandler::Response MemoryHandler::SetPressureNotificationsSuppressed(
20 bool suppressed) { 21 bool suppressed) {
22 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
23 return Response::InvalidParams(
24 "Cannot enable/disable notifications when memory coordinator is "
25 "enabled");
26 }
21 content::MemoryPressureControllerImpl::GetInstance() 27 content::MemoryPressureControllerImpl::GetInstance()
22 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed); 28 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed);
23 return Response::OK(); 29 return Response::OK();
24 } 30 }
25 31
26 MemoryHandler::Response MemoryHandler::SimulatePressureNotification( 32 MemoryHandler::Response MemoryHandler::SimulatePressureNotification(
27 const std::string& level) { 33 const std::string& level) {
28 base::MemoryPressureListener::MemoryPressureLevel parsed_level; 34 base::MemoryPressureListener::MemoryPressureLevel parsed_level;
29 if (level == kPressureLevelModerate) { 35 if (level == kPressureLevelModerate) {
30 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE; 36 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE;
31 } else if (level == kPressureLevelCritical) { 37 } else if (level == kPressureLevelCritical) {
32 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL; 38 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL;
33 } else { 39 } else {
34 return Response::InternalError(base::StringPrintf( 40 return Response::InternalError(base::StringPrintf(
35 "Invalid memory pressure level '%s'", level.c_str())); 41 "Invalid memory pressure level '%s'", level.c_str()));
36 } 42 }
37 43
38 MemoryPressureControllerImpl::GetInstance() 44 MemoryPressureControllerImpl::GetInstance()
39 ->SimulatePressureNotificationInAllProcesses(parsed_level); 45 ->SimulatePressureNotificationInAllProcesses(parsed_level);
40 return Response::OK(); 46 return Response::OK();
41 } 47 }
42 48
43 } // namespace memory 49 } // namespace memory
44 } // namespace devtools 50 } // namespace devtools
45 } // namespace content 51 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.cc ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698