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/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/threading/worker_pool.h" | 9 #include "base/threading/worker_pool.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "content/child/child_process.h" | 11 #include "content/child/child_process.h" |
12 #include "content/child/thread_safe_sender.h" | 12 #include "content/child/thread_safe_sender.h" |
13 #include "content/common/gpu/gpu_memory_buffer_factory.h" | 13 #include "content/common/gpu/gpu_memory_buffer_factory.h" |
14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
15 #include "content/gpu/gpu_process_control_impl.h" | |
15 #include "content/gpu/gpu_watchdog_thread.h" | 16 #include "content/gpu/gpu_watchdog_thread.h" |
16 #include "content/public/common/content_client.h" | 17 #include "content/public/common/content_client.h" |
17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
18 #include "gpu/config/gpu_info_collector.h" | 19 #include "gpu/config/gpu_info_collector.h" |
19 #include "ipc/ipc_channel_handle.h" | 20 #include "ipc/ipc_channel_handle.h" |
20 #include "ipc/ipc_sync_message_filter.h" | 21 #include "ipc/ipc_sync_message_filter.h" |
21 #include "ui/gl/gl_implementation.h" | 22 #include "ui/gl/gl_implementation.h" |
22 #include "ui/gl/gpu_switching_manager.h" | 23 #include "ui/gl/gpu_switching_manager.h" |
23 | 24 |
24 #if defined(USE_OZONE) | 25 #if defined(USE_OZONE) |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 return supported_types[0]; | 176 return supported_types[0]; |
176 } | 177 } |
177 | 178 |
178 void GpuChildThread::Shutdown() { | 179 void GpuChildThread::Shutdown() { |
179 ChildThreadImpl::Shutdown(); | 180 ChildThreadImpl::Shutdown(); |
180 logging::SetLogMessageHandler(NULL); | 181 logging::SetLogMessageHandler(NULL); |
181 } | 182 } |
182 | 183 |
183 void GpuChildThread::Init(const base::Time& process_start_time) { | 184 void GpuChildThread::Init(const base::Time& process_start_time) { |
184 process_start_time_ = process_start_time; | 185 process_start_time_ = process_start_time; |
186 | |
187 process_control_.reset(new GpuProcessControlImpl()); | |
188 service_registry()->AddService(base::Bind( | |
189 &GpuChildThread::BindProcessControlRequest, base::Unretained(this))); | |
piman
2015/10/06 19:59:36
What makes Unretained safe?
xhwang
2015/10/07 19:07:58
Added comment.
| |
185 } | 190 } |
186 | 191 |
187 bool GpuChildThread::Send(IPC::Message* msg) { | 192 bool GpuChildThread::Send(IPC::Message* msg) { |
188 // The GPU process must never send a synchronous IPC message to the browser | 193 // The GPU process must never send a synchronous IPC message to the browser |
189 // process. This could result in deadlock. | 194 // process. This could result in deadlock. |
190 DCHECK(!msg->is_sync()); | 195 DCHECK(!msg->is_sync()); |
191 | 196 |
192 return ChildThreadImpl::Send(msg); | 197 return ChildThreadImpl::Send(msg); |
193 } | 198 } |
194 | 199 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 watchdog_thread_->Stop(); | 372 watchdog_thread_->Stop(); |
368 } | 373 } |
369 } | 374 } |
370 | 375 |
371 void GpuChildThread::OnGpuSwitched() { | 376 void GpuChildThread::OnGpuSwitched() { |
372 DVLOG(1) << "GPU: GPU has switched"; | 377 DVLOG(1) << "GPU: GPU has switched"; |
373 // Notify observers in the GPU process. | 378 // Notify observers in the GPU process. |
374 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 379 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
375 } | 380 } |
376 | 381 |
382 void GpuChildThread::BindProcessControlRequest( | |
383 mojo::InterfaceRequest<ProcessControl> request) { | |
384 DCHECK(process_control_); | |
385 process_control_bindings_.AddBinding(process_control_.get(), request.Pass()); | |
386 } | |
387 | |
377 } // namespace content | 388 } // namespace content |
OLD | NEW |