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

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

Issue 2515613006: [DevTools] Move Memory, SystemInfo and Tethering domains to new generator. (Closed)
Patch Set: Created 4 years, 1 month 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" 9 #include "content/browser/memory/memory_pressure_controller_impl.h"
10 #include "content/public/common/content_features.h" 10 #include "content/public/common/content_features.h"
11 11
12 namespace content { 12 namespace content {
13 namespace devtools { 13 namespace protocol {
14 namespace memory {
15 14
16 MemoryHandler::MemoryHandler() {} 15 MemoryHandler::MemoryHandler() {}
17 16
18 MemoryHandler::~MemoryHandler() {} 17 MemoryHandler::~MemoryHandler() {}
19 18
20 MemoryHandler::Response MemoryHandler::SetPressureNotificationsSuppressed( 19 void MemoryHandler::Wire(UberDispatcher* dispatcher) {
20 frontend_.reset(new Memory::Frontend(dispatcher->channel()));
21 Memory::Dispatcher::wire(dispatcher, this);
22 }
23
24 Response MemoryHandler::Disable() {
25 return Response::OK();
26 }
27
28 Response MemoryHandler::SetPressureNotificationsSuppressed(
21 bool suppressed) { 29 bool suppressed) {
22 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) { 30 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
23 return Response::InvalidParams( 31 return Response::Error(
24 "Cannot enable/disable notifications when memory coordinator is " 32 "Cannot enable/disable notifications when memory coordinator is "
25 "enabled"); 33 "enabled");
26 } 34 }
27 content::MemoryPressureControllerImpl::GetInstance() 35 content::MemoryPressureControllerImpl::GetInstance()
28 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed); 36 ->SetPressureNotificationsSuppressedInAllProcesses(suppressed);
29 return Response::OK(); 37 return Response::OK();
30 } 38 }
31 39
32 MemoryHandler::Response MemoryHandler::SimulatePressureNotification( 40 Response MemoryHandler::SimulatePressureNotification(
33 const std::string& level) { 41 const std::string& level) {
34 base::MemoryPressureListener::MemoryPressureLevel parsed_level; 42 base::MemoryPressureListener::MemoryPressureLevel parsed_level;
35 if (level == kPressureLevelModerate) { 43 if (level == protocol::Memory::PressureLevelEnum::Moderate) {
36 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE; 44 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_MODERATE;
37 } else if (level == kPressureLevelCritical) { 45 } else if (level == protocol::Memory::PressureLevelEnum::Critical) {
38 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL; 46 parsed_level = base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL;
39 } else { 47 } else {
40 return Response::InternalError(base::StringPrintf( 48 return Response::InvalidParams(base::StringPrintf(
41 "Invalid memory pressure level '%s'", level.c_str())); 49 "Invalid memory pressure level '%s'", level.c_str()));
42 } 50 }
43 51
44 MemoryPressureControllerImpl::GetInstance() 52 MemoryPressureControllerImpl::GetInstance()
45 ->SimulatePressureNotificationInAllProcesses(parsed_level); 53 ->SimulatePressureNotificationInAllProcesses(parsed_level);
46 return Response::OK(); 54 return Response::OK();
47 } 55 }
48 56
49 MemoryHandler::Response MemoryHandler::GetDOMCounters( 57 } // namespace protocol
50 int* documents,
51 int* nodes,
52 int* event_listeners) {
53 return Response::FallThrough();
54 }
55
56 } // namespace memory
57 } // namespace devtools
58 } // namespace content 58 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698