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

Side by Side Diff: content/browser/browser_main_loop.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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser_main_loop.h" 5 #include "content/browser/browser_main_loop.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 #include "content/common/content_switches_internal.h" 68 #include "content/common/content_switches_internal.h"
69 #include "content/common/host_discardable_shared_memory_manager.h" 69 #include "content/common/host_discardable_shared_memory_manager.h"
70 #include "content/common/host_shared_bitmap_manager.h" 70 #include "content/common/host_shared_bitmap_manager.h"
71 #include "content/common/service_manager/service_manager_connection_impl.h" 71 #include "content/common/service_manager/service_manager_connection_impl.h"
72 #include "content/public/browser/browser_main_parts.h" 72 #include "content/public/browser/browser_main_parts.h"
73 #include "content/public/browser/content_browser_client.h" 73 #include "content/public/browser/content_browser_client.h"
74 #include "content/public/browser/gpu_data_manager_observer.h" 74 #include "content/public/browser/gpu_data_manager_observer.h"
75 #include "content/public/browser/render_process_host.h" 75 #include "content/public/browser/render_process_host.h"
76 #include "content/public/browser/tracing_controller.h" 76 #include "content/public/browser/tracing_controller.h"
77 #include "content/public/common/content_client.h" 77 #include "content/public/common/content_client.h"
78 #include "content/public/common/content_features.h"
78 #include "content/public/common/content_switches.h" 79 #include "content/public/common/content_switches.h"
79 #include "content/public/common/main_function_params.h" 80 #include "content/public/common/main_function_params.h"
80 #include "content/public/common/result_codes.h" 81 #include "content/public/common/result_codes.h"
81 #include "device/battery/battery_status_service.h" 82 #include "device/battery/battery_status_service.h"
82 #include "device/time_zone_monitor/time_zone_monitor.h" 83 #include "device/time_zone_monitor/time_zone_monitor.h"
83 #include "media/base/media.h" 84 #include "media/base/media.h"
84 #include "media/base/user_input_monitor.h" 85 #include "media/base/user_input_monitor.h"
85 #include "media/midi/midi_manager.h" 86 #include "media/midi/midi_manager.h"
86 #include "mojo/edk/embedder/embedder.h" 87 #include "mojo/edk/embedder/embedder.h"
87 #include "mojo/edk/embedder/scoped_ipc_support.h" 88 #include "mojo/edk/embedder/scoped_ipc_support.h"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 740 }
740 741
741 const base::CommandLine* command_line = 742 const base::CommandLine* command_line =
742 base::CommandLine::ForCurrentProcess(); 743 base::CommandLine::ForCurrentProcess();
743 // Note that we do not initialize a new FeatureList when calling this for 744 // Note that we do not initialize a new FeatureList when calling this for
744 // the second time. 745 // the second time.
745 base::FeatureList::InitializeInstance( 746 base::FeatureList::InitializeInstance(
746 command_line->GetSwitchValueASCII(switches::kEnableFeatures), 747 command_line->GetSwitchValueASCII(switches::kEnableFeatures),
747 command_line->GetSwitchValueASCII(switches::kDisableFeatures)); 748 command_line->GetSwitchValueASCII(switches::kDisableFeatures));
748 749
749 // TODO(chrisha): Abstract away this construction mess to a helper function, 750 InitializeMemoryManagementComponent();
750 // once MemoryPressureMonitor is made a concrete class.
751 #if defined(OS_CHROMEOS)
752 if (chromeos::switches::MemoryPressureHandlingEnabled()) {
753 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor(
754 chromeos::switches::GetMemoryPressureThresholds()));
755 }
756 #elif defined(OS_MACOSX)
757 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor());
758 #elif defined(OS_WIN)
759 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor(
760 parsed_command_line_));
761 #endif
762 751
763 #if defined(ENABLE_PLUGINS) 752 #if defined(ENABLE_PLUGINS)
764 // Prior to any processing happening on the IO thread, we create the 753 // Prior to any processing happening on the IO thread, we create the
765 // plugin service as it is predominantly used from the IO thread, 754 // plugin service as it is predominantly used from the IO thread,
766 // but must be created on the main thread. The service ctor is 755 // but must be created on the main thread. The service ctor is
767 // inexpensive and does not invoke the io_thread() accessor. 756 // inexpensive and does not invoke the io_thread() accessor.
768 { 757 {
769 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService"); 758 TRACE_EVENT0("startup", "BrowserMainLoop::CreateThreads:PluginService");
770 PluginService::GetInstance()->Init(); 759 PluginService::GetInstance()->Init();
771 } 760 }
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 #endif 1378 #endif
1390 1379
1391 return result_code_; 1380 return result_code_;
1392 } 1381 }
1393 1382
1394 bool BrowserMainLoop::UsingInProcessGpu() const { 1383 bool BrowserMainLoop::UsingInProcessGpu() const {
1395 return parsed_command_line_.HasSwitch(switches::kSingleProcess) || 1384 return parsed_command_line_.HasSwitch(switches::kSingleProcess) ||
1396 parsed_command_line_.HasSwitch(switches::kInProcessGPU); 1385 parsed_command_line_.HasSwitch(switches::kInProcessGPU);
1397 } 1386 }
1398 1387
1388 void BrowserMainLoop::InitializeMemoryManagementComponent() {
1389 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
1390 // Disable MemoryPressureListener when memory coordinator is enabled.
1391 base::MemoryPressureListener::SetNotificationsSuppressed(true);
1392 return;
1393 }
1394
1395 // TODO(chrisha): Abstract away this construction mess to a helper function,
1396 // once MemoryPressureMonitor is made a concrete class.
1397 #if defined(OS_CHROMEOS)
1398 if (chromeos::switches::MemoryPressureHandlingEnabled()) {
1399 memory_pressure_monitor_.reset(new base::chromeos::MemoryPressureMonitor(
1400 chromeos::switches::GetMemoryPressureThresholds()));
1401 }
1402 #elif defined(OS_MACOSX)
1403 memory_pressure_monitor_.reset(new base::mac::MemoryPressureMonitor());
1404 #elif defined(OS_WIN)
1405 memory_pressure_monitor_.reset(CreateWinMemoryPressureMonitor(
1406 parsed_command_line_));
1407 #endif
1408 }
1409
1399 bool BrowserMainLoop::InitializeToolkit() { 1410 bool BrowserMainLoop::InitializeToolkit() {
1400 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit"); 1411 TRACE_EVENT0("startup", "BrowserMainLoop::InitializeToolkit");
1401 1412
1402 // TODO(evan): this function is rather subtle, due to the variety 1413 // TODO(evan): this function is rather subtle, due to the variety
1403 // of intersecting ifdefs we have. To keep it easy to follow, there 1414 // of intersecting ifdefs we have. To keep it easy to follow, there
1404 // are no #else branches on any #ifs. 1415 // are no #else branches on any #ifs.
1405 // TODO(stevenjb): Move platform specific code into platform specific Parts 1416 // TODO(stevenjb): Move platform specific code into platform specific Parts
1406 // (Need to add InitializeToolkit stage to BrowserParts). 1417 // (Need to add InitializeToolkit stage to BrowserParts).
1407 // See also GTK setup in EarlyInitialization, above, and associated comments. 1418 // See also GTK setup in EarlyInitialization, above, and associated comments.
1408 1419
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1566 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner = 1577 scoped_refptr<base::SingleThreadTaskRunner> worker_task_runner =
1567 audio_thread_->task_runner(); 1578 audio_thread_->task_runner();
1568 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner), 1579 audio_manager_ = media::AudioManager::Create(std::move(audio_task_runner),
1569 std::move(worker_task_runner), 1580 std::move(worker_task_runner),
1570 MediaInternals::GetInstance()); 1581 MediaInternals::GetInstance());
1571 } 1582 }
1572 CHECK(audio_manager_); 1583 CHECK(audio_manager_);
1573 } 1584 }
1574 1585
1575 } // namespace content 1586 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_main_loop.h ('k') | content/browser/devtools/protocol/memory_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698