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

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

Issue 1641813002: Provide renderers with memory pressure signals. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@contentapi
Patch Set: Addressed creis' comments. Created 4 years, 10 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 | « chrome/browser/memory/tab_stats.cc ('k') | content/browser/memory/memory_message_filter.h » ('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.h" 9 #include "content/browser/memory/memory_pressure_controller_impl.h"
10 10
11 namespace content { 11 namespace content {
12 namespace devtools { 12 namespace devtools {
13 namespace memory { 13 namespace memory {
14 14
15 MemoryHandler::MemoryHandler() {} 15 MemoryHandler::MemoryHandler() {}
16 16
17 MemoryHandler::~MemoryHandler() {} 17 MemoryHandler::~MemoryHandler() {}
18 18
19 MemoryHandler::Response MemoryHandler::SetPressureNotificationsSuppressed( 19 MemoryHandler::Response MemoryHandler::SetPressureNotificationsSuppressed(
20 bool suppressed) { 20 bool suppressed) {
21 content::MemoryPressureController::GetInstance() 21 content::MemoryPressureControllerImpl::GetInstance()
22 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed); 22 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed);
23 return Response::OK(); 23 return Response::OK();
24 } 24 }
25 25
26 MemoryHandler::Response MemoryHandler::SimulatePressureNotification( 26 MemoryHandler::Response MemoryHandler::SimulatePressureNotification(
27 const std::string& level) { 27 const std::string& level) {
28 base::MemoryPressureListener::MemoryPressureLevel parsed_level; 28 base::MemoryPressureListener::MemoryPressureLevel parsed_level;
29 if (level == kPressureLevelModerate) { 29 if (level == kPressureLevelModerate) {
30 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE; 30 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE;
31 } else if (level == kPressureLevelCritical) { 31 } else if (level == kPressureLevelCritical) {
32 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL; 32 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL;
33 } else { 33 } else {
34 return Response::InternalError(base::StringPrintf( 34 return Response::InternalError(base::StringPrintf(
35 "Invalid memory pressure level '%s'", level.c_str())); 35 "Invalid memory pressure level '%s'", level.c_str()));
36 } 36 }
37 37
38 MemoryPressureController::GetInstance() 38 MemoryPressureControllerImpl::GetInstance()
39 ->SimulatePressureNotificationInAllProcesses(parsed_level); 39 ->SimulatePressureNotificationInAllProcesses(parsed_level);
40 return Response::OK(); 40 return Response::OK();
41 } 41 }
42 42
43 } // namespace memory 43 } // namespace memory
44 } // namespace devtools 44 } // namespace devtools
45 } // namespace content 45 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/memory/tab_stats.cc ('k') | content/browser/memory/memory_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698