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 28 matching lines...) Expand all Loading... |
39 #include "build/build_config.h" | 39 #include "build/build_config.h" |
40 #include "cc/base/histograms.h" | 40 #include "cc/base/histograms.h" |
41 #include "cc/base/switches.h" | 41 #include "cc/base/switches.h" |
42 #include "cc/blink/web_external_bitmap_impl.h" | 42 #include "cc/blink/web_external_bitmap_impl.h" |
43 #include "cc/blink/web_layer_impl.h" | 43 #include "cc/blink/web_layer_impl.h" |
44 #include "cc/output/output_surface.h" | 44 #include "cc/output/output_surface.h" |
45 #include "cc/output/vulkan_in_process_context_provider.h" | 45 #include "cc/output/vulkan_in_process_context_provider.h" |
46 #include "cc/raster/task_graph_runner.h" | 46 #include "cc/raster/task_graph_runner.h" |
47 #include "cc/trees/layer_tree_host_common.h" | 47 #include "cc/trees/layer_tree_host_common.h" |
48 #include "cc/trees/layer_tree_settings.h" | 48 #include "cc/trees/layer_tree_settings.h" |
| 49 #include "components/mus/common/gpu_service.h" |
49 #include "components/scheduler/child/compositor_worker_scheduler.h" | 50 #include "components/scheduler/child/compositor_worker_scheduler.h" |
50 #include "components/scheduler/child/webthread_base.h" | 51 #include "components/scheduler/child/webthread_base.h" |
51 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" | 52 #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
52 #include "components/scheduler/renderer/renderer_scheduler.h" | 53 #include "components/scheduler/renderer/renderer_scheduler.h" |
53 #include "content/child/appcache/appcache_dispatcher.h" | 54 #include "content/child/appcache/appcache_dispatcher.h" |
54 #include "content/child/appcache/appcache_frontend_impl.h" | 55 #include "content/child/appcache/appcache_frontend_impl.h" |
55 #include "content/child/blob_storage/blob_message_filter.h" | 56 #include "content/child/blob_storage/blob_message_filter.h" |
56 #include "content/child/child_discardable_shared_memory_manager.h" | 57 #include "content/child/child_discardable_shared_memory_manager.h" |
57 #include "content/child/child_gpu_memory_buffer_manager.h" | 58 #include "content/child/child_gpu_memory_buffer_manager.h" |
58 #include "content/child/child_histogram_message_filter.h" | 59 #include "content/child/child_histogram_message_filter.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 attributes.lose_context_when_out_of_memory = true; | 450 attributes.lose_context_when_out_of_memory = true; |
450 const bool automatic_flushes = false; | 451 const bool automatic_flushes = false; |
451 return make_scoped_refptr(new ContextProviderCommandBuffer( | 452 return make_scoped_refptr(new ContextProviderCommandBuffer( |
452 std::move(gpu_channel_host), stream_id, stream_priority, | 453 std::move(gpu_channel_host), stream_id, stream_priority, |
453 gpu::kNullSurfaceHandle, | 454 gpu::kNullSurfaceHandle, |
454 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), | 455 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), |
455 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, | 456 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, |
456 attributes, nullptr, type)); | 457 attributes, nullptr, type)); |
457 } | 458 } |
458 | 459 |
| 460 bool IsRunningInMash() { |
| 461 const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 462 return cmdline->HasSwitch(switches::kIsRunningInMash); |
| 463 } |
| 464 |
459 } // namespace | 465 } // namespace |
460 | 466 |
461 // For measuring memory usage after each task. Behind a command line flag. | 467 // For measuring memory usage after each task. Behind a command line flag. |
462 class MemoryObserver : public base::MessageLoop::TaskObserver { | 468 class MemoryObserver : public base::MessageLoop::TaskObserver { |
463 public: | 469 public: |
464 MemoryObserver() {} | 470 MemoryObserver() {} |
465 ~MemoryObserver() override {} | 471 ~MemoryObserver() override {} |
466 | 472 |
467 void WillProcessTask(const base::PendingTask& pending_task) override {} | 473 void WillProcessTask(const base::PendingTask& pending_task) override {} |
468 | 474 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 #if defined(USE_EXTERNAL_POPUP_MENU) | 642 #if defined(USE_EXTERNAL_POPUP_MENU) |
637 // On Mac and Android Java UI, the select popups are rendered by the browser. | 643 // On Mac and Android Java UI, the select popups are rendered by the browser. |
638 blink::WebView::setUseExternalPopupMenus(true); | 644 blink::WebView::setUseExternalPopupMenus(true); |
639 #endif | 645 #endif |
640 | 646 |
641 lazy_tls.Pointer()->Set(this); | 647 lazy_tls.Pointer()->Set(this); |
642 | 648 |
643 // Register this object as the main thread. | 649 // Register this object as the main thread. |
644 ChildProcess::current()->set_main_thread(this); | 650 ChildProcess::current()->set_main_thread(this); |
645 | 651 |
| 652 #if defined(MOJO_SHELL_CLIENT) |
| 653 if (IsRunningInMash()) { |
| 654 auto* shell_connection = ChildThread::Get()->GetMojoShellConnection(); |
| 655 mus::GpuService::Initialize(shell_connection->GetConnector()); |
| 656 } |
| 657 #endif |
| 658 |
646 InitializeWebKit(resource_task_queue); | 659 InitializeWebKit(resource_task_queue); |
647 | 660 |
648 // In single process the single process is all there is. | 661 // In single process the single process is all there is. |
649 webkit_shared_timer_suspended_ = false; | 662 webkit_shared_timer_suspended_ = false; |
650 widget_count_ = 0; | 663 widget_count_ = 0; |
651 hidden_widget_count_ = 0; | 664 hidden_widget_count_ = 0; |
652 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; | 665 idle_notification_delay_in_ms_ = kInitialIdleHandlerDelayMs; |
653 idle_notifications_to_skip_ = 0; | 666 idle_notifications_to_skip_ = 0; |
654 | 667 |
655 appcache_dispatcher_.reset( | 668 appcache_dispatcher_.reset( |
656 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); | 669 new AppCacheDispatcher(Get(), new AppCacheFrontendImpl())); |
657 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); | 670 dom_storage_dispatcher_.reset(new DomStorageDispatcher()); |
658 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher( | 671 main_thread_indexed_db_dispatcher_.reset(new IndexedDBDispatcher( |
659 thread_safe_sender())); | 672 thread_safe_sender())); |
660 main_thread_cache_storage_dispatcher_.reset( | 673 main_thread_cache_storage_dispatcher_.reset( |
661 new CacheStorageDispatcher(thread_safe_sender())); | 674 new CacheStorageDispatcher(thread_safe_sender())); |
662 embedded_worker_dispatcher_.reset(new EmbeddedWorkerDispatcher()); | 675 embedded_worker_dispatcher_.reset(new EmbeddedWorkerDispatcher()); |
663 | 676 |
664 // Note: This may reorder messages from the ResourceDispatcher with respect to | 677 // Note: This may reorder messages from the ResourceDispatcher with respect to |
665 // other subsystems. | 678 // other subsystems. |
666 resource_dispatch_throttler_.reset(new ResourceDispatchThrottler( | 679 resource_dispatch_throttler_.reset(new ResourceDispatchThrottler( |
667 static_cast<RenderThread*>(this), renderer_scheduler_.get(), | 680 static_cast<RenderThread*>(this), renderer_scheduler_.get(), |
668 base::TimeDelta::FromSecondsD(kThrottledResourceRequestFlushPeriodS), | 681 base::TimeDelta::FromSecondsD(kThrottledResourceRequestFlushPeriodS), |
669 kMaxResourceRequestsPerFlushWhenThrottled)); | 682 kMaxResourceRequestsPerFlushWhenThrottled)); |
670 resource_dispatcher()->set_message_sender(resource_dispatch_throttler_.get()); | 683 resource_dispatcher()->set_message_sender(resource_dispatch_throttler_.get()); |
671 | 684 |
672 media_stream_center_ = NULL; | 685 media_stream_center_ = nullptr; |
673 | 686 |
674 blob_message_filter_ = new BlobMessageFilter(GetFileThreadMessageLoopProxy()); | 687 blob_message_filter_ = new BlobMessageFilter(GetFileThreadMessageLoopProxy()); |
675 AddFilter(blob_message_filter_.get()); | 688 AddFilter(blob_message_filter_.get()); |
676 db_message_filter_ = new DBMessageFilter(); | 689 db_message_filter_ = new DBMessageFilter(); |
677 AddFilter(db_message_filter_.get()); | 690 AddFilter(db_message_filter_.get()); |
678 | 691 |
679 vc_manager_.reset(new VideoCaptureImplManager()); | 692 vc_manager_.reset(new VideoCaptureImplManager()); |
680 AddFilter(vc_manager_->video_capture_message_filter()); | 693 AddFilter(vc_manager_->video_capture_message_filter()); |
681 | 694 |
682 browser_plugin_manager_.reset(new BrowserPluginManager()); | 695 browser_plugin_manager_.reset(new BrowserPluginManager()); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 if (blink_platform_impl_) { | 888 if (blink_platform_impl_) { |
876 // Crash the process if they fail to close after a generous amount of time. | 889 // Crash the process if they fail to close after a generous amount of time. |
877 bool all_closed = blink_platform_impl_->web_database_observer_impl() | 890 bool all_closed = blink_platform_impl_->web_database_observer_impl() |
878 ->WaitForAllDatabasesToClose(base::TimeDelta::FromSeconds(60)); | 891 ->WaitForAllDatabasesToClose(base::TimeDelta::FromSeconds(60)); |
879 CHECK(all_closed); | 892 CHECK(all_closed); |
880 } | 893 } |
881 | 894 |
882 // Shutdown in reverse of the initialization order. | 895 // Shutdown in reverse of the initialization order. |
883 if (devtools_agent_message_filter_.get()) { | 896 if (devtools_agent_message_filter_.get()) { |
884 RemoveFilter(devtools_agent_message_filter_.get()); | 897 RemoveFilter(devtools_agent_message_filter_.get()); |
885 devtools_agent_message_filter_ = NULL; | 898 devtools_agent_message_filter_ = nullptr; |
886 } | 899 } |
887 | 900 |
888 RemoveFilter(audio_input_message_filter_.get()); | 901 RemoveFilter(audio_input_message_filter_.get()); |
889 audio_input_message_filter_ = NULL; | 902 audio_input_message_filter_ = nullptr; |
890 | 903 |
891 #if defined(ENABLE_WEBRTC) | 904 #if defined(ENABLE_WEBRTC) |
892 RTCPeerConnectionHandler::DestructAllHandlers(); | 905 RTCPeerConnectionHandler::DestructAllHandlers(); |
893 // |peer_connection_factory_| cannot be deleted until after the main message | 906 // |peer_connection_factory_| cannot be deleted until after the main message |
894 // loop has been destroyed. This is because there may be pending tasks that | 907 // loop has been destroyed. This is because there may be pending tasks that |
895 // hold on to objects produced by the PC factory that depend on threads owned | 908 // hold on to objects produced by the PC factory that depend on threads owned |
896 // by the PC factory. Once those tasks have been freed, the factory can be | 909 // by the PC factory. Once those tasks have been freed, the factory can be |
897 // deleted. | 910 // deleted. |
898 #endif | 911 #endif |
899 RemoveFilter(vc_manager_->video_capture_message_filter()); | 912 RemoveFilter(vc_manager_->video_capture_message_filter()); |
900 vc_manager_.reset(); | 913 vc_manager_.reset(); |
901 | 914 |
902 RemoveFilter(db_message_filter_.get()); | 915 RemoveFilter(db_message_filter_.get()); |
903 db_message_filter_ = NULL; | 916 db_message_filter_ = nullptr; |
904 | 917 |
905 // Shutdown the file thread if it's running. | 918 // Shutdown the file thread if it's running. |
906 if (file_thread_) | 919 if (file_thread_) |
907 file_thread_->Stop(); | 920 file_thread_->Stop(); |
908 | 921 |
909 if (compositor_message_filter_.get()) { | 922 if (compositor_message_filter_.get()) { |
910 RemoveFilter(compositor_message_filter_.get()); | 923 RemoveFilter(compositor_message_filter_.get()); |
911 compositor_message_filter_ = NULL; | 924 compositor_message_filter_ = nullptr; |
912 } | 925 } |
913 | 926 |
914 #if defined(OS_ANDROID) | 927 #if defined(OS_ANDROID) |
915 if (sync_compositor_message_filter_) { | 928 if (sync_compositor_message_filter_) { |
916 RemoveFilter(sync_compositor_message_filter_.get()); | 929 RemoveFilter(sync_compositor_message_filter_.get()); |
917 sync_compositor_message_filter_ = nullptr; | 930 sync_compositor_message_filter_ = nullptr; |
918 } | 931 } |
919 stream_texture_factory_ = nullptr; | 932 stream_texture_factory_ = nullptr; |
920 #endif | 933 #endif |
921 | 934 |
922 media_thread_.reset(); | 935 media_thread_.reset(); |
923 | 936 |
924 blink_platform_impl_->SetCompositorThread(nullptr); | 937 blink_platform_impl_->SetCompositorThread(nullptr); |
925 | 938 |
926 compositor_thread_.reset(); | 939 compositor_thread_.reset(); |
927 | 940 |
928 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. | 941 // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after. |
929 RemoveFilter(audio_message_filter_.get()); | 942 RemoveFilter(audio_message_filter_.get()); |
930 audio_message_filter_ = NULL; | 943 audio_message_filter_ = nullptr; |
931 | 944 |
932 categorized_worker_pool_->Shutdown(); | 945 categorized_worker_pool_->Shutdown(); |
933 | 946 |
934 main_input_callback_.Cancel(); | 947 main_input_callback_.Cancel(); |
935 input_handler_manager_.reset(); | 948 input_handler_manager_.reset(); |
936 if (input_event_filter_.get()) { | 949 if (input_event_filter_.get()) { |
937 RemoveFilter(input_event_filter_.get()); | 950 RemoveFilter(input_event_filter_.get()); |
938 input_event_filter_ = NULL; | 951 input_event_filter_ = nullptr; |
939 } | 952 } |
940 | 953 |
941 // RemoveEmbeddedWorkerRoute may be called while deleting | 954 // RemoveEmbeddedWorkerRoute may be called while deleting |
942 // EmbeddedWorkerDispatcher. So it must be deleted before deleting | 955 // EmbeddedWorkerDispatcher. So it must be deleted before deleting |
943 // RenderThreadImpl. | 956 // RenderThreadImpl. |
944 embedded_worker_dispatcher_.reset(); | 957 embedded_worker_dispatcher_.reset(); |
945 | 958 |
946 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might | 959 // Ramp down IDB before we ramp down WebKit (and V8), since IDB classes might |
947 // hold pointers to V8 objects (e.g., via pending requests). | 960 // hold pointers to V8 objects (e.g., via pending requests). |
948 main_thread_indexed_db_dispatcher_.reset(); | 961 main_thread_indexed_db_dispatcher_.reset(); |
949 | 962 |
950 main_thread_compositor_task_runner_ = NULL; | 963 main_thread_compositor_task_runner_ = nullptr; |
951 | 964 |
952 gpu_factories_.clear(); | 965 gpu_factories_.clear(); |
953 | 966 |
954 // Context providers must be released prior to destroying the GPU channel. | 967 // Context providers must be released prior to destroying the GPU channel. |
955 shared_worker_context_provider_ = nullptr; | 968 shared_worker_context_provider_ = nullptr; |
956 shared_main_thread_contexts_ = nullptr; | 969 shared_main_thread_contexts_ = nullptr; |
957 | 970 |
958 if (gpu_channel_.get()) | 971 if (gpu_channel_.get()) |
959 gpu_channel_->DestroyChannel(); | 972 gpu_channel_->DestroyChannel(); |
960 | 973 |
(...skipping 18 matching lines...) Expand all Loading... |
979 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown | 992 // Delay shutting down DiscardableSharedMemoryManager until blink::shutdown |
980 // is complete, because blink::shutdown destructs Blink Resources and they | 993 // is complete, because blink::shutdown destructs Blink Resources and they |
981 // may try to unlock their underlying discardable memory. | 994 // may try to unlock their underlying discardable memory. |
982 ChildThreadImpl::ShutdownDiscardableSharedMemoryManager(); | 995 ChildThreadImpl::ShutdownDiscardableSharedMemoryManager(); |
983 | 996 |
984 // The message loop must be cleared after shutting down | 997 // The message loop must be cleared after shutting down |
985 // the DiscardableSharedMemoryManager, which needs to send messages | 998 // the DiscardableSharedMemoryManager, which needs to send messages |
986 // to the browser process. | 999 // to the browser process. |
987 main_message_loop_.reset(); | 1000 main_message_loop_.reset(); |
988 | 1001 |
989 lazy_tls.Pointer()->Set(NULL); | 1002 lazy_tls.Pointer()->Set(nullptr); |
990 } | 1003 } |
991 | 1004 |
992 bool RenderThreadImpl::Send(IPC::Message* msg) { | 1005 bool RenderThreadImpl::Send(IPC::Message* msg) { |
993 // There are cases where we want to pump asynchronous messages while waiting | 1006 // There are cases where we want to pump asynchronous messages while waiting |
994 // synchronously for the replies to the message to be sent here. However, this | 1007 // synchronously for the replies to the message to be sent here. However, this |
995 // may create an opportunity for re-entrancy into WebKit and other subsystems, | 1008 // may create an opportunity for re-entrancy into WebKit and other subsystems, |
996 // so we need to take care to disable callbacks, timers, and pending network | 1009 // so we need to take care to disable callbacks, timers, and pending network |
997 // loads that could trigger such callbacks. | 1010 // loads that could trigger such callbacks. |
998 bool pumping_events = false; | 1011 bool pumping_events = false; |
999 if (msg->is_sync()) { | 1012 if (msg->is_sync()) { |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 #if defined(OS_ANDROID) | 1515 #if defined(OS_ANDROID) |
1503 | 1516 |
1504 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { | 1517 scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() { |
1505 DCHECK(IsMainThread()); | 1518 DCHECK(IsMainThread()); |
1506 if (!stream_texture_factory_.get() || | 1519 if (!stream_texture_factory_.get() || |
1507 stream_texture_factory_->ContextGL()->GetGraphicsResetStatusKHR() != | 1520 stream_texture_factory_->ContextGL()->GetGraphicsResetStatusKHR() != |
1508 GL_NO_ERROR) { | 1521 GL_NO_ERROR) { |
1509 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = | 1522 scoped_refptr<ContextProviderCommandBuffer> shared_context_provider = |
1510 SharedMainThreadContextProvider(); | 1523 SharedMainThreadContextProvider(); |
1511 if (!shared_context_provider) { | 1524 if (!shared_context_provider) { |
1512 stream_texture_factory_ = NULL; | 1525 stream_texture_factory_ = nullptr; |
1513 return NULL; | 1526 return nullptr; |
1514 } | 1527 } |
1515 DCHECK(shared_context_provider->GetCommandBufferProxy()); | 1528 DCHECK(shared_context_provider->GetCommandBufferProxy()); |
1516 DCHECK(shared_context_provider->GetCommandBufferProxy()->channel()); | 1529 DCHECK(shared_context_provider->GetCommandBufferProxy()->channel()); |
1517 stream_texture_factory_ = | 1530 stream_texture_factory_ = |
1518 StreamTextureFactory::Create(std::move(shared_context_provider)); | 1531 StreamTextureFactory::Create(std::move(shared_context_provider)); |
1519 } | 1532 } |
1520 return stream_texture_factory_; | 1533 return stream_texture_factory_; |
1521 } | 1534 } |
1522 | 1535 |
1523 bool RenderThreadImpl::EnableStreamTextureCopy() { | 1536 bool RenderThreadImpl::EnableStreamTextureCopy() { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 // more informative stack, since we will otherwise just crash later when we | 1683 // more informative stack, since we will otherwise just crash later when we |
1671 // try to restart it. | 1684 // try to restart it. |
1672 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1685 CHECK(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
1673 switches::kSingleProcess)); | 1686 switches::kSingleProcess)); |
1674 ChildThreadImpl::OnChannelError(); | 1687 ChildThreadImpl::OnChannelError(); |
1675 } | 1688 } |
1676 | 1689 |
1677 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { | 1690 bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) { |
1678 base::ObserverListBase<RenderThreadObserver>::Iterator it(&observers_); | 1691 base::ObserverListBase<RenderThreadObserver>::Iterator it(&observers_); |
1679 RenderThreadObserver* observer; | 1692 RenderThreadObserver* observer; |
1680 while ((observer = it.GetNext()) != NULL) { | 1693 while ((observer = it.GetNext()) != nullptr) { |
1681 if (observer->OnControlMessageReceived(msg)) | 1694 if (observer->OnControlMessageReceived(msg)) |
1682 return true; | 1695 return true; |
1683 } | 1696 } |
1684 | 1697 |
1685 // Some messages are handled by delegates. | 1698 // Some messages are handled by delegates. |
1686 if (appcache_dispatcher_->OnMessageReceived(msg) || | 1699 if (appcache_dispatcher_->OnMessageReceived(msg) || |
1687 dom_storage_dispatcher_->OnMessageReceived(msg) || | 1700 dom_storage_dispatcher_->OnMessageReceived(msg) || |
1688 embedded_worker_dispatcher_->OnMessageReceived(msg)) { | 1701 embedded_worker_dispatcher_->OnMessageReceived(msg)) { |
1689 return true; | 1702 return true; |
1690 } | 1703 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); | 1789 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); |
1777 | 1790 |
1778 if (gpu_channel_) { | 1791 if (gpu_channel_) { |
1779 // Do nothing if we already have a GPU channel or are already | 1792 // Do nothing if we already have a GPU channel or are already |
1780 // establishing one. | 1793 // establishing one. |
1781 if (!gpu_channel_->IsLost()) | 1794 if (!gpu_channel_->IsLost()) |
1782 return gpu_channel_; | 1795 return gpu_channel_; |
1783 | 1796 |
1784 // Recreate the channel if it has been lost. | 1797 // Recreate the channel if it has been lost. |
1785 gpu_channel_->DestroyChannel(); | 1798 gpu_channel_->DestroyChannel(); |
1786 gpu_channel_ = NULL; | 1799 gpu_channel_ = nullptr; |
1787 } | 1800 } |
1788 | 1801 |
1789 // Ask the browser for the channel name. | 1802 if (!IsRunningInMash()) { |
1790 int client_id = 0; | 1803 int client_id = 0; |
1791 IPC::ChannelHandle channel_handle; | 1804 IPC::ChannelHandle channel_handle; |
1792 gpu::GPUInfo gpu_info; | 1805 gpu::GPUInfo gpu_info; |
1793 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( | 1806 // Ask the browser for the channel name. |
1794 cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || | 1807 if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( |
| 1808 cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || |
1795 #if defined(OS_POSIX) | 1809 #if defined(OS_POSIX) |
1796 channel_handle.socket.fd == -1 || | 1810 channel_handle.socket.fd == -1 || |
1797 #endif | 1811 #endif |
1798 channel_handle.name.empty()) { | 1812 channel_handle.name.empty()) { |
1799 // Otherwise cancel the connection. | 1813 // Otherwise cancel the connection. |
1800 return NULL; | 1814 return nullptr; |
| 1815 } |
| 1816 GetContentClient()->SetGpuInfo(gpu_info); |
| 1817 |
| 1818 // Cache some variables that are needed on the compositor thread for our |
| 1819 // implementation of GpuChannelHostFactory. |
| 1820 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); |
| 1821 |
| 1822 gpu_channel_ = |
| 1823 gpu::GpuChannelHost::Create(this, client_id, gpu_info, channel_handle, |
| 1824 ChildProcess::current()->GetShutDownEvent(), |
| 1825 gpu_memory_buffer_manager()); |
| 1826 } else { |
| 1827 gpu_channel_ = mus::GpuService::GetInstance()->EstablishGpuChannelSync(); |
1801 } | 1828 } |
1802 | |
1803 GetContentClient()->SetGpuInfo(gpu_info); | |
1804 | |
1805 // Cache some variables that are needed on the compositor thread for our | |
1806 // implementation of GpuChannelHostFactory. | |
1807 io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); | |
1808 | |
1809 gpu_channel_ = gpu::GpuChannelHost::Create( | |
1810 this, client_id, gpu_info, channel_handle, | |
1811 ChildProcess::current()->GetShutDownEvent(), gpu_memory_buffer_manager()); | |
1812 return gpu_channel_; | 1829 return gpu_channel_; |
1813 } | 1830 } |
1814 | 1831 |
1815 std::unique_ptr<cc::OutputSurface> | 1832 std::unique_ptr<cc::OutputSurface> |
1816 RenderThreadImpl::CreateCompositorOutputSurface( | 1833 RenderThreadImpl::CreateCompositorOutputSurface( |
1817 bool use_software, | 1834 bool use_software, |
1818 int routing_id, | 1835 int routing_id, |
1819 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, | 1836 scoped_refptr<FrameSwapMessageQueue> frame_swap_message_queue, |
1820 const GURL& url) { | 1837 const GURL& url) { |
1821 const base::CommandLine& command_line = | 1838 const base::CommandLine& command_line = |
1822 *base::CommandLine::ForCurrentProcess(); | 1839 *base::CommandLine::ForCurrentProcess(); |
1823 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) | 1840 if (command_line.HasSwitch(switches::kDisableGpuCompositing)) |
1824 use_software = true; | 1841 use_software = true; |
1825 | 1842 |
1826 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) | 1843 #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA) |
1827 auto shell_connection = MojoShellConnection::GetForProcess(); | 1844 auto* shell_connection = MojoShellConnection::GetForProcess(); |
1828 if (shell_connection && !use_software && | 1845 if (shell_connection && !use_software && |
1829 command_line.HasSwitch(switches::kUseMusInRenderer)) { | 1846 command_line.HasSwitch(switches::kUseMusInRenderer)) { |
1830 mus::GpuService::Initialize(shell_connection->GetConnector()); | |
1831 RenderWidgetMusConnection* connection = | 1847 RenderWidgetMusConnection* connection = |
1832 RenderWidgetMusConnection::GetOrCreate(routing_id); | 1848 RenderWidgetMusConnection::GetOrCreate(routing_id); |
1833 return connection->CreateOutputSurface(); | 1849 return connection->CreateOutputSurface(); |
1834 } | 1850 } |
1835 #endif | 1851 #endif |
1836 | 1852 |
1837 uint32_t output_surface_id = g_next_output_surface_id++; | 1853 uint32_t output_surface_id = g_next_output_surface_id++; |
1838 | 1854 |
1839 if (command_line.HasSwitch(switches::kEnableVulkan)) { | 1855 if (command_line.HasSwitch(switches::kEnableVulkan)) { |
1840 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = | 1856 scoped_refptr<cc::VulkanContextProvider> vulkan_context_provider = |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2244 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
2229 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2245 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
2230 | 2246 |
2231 blink::mainThreadIsolate()->MemoryPressureNotification( | 2247 blink::mainThreadIsolate()->MemoryPressureNotification( |
2232 v8_memory_pressure_level); | 2248 v8_memory_pressure_level); |
2233 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2249 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
2234 v8_memory_pressure_level); | 2250 v8_memory_pressure_level); |
2235 } | 2251 } |
2236 | 2252 |
2237 } // namespace content | 2253 } // namespace content |
OLD | NEW |