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

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

Issue 2882513004: Remove renderer notifications of memory pressure. (Closed)
Patch Set: Merge 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 unified diff | Download patch
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"
10 #include "content/public/common/content_features.h" 9 #include "content/public/common/content_features.h"
11 10
12 namespace content { 11 namespace content {
13 namespace protocol { 12 namespace protocol {
14 13
15 MemoryHandler::MemoryHandler() 14 MemoryHandler::MemoryHandler()
16 : DevToolsDomainHandler(Memory::Metainfo::domainName) { 15 : DevToolsDomainHandler(Memory::Metainfo::domainName) {
17 } 16 }
18 17
19 MemoryHandler::~MemoryHandler() {} 18 MemoryHandler::~MemoryHandler() {}
20 19
21 void MemoryHandler::Wire(UberDispatcher* dispatcher) { 20 void MemoryHandler::Wire(UberDispatcher* dispatcher) {
22 Memory::Dispatcher::wire(dispatcher, this); 21 Memory::Dispatcher::wire(dispatcher, this);
23 } 22 }
24 23
25 Response MemoryHandler::SetPressureNotificationsSuppressed( 24 Response MemoryHandler::SetPressureNotificationsSuppressed(
26 bool suppressed) { 25 bool suppressed) {
27 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { 26 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
28 return Response::Error( 27 return Response::Error(
29 "Cannot enable/disable notifications when memory coordinator is " 28 "Cannot enable/disable notifications when memory coordinator is "
30 "enabled"); 29 "enabled");
31 } 30 }
32 content::MemoryPressureControllerImpl::GetInstance() 31
33 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed); 32 base::MemoryPressureListener::SetNotificationsSuppressed(suppressed);
34 return Response::OK(); 33 return Response::OK();
35 } 34 }
36 35
37 Response MemoryHandler::SimulatePressureNotification( 36 Response MemoryHandler::SimulatePressureNotification(
38 const std::string& level) { 37 const std::string& level) {
39 base::MemoryPressureListener::MemoryPressureLevel parsed_level; 38 base::MemoryPressureListener::MemoryPressureLevel parsed_level;
40 if (level == protocol::Memory::PressureLevelEnum::Moderate) { 39 if (level == protocol::Memory::PressureLevelEnum::Moderate) {
41 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE; 40 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE;
42 } else if (level == protocol::Memory::PressureLevelEnum::Critical) { 41 } else if (level == protocol::Memory::PressureLevelEnum::Critical) {
43 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL; 42 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL;
44 } else { 43 } else {
45 return Response::InvalidParams(base::StringPrintf( 44 return Response::InvalidParams(base::StringPrintf(
46 "Invalid memory pressure level '%s'", level.c_str())); 45 "Invalid memory pressure level '%s'", level.c_str()));
47 } 46 }
48 47
49 MemoryPressureControllerImpl::GetInstance() 48 // Simulate memory pressure notification in the browser process.
50 ->SimulatePressureNotificationInAllProcesses(parsed_level); 49 base::MemoryPressureListener::SimulatePressureNotification(parsed_level);
51 return Response::OK(); 50 return Response::OK();
52 } 51 }
53 52
54 } // namespace protocol 53 } // namespace protocol
55 } // namespace content 54 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_child_process_host_impl.cc ('k') | content/browser/memory/memory_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698