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