OLD | NEW |
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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // MemoryCoordinator at the same time. | 853 // MemoryCoordinator at the same time. |
854 DCHECK(!base::FeatureList::IsEnabled(features::kPurgeAndSuspend)); | 854 DCHECK(!base::FeatureList::IsEnabled(features::kPurgeAndSuspend)); |
855 | 855 |
856 // Disable MemoryPressureListener when memory coordinator is enabled. | 856 // Disable MemoryPressureListener when memory coordinator is enabled. |
857 base::MemoryPressureListener::SetNotificationsSuppressed(true); | 857 base::MemoryPressureListener::SetNotificationsSuppressed(true); |
858 | 858 |
859 // TODO(bashi): Revisit how to manage the lifetime of | 859 // TODO(bashi): Revisit how to manage the lifetime of |
860 // ChildMemoryCoordinatorImpl. | 860 // ChildMemoryCoordinatorImpl. |
861 // https://codereview.chromium.org/2094583002/#msg52 | 861 // https://codereview.chromium.org/2094583002/#msg52 |
862 mojom::MemoryCoordinatorHandlePtr parent_coordinator; | 862 mojom::MemoryCoordinatorHandlePtr parent_coordinator; |
863 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&parent_coordinator)); | 863 GetRemoteInterfaces()->GetInterface(mojo::MakeRequest(&parent_coordinator)); |
864 memory_coordinator_ = CreateChildMemoryCoordinator( | 864 memory_coordinator_ = CreateChildMemoryCoordinator( |
865 std::move(parent_coordinator), this); | 865 std::move(parent_coordinator), this); |
866 } | 866 } |
867 | 867 |
868 int num_raster_threads = 0; | 868 int num_raster_threads = 0; |
869 std::string string_value = | 869 std::string string_value = |
870 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 870 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
871 bool parsed_num_raster_threads = | 871 bool parsed_num_raster_threads = |
872 base::StringToInt(string_value, &num_raster_threads); | 872 base::StringToInt(string_value, &num_raster_threads); |
873 DCHECK(parsed_num_raster_threads) << string_value; | 873 DCHECK(parsed_num_raster_threads) << string_value; |
874 DCHECK_GT(num_raster_threads, 0); | 874 DCHECK_GT(num_raster_threads, 0); |
875 | 875 |
876 // TODO(vmpstr): If the flag sticks, we should clean it up and always have | 876 // TODO(vmpstr): If the flag sticks, we should clean it up and always have |
877 // image decode tasks. | 877 // image decode tasks. |
878 are_image_decode_tasks_enabled_ = true; | 878 are_image_decode_tasks_enabled_ = true; |
879 | 879 |
880 categorized_worker_pool_->Start(num_raster_threads); | 880 categorized_worker_pool_->Start(num_raster_threads); |
881 | 881 |
882 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; | 882 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; |
883 if (IsRunningInMash()) { | 883 if (IsRunningInMash()) { |
884 #if defined(USE_AURA) | 884 #if defined(USE_AURA) |
885 GetServiceManagerConnection()->GetConnector()->ConnectToInterface( | 885 GetServiceManagerConnection()->GetConnector()->ConnectToInterface( |
886 ui::mojom::kServiceName, &manager_ptr); | 886 ui::mojom::kServiceName, &manager_ptr); |
887 #else | 887 #else |
888 NOTREACHED(); | 888 NOTREACHED(); |
889 #endif | 889 #endif |
890 } else { | 890 } else { |
891 ChildThread::Get()->GetRemoteInterfaces()->GetInterface( | 891 ChildThread::Get()->GetRemoteInterfaces()->GetInterface( |
892 mojo::GetProxy(&manager_ptr)); | 892 mojo::MakeRequest(&manager_ptr)); |
893 } | 893 } |
894 | 894 |
895 discardable_shared_memory_manager_ = base::MakeUnique< | 895 discardable_shared_memory_manager_ = base::MakeUnique< |
896 discardable_memory::ClientDiscardableSharedMemoryManager>( | 896 discardable_memory::ClientDiscardableSharedMemoryManager>( |
897 std::move(manager_ptr), GetIOTaskRunner()); | 897 std::move(manager_ptr), GetIOTaskRunner()); |
898 | 898 |
899 // TODO(boliu): In single process, browser main loop should set up the | 899 // TODO(boliu): In single process, browser main loop should set up the |
900 // discardable memory manager, and should skip this if kSingleProcess. | 900 // discardable memory manager, and should skip this if kSingleProcess. |
901 // See crbug.com/503724. | 901 // See crbug.com/503724. |
902 base::DiscardableMemoryAllocator::SetInstance( | 902 base::DiscardableMemoryAllocator::SetInstance( |
903 discardable_shared_memory_manager_.get()); | 903 discardable_shared_memory_manager_.get()); |
904 | 904 |
905 GetContentClient()->renderer()->ExposeInterfacesToBrowser( | 905 GetContentClient()->renderer()->ExposeInterfacesToBrowser( |
906 GetInterfaceRegistry()); | 906 GetInterfaceRegistry()); |
907 | 907 |
908 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); | 908 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateFrameFactory)); |
909 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); | 909 GetInterfaceRegistry()->AddInterface(base::Bind(&CreateEmbeddedWorkerSetup)); |
910 GetInterfaceRegistry()->AddInterface( | 910 GetInterfaceRegistry()->AddInterface( |
911 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, | 911 base::Bind(&EmbeddedWorkerInstanceClientImpl::Create, |
912 base::Unretained(embedded_worker_dispatcher_.get()))); | 912 base::Unretained(embedded_worker_dispatcher_.get()))); |
913 | 913 |
914 GetRemoteInterfaces()->GetInterface( | 914 GetRemoteInterfaces()->GetInterface( |
915 mojo::GetProxy(&storage_partition_service_)); | 915 mojo::MakeRequest(&storage_partition_service_)); |
916 | 916 |
917 #if defined(OS_LINUX) | 917 #if defined(OS_LINUX) |
918 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); | 918 ChildProcess::current()->SetIOThreadPriority(base::ThreadPriority::DISPLAY); |
919 ChildThreadImpl::current()->SetThreadPriority( | 919 ChildThreadImpl::current()->SetThreadPriority( |
920 categorized_worker_pool_->background_worker_thread_id(), | 920 categorized_worker_pool_->background_worker_thread_id(), |
921 base::ThreadPriority::BACKGROUND); | 921 base::ThreadPriority::BACKGROUND); |
922 #endif | 922 #endif |
923 | 923 |
924 record_purge_suspend_metric_closure_.Reset(base::Bind( | 924 record_purge_suspend_metric_closure_.Reset(base::Bind( |
925 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); | 925 &RenderThreadImpl::RecordPurgeAndSuspendMetrics, base::Unretained(this))); |
(...skipping 1561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2487 } | 2487 } |
2488 } | 2488 } |
2489 | 2489 |
2490 void RenderThreadImpl::OnRendererInterfaceRequest( | 2490 void RenderThreadImpl::OnRendererInterfaceRequest( |
2491 mojom::RendererAssociatedRequest request) { | 2491 mojom::RendererAssociatedRequest request) { |
2492 DCHECK(!renderer_binding_.is_bound()); | 2492 DCHECK(!renderer_binding_.is_bound()); |
2493 renderer_binding_.Bind(std::move(request)); | 2493 renderer_binding_.Bind(std::move(request)); |
2494 } | 2494 } |
2495 | 2495 |
2496 } // namespace content | 2496 } // namespace content |
OLD | NEW |