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

Side by Side Diff: content/renderer/render_thread_impl.cc

Issue 2731913002: NotForReview: Expose the global memory budget (chromium side)
Patch Set: Add --simulate-memory-pressure Created 3 years, 9 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/common/memory_coordinator.mojom ('k') | gin/public/v8_platform.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 (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/renderer/render_thread_impl.h" 5 #include "content/renderer/render_thread_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 #if defined(USE_EXTERNAL_POPUP_MENU) 617 #if defined(USE_EXTERNAL_POPUP_MENU)
618 // On Mac and Android Java UI, the select popups are rendered by the browser. 618 // On Mac and Android Java UI, the select popups are rendered by the browser.
619 blink::WebView::setUseExternalPopupMenus(true); 619 blink::WebView::setUseExternalPopupMenus(true);
620 #endif 620 #endif
621 621
622 lazy_tls.Pointer()->Set(this); 622 lazy_tls.Pointer()->Set(this);
623 623
624 // Register this object as the main thread. 624 // Register this object as the main thread.
625 ChildProcess::current()->set_main_thread(this); 625 ChildProcess::current()->set_main_thread(this);
626 626
627 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
628 // Disable MemoryPressureListener when memory coordinator is enabled.
629 base::MemoryPressureListener::SetNotificationsSuppressed(true);
630
631 // TODO(bashi): Revisit how to manage the lifetime of
632 // ChildMemoryCoordinatorImpl.
633 // https://codereview.chromium.org/2094583002/#msg52
634 mojom::MemoryCoordinatorHandlePtr parent_coordinator;
635 GetRemoteInterfaces()->GetInterface(mojo::MakeRequest(&parent_coordinator));
636 memory_coordinator_ =
637 CreateChildMemoryCoordinator(std::move(parent_coordinator), this);
638 }
639
627 if (IsRunningInMash()) { 640 if (IsRunningInMash()) {
628 gpu_ = ui::Gpu::Create(GetServiceManagerConnection()->GetConnector(), 641 gpu_ = ui::Gpu::Create(GetServiceManagerConnection()->GetConnector(),
629 GetIOTaskRunner()); 642 GetIOTaskRunner());
630 } else { 643 } else {
631 gpu_ = ui::Gpu::Create(GetRemoteInterfaces(), GetIOTaskRunner()); 644 gpu_ = ui::Gpu::Create(GetRemoteInterfaces(), GetIOTaskRunner());
632 } 645 }
633 646
634 channel()->GetThreadSafeRemoteAssociatedInterface( 647 channel()->GetThreadSafeRemoteAssociatedInterface(
635 &thread_safe_render_message_filter_); 648 &thread_safe_render_message_filter_);
636 shared_bitmap_manager_.reset( 649 shared_bitmap_manager_.reset(
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 base::CommandLine::ForCurrentProcess()->HasSwitch( 832 base::CommandLine::ForCurrentProcess()->HasSwitch(
820 switches::kEnableNewVp9CodecString)) { 833 switches::kEnableNewVp9CodecString)) {
821 media::EnableNewVp9CodecStringSupport(); 834 media::EnableNewVp9CodecStringSupport();
822 } 835 }
823 836
824 memory_pressure_listener_.reset(new base::MemoryPressureListener( 837 memory_pressure_listener_.reset(new base::MemoryPressureListener(
825 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), 838 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)),
826 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, 839 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure,
827 base::Unretained(this)))); 840 base::Unretained(this))));
828 841
829 if (base::FeatureList::IsEnabled(features::kMemoryCoordinator)) {
830 // Disable MemoryPressureListener when memory coordinator is enabled.
831 base::MemoryPressureListener::SetNotificationsSuppressed(true);
832
833 // TODO(bashi): Revisit how to manage the lifetime of
834 // ChildMemoryCoordinatorImpl.
835 // https://codereview.chromium.org/2094583002/#msg52
836 mojom::MemoryCoordinatorHandlePtr parent_coordinator;
837 GetRemoteInterfaces()->GetInterface(mojo::MakeRequest(&parent_coordinator));
838 memory_coordinator_ = CreateChildMemoryCoordinator(
839 std::move(parent_coordinator), this);
840 }
841
842 int num_raster_threads = 0; 842 int num_raster_threads = 0;
843 std::string string_value = 843 std::string string_value =
844 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); 844 command_line.GetSwitchValueASCII(switches::kNumRasterThreads);
845 bool parsed_num_raster_threads = 845 bool parsed_num_raster_threads =
846 base::StringToInt(string_value, &num_raster_threads); 846 base::StringToInt(string_value, &num_raster_threads);
847 DCHECK(parsed_num_raster_threads) << string_value; 847 DCHECK(parsed_num_raster_threads) << string_value;
848 DCHECK_GT(num_raster_threads, 0); 848 DCHECK_GT(num_raster_threads, 0);
849 849
850 // TODO(vmpstr): If the flag sticks, we should clean it up and always have 850 // TODO(vmpstr): If the flag sticks, we should clean it up and always have
851 // image decode tasks. 851 // image decode tasks.
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2396 } 2396 }
2397 } 2397 }
2398 2398
2399 void RenderThreadImpl::OnRendererInterfaceRequest( 2399 void RenderThreadImpl::OnRendererInterfaceRequest(
2400 mojom::RendererAssociatedRequest request) { 2400 mojom::RendererAssociatedRequest request) {
2401 DCHECK(!renderer_binding_.is_bound()); 2401 DCHECK(!renderer_binding_.is_bound());
2402 renderer_binding_.Bind(std::move(request)); 2402 renderer_binding_.Bind(std::move(request));
2403 } 2403 }
2404 2404
2405 } // namespace content 2405 } // namespace content
OLDNEW
« no previous file with comments | « content/common/memory_coordinator.mojom ('k') | gin/public/v8_platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698