| Index: content/renderer/render_thread_impl.cc
|
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
|
| index 1226bb4b64d5e759bbd6b7a79c9962e2c3cc194b..36b8ac10107891f275e4f3caf2b56c47fc73f830 100644
|
| --- a/content/renderer/render_thread_impl.cc
|
| +++ b/content/renderer/render_thread_impl.cc
|
| @@ -46,6 +46,7 @@
|
| #include "cc/raster/task_graph_runner.h"
|
| #include "cc/trees/layer_tree_host_common.h"
|
| #include "cc/trees/layer_tree_settings.h"
|
| +#include "components/mus/common/gpu_service.h"
|
| #include "components/scheduler/child/compositor_worker_scheduler.h"
|
| #include "components/scheduler/child/webthread_base.h"
|
| #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h"
|
| @@ -456,6 +457,11 @@ scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext(
|
| attributes, nullptr, type));
|
| }
|
|
|
| +bool IsRunningInMash() {
|
| + const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess();
|
| + return cmdline->HasSwitch(switches::kIsRunningInMash);
|
| +}
|
| +
|
| } // namespace
|
|
|
| // For measuring memory usage after each task. Behind a command line flag.
|
| @@ -643,6 +649,13 @@ void RenderThreadImpl::Init(
|
| // Register this object as the main thread.
|
| ChildProcess::current()->set_main_thread(this);
|
|
|
| +#if defined(MOJO_SHELL_CLIENT)
|
| + if (IsRunningInMash()) {
|
| + auto* shell_connection = ChildThread::Get()->GetMojoShellConnection();
|
| + mus::GpuService::Initialize(shell_connection->GetConnector());
|
| + }
|
| +#endif
|
| +
|
| InitializeWebKit(resource_task_queue);
|
|
|
| // In single process the single process is all there is.
|
| @@ -669,7 +682,7 @@ void RenderThreadImpl::Init(
|
| kMaxResourceRequestsPerFlushWhenThrottled));
|
| resource_dispatcher()->set_message_sender(resource_dispatch_throttler_.get());
|
|
|
| - media_stream_center_ = NULL;
|
| + media_stream_center_ = nullptr;
|
|
|
| blob_message_filter_ = new BlobMessageFilter(GetFileThreadMessageLoopProxy());
|
| AddFilter(blob_message_filter_.get());
|
| @@ -882,11 +895,11 @@ void RenderThreadImpl::Shutdown() {
|
| // Shutdown in reverse of the initialization order.
|
| if (devtools_agent_message_filter_.get()) {
|
| RemoveFilter(devtools_agent_message_filter_.get());
|
| - devtools_agent_message_filter_ = NULL;
|
| + devtools_agent_message_filter_ = nullptr;
|
| }
|
|
|
| RemoveFilter(audio_input_message_filter_.get());
|
| - audio_input_message_filter_ = NULL;
|
| + audio_input_message_filter_ = nullptr;
|
|
|
| #if defined(ENABLE_WEBRTC)
|
| RTCPeerConnectionHandler::DestructAllHandlers();
|
| @@ -900,7 +913,7 @@ void RenderThreadImpl::Shutdown() {
|
| vc_manager_.reset();
|
|
|
| RemoveFilter(db_message_filter_.get());
|
| - db_message_filter_ = NULL;
|
| + db_message_filter_ = nullptr;
|
|
|
| // Shutdown the file thread if it's running.
|
| if (file_thread_)
|
| @@ -908,7 +921,7 @@ void RenderThreadImpl::Shutdown() {
|
|
|
| if (compositor_message_filter_.get()) {
|
| RemoveFilter(compositor_message_filter_.get());
|
| - compositor_message_filter_ = NULL;
|
| + compositor_message_filter_ = nullptr;
|
| }
|
|
|
| #if defined(OS_ANDROID)
|
| @@ -927,7 +940,7 @@ void RenderThreadImpl::Shutdown() {
|
|
|
| // AudioMessageFilter may be accessed on |media_thread_|, so shutdown after.
|
| RemoveFilter(audio_message_filter_.get());
|
| - audio_message_filter_ = NULL;
|
| + audio_message_filter_ = nullptr;
|
|
|
| categorized_worker_pool_->Shutdown();
|
|
|
| @@ -935,7 +948,7 @@ void RenderThreadImpl::Shutdown() {
|
| input_handler_manager_.reset();
|
| if (input_event_filter_.get()) {
|
| RemoveFilter(input_event_filter_.get());
|
| - input_event_filter_ = NULL;
|
| + input_event_filter_ = nullptr;
|
| }
|
|
|
| // RemoveEmbeddedWorkerRoute may be called while deleting
|
| @@ -947,7 +960,7 @@ void RenderThreadImpl::Shutdown() {
|
| // hold pointers to V8 objects (e.g., via pending requests).
|
| main_thread_indexed_db_dispatcher_.reset();
|
|
|
| - main_thread_compositor_task_runner_ = NULL;
|
| + main_thread_compositor_task_runner_ = nullptr;
|
|
|
| gpu_factories_.clear();
|
|
|
| @@ -986,7 +999,7 @@ void RenderThreadImpl::Shutdown() {
|
| // to the browser process.
|
| main_message_loop_.reset();
|
|
|
| - lazy_tls.Pointer()->Set(NULL);
|
| + lazy_tls.Pointer()->Set(nullptr);
|
| }
|
|
|
| bool RenderThreadImpl::Send(IPC::Message* msg) {
|
| @@ -1509,8 +1522,8 @@ scoped_refptr<StreamTextureFactory> RenderThreadImpl::GetStreamTexureFactory() {
|
| scoped_refptr<ContextProviderCommandBuffer> shared_context_provider =
|
| SharedMainThreadContextProvider();
|
| if (!shared_context_provider) {
|
| - stream_texture_factory_ = NULL;
|
| - return NULL;
|
| + stream_texture_factory_ = nullptr;
|
| + return nullptr;
|
| }
|
| DCHECK(shared_context_provider->GetCommandBufferProxy());
|
| DCHECK(shared_context_provider->GetCommandBufferProxy()->channel());
|
| @@ -1677,7 +1690,7 @@ void RenderThreadImpl::OnChannelError() {
|
| bool RenderThreadImpl::OnControlMessageReceived(const IPC::Message& msg) {
|
| base::ObserverListBase<RenderThreadObserver>::Iterator it(&observers_);
|
| RenderThreadObserver* observer;
|
| - while ((observer = it.GetNext()) != NULL) {
|
| + while ((observer = it.GetNext()) != nullptr) {
|
| if (observer->OnControlMessageReceived(msg))
|
| return true;
|
| }
|
| @@ -1783,32 +1796,36 @@ scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync(
|
|
|
| // Recreate the channel if it has been lost.
|
| gpu_channel_->DestroyChannel();
|
| - gpu_channel_ = NULL;
|
| + gpu_channel_ = nullptr;
|
| }
|
|
|
| - // Ask the browser for the channel name.
|
| - int client_id = 0;
|
| - IPC::ChannelHandle channel_handle;
|
| - gpu::GPUInfo gpu_info;
|
| - if (!Send(new ChildProcessHostMsg_EstablishGpuChannel(
|
| - cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) ||
|
| + if (!IsRunningInMash()) {
|
| + int client_id = 0;
|
| + IPC::ChannelHandle channel_handle;
|
| + gpu::GPUInfo gpu_info;
|
| + // Ask the browser for the channel name.
|
| + if (!Send(new ChildProcessHostMsg_EstablishGpuChannel(
|
| + cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) ||
|
| #if defined(OS_POSIX)
|
| - channel_handle.socket.fd == -1 ||
|
| + channel_handle.socket.fd == -1 ||
|
| #endif
|
| - channel_handle.name.empty()) {
|
| - // Otherwise cancel the connection.
|
| - return NULL;
|
| - }
|
| -
|
| - GetContentClient()->SetGpuInfo(gpu_info);
|
| + channel_handle.name.empty()) {
|
| + // Otherwise cancel the connection.
|
| + return nullptr;
|
| + }
|
| + GetContentClient()->SetGpuInfo(gpu_info);
|
|
|
| - // Cache some variables that are needed on the compositor thread for our
|
| - // implementation of GpuChannelHostFactory.
|
| - io_thread_task_runner_ = ChildProcess::current()->io_task_runner();
|
| + // Cache some variables that are needed on the compositor thread for our
|
| + // implementation of GpuChannelHostFactory.
|
| + io_thread_task_runner_ = ChildProcess::current()->io_task_runner();
|
|
|
| - gpu_channel_ = gpu::GpuChannelHost::Create(
|
| - this, client_id, gpu_info, channel_handle,
|
| - ChildProcess::current()->GetShutDownEvent(), gpu_memory_buffer_manager());
|
| + gpu_channel_ =
|
| + gpu::GpuChannelHost::Create(this, client_id, gpu_info, channel_handle,
|
| + ChildProcess::current()->GetShutDownEvent(),
|
| + gpu_memory_buffer_manager());
|
| + } else {
|
| + gpu_channel_ = mus::GpuService::GetInstance()->EstablishGpuChannelSync();
|
| + }
|
| return gpu_channel_;
|
| }
|
|
|
| @@ -1824,10 +1841,9 @@ RenderThreadImpl::CreateCompositorOutputSurface(
|
| use_software = true;
|
|
|
| #if defined(MOJO_SHELL_CLIENT) && defined(USE_AURA)
|
| - auto shell_connection = MojoShellConnection::GetForProcess();
|
| + auto* shell_connection = MojoShellConnection::GetForProcess();
|
| if (shell_connection && !use_software &&
|
| command_line.HasSwitch(switches::kUseMusInRenderer)) {
|
| - mus::GpuService::Initialize(shell_connection->GetConnector());
|
| RenderWidgetMusConnection* connection =
|
| RenderWidgetMusConnection::GetOrCreate(routing_id);
|
| return connection->CreateOutputSurface();
|
|
|