Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: content/gpu/gpu_child_thread.cc

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/public/browser/render_process_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback_helpers.h" 11 #include "base/callback_helpers.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/threading/thread_local.h" 14 #include "base/threading/thread_local.h"
15 #include "base/threading/worker_pool.h" 15 #include "base/threading/worker_pool.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "content/child/child_process.h" 17 #include "content/child/child_process.h"
18 #include "content/child/thread_safe_sender.h" 18 #include "content/child/thread_safe_sender.h"
19 #include "content/common/establish_channel_params.h" 19 #include "content/common/establish_channel_params.h"
20 #include "content/common/gpu_host_messages.h" 20 #include "content/common/gpu_host_messages.h"
21 #include "content/gpu/gpu_process_control_impl.h" 21 #include "content/gpu/gpu_process_control_impl.h"
22 #include "content/gpu/gpu_watchdog_thread.h" 22 #include "content/gpu/gpu_watchdog_thread.h"
23 #include "content/public/common/content_client.h" 23 #include "content/public/common/content_client.h"
24 #include "content/public/common/content_switches.h" 24 #include "content/public/common/content_switches.h"
25 #include "content/public/common/mojo_shell_connection.h"
25 #include "content/public/gpu/content_gpu_client.h" 26 #include "content/public/gpu/content_gpu_client.h"
26 #include "gpu/command_buffer/service/gpu_switches.h" 27 #include "gpu/command_buffer/service/gpu_switches.h"
27 #include "gpu/command_buffer/service/sync_point_manager.h" 28 #include "gpu/command_buffer/service/sync_point_manager.h"
28 #include "gpu/config/gpu_info_collector.h" 29 #include "gpu/config/gpu_info_collector.h"
29 #include "gpu/config/gpu_switches.h" 30 #include "gpu/config/gpu_switches.h"
30 #include "gpu/config/gpu_util.h" 31 #include "gpu/config/gpu_util.h"
31 #include "gpu/ipc/common/memory_stats.h" 32 #include "gpu/ipc/common/memory_stats.h"
32 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 33 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
33 #include "ipc/ipc_channel_handle.h" 34 #include "ipc/ipc_channel_handle.h"
34 #include "ipc/ipc_sync_message_filter.h" 35 #include "ipc/ipc_sync_message_filter.h"
35 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h" 36 #include "media/gpu/ipc/service/gpu_jpeg_decode_accelerator.h"
36 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h" 37 #include "media/gpu/ipc/service/gpu_video_decode_accelerator.h"
37 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h" 38 #include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
38 #include "media/gpu/ipc/service/media_service.h" 39 #include "media/gpu/ipc/service/media_service.h"
40 #include "services/shell/public/cpp/interface_registry.h"
39 #include "ui/gl/gl_implementation.h" 41 #include "ui/gl/gl_implementation.h"
40 #include "ui/gl/gl_switches.h" 42 #include "ui/gl/gl_switches.h"
41 #include "ui/gl/gpu_switching_manager.h" 43 #include "ui/gl/gpu_switching_manager.h"
42 #include "ui/gl/init/gl_factory.h" 44 #include "ui/gl/init/gl_factory.h"
43 #include "url/gurl.h" 45 #include "url/gurl.h"
44 46
45 #if defined(USE_OZONE) 47 #if defined(USE_OZONE)
46 #include "ui/ozone/public/gpu_platform_support.h" 48 #include "ui/ozone/public/gpu_platform_support.h"
47 #include "ui/ozone/public/ozone_platform.h" 49 #include "ui/ozone/public/ozone_platform.h"
48 #endif 50 #endif
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 #if defined(OS_ANDROID) 217 #if defined(OS_ANDROID)
216 // When running in in-process mode, this has been set in the browser at 218 // When running in in-process mode, this has been set in the browser at
217 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun(). 219 // ChromeBrowserMainPartsAndroid::PreMainMessageLoopRun().
218 if (!in_browser_process_) 220 if (!in_browser_process_)
219 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid()); 221 media::SetMediaClientAndroid(GetContentClient()->GetMediaClientAndroid());
220 #endif 222 #endif
221 223
222 // Only set once per process instance. 224 // Only set once per process instance.
223 process_control_.reset(new GpuProcessControlImpl()); 225 process_control_.reset(new GpuProcessControlImpl());
224 226
227 GetInterfaceRegistry()->AddInterface(base::Bind(
228 &GpuChildThread::BindProcessControlRequest, base::Unretained(this)));
229
230 if (GetContentClient()->gpu()) { // NULL in tests.
231 GetContentClient()->gpu()->ExposeInterfacesToBrowser(
232 GetInterfaceRegistry());
233 }
234
235 // We don't want to process any incoming interface requests until
236 // OnInitialize() is invoked.
237 GetInterfaceRegistry()->PauseBinding();
238
225 if (GetContentClient()->gpu()) // NULL in tests. 239 if (GetContentClient()->gpu()) // NULL in tests.
226 GetContentClient()->gpu()->Initialize(this); 240 GetContentClient()->gpu()->Initialize(this);
227 } 241 }
228 242
229 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name, 243 void GpuChildThread::OnFieldTrialGroupFinalized(const std::string& trial_name,
230 const std::string& group_name) { 244 const std::string& group_name) {
231 Send(new GpuHostMsg_FieldTrialActivated(trial_name)); 245 Send(new GpuHostMsg_FieldTrialActivated(trial_name));
232 } 246 }
233 247
234 bool GpuChildThread::Send(IPC::Message* msg) { 248 bool GpuChildThread::Send(IPC::Message* msg) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 OnDestroyingVideoSurface); 298 OnDestroyingVideoSurface);
285 #endif 299 #endif
286 IPC_MESSAGE_UNHANDLED(handled = false) 300 IPC_MESSAGE_UNHANDLED(handled = false)
287 IPC_END_MESSAGE_MAP() 301 IPC_END_MESSAGE_MAP()
288 if (handled) 302 if (handled)
289 return true; 303 return true;
290 304
291 return false; 305 return false;
292 } 306 }
293 307
294 bool GpuChildThread::OnConnect(shell::Connection* connection) {
295 // Use of base::Unretained(this) is safe here because |service_registry()|
296 // will be destroyed before GpuChildThread is destructed.
297 connection->GetInterfaceRegistry()->AddInterface(base::Bind(
298 &GpuChildThread::BindProcessControlRequest, base::Unretained(this)));
299
300 if (GetContentClient()->gpu()) { // NULL in tests.
301 GetContentClient()->gpu()->ExposeInterfacesToBrowser(
302 connection->GetInterfaceRegistry());
303 }
304
305 // We don't want to process any incoming interface requests until
306 // OnInitialize().
307 if (!gpu_channel_manager_) {
308 connection->GetInterfaceRegistry()->PauseBinding();
309 resume_interface_bindings_callback_ = base::Bind(
310 &shell::InterfaceRegistry::ResumeBinding,
311 connection->GetInterfaceRegistry()->GetWeakPtr());
312 }
313
314 return true;
315 }
316
317 shell::InterfaceRegistry* GpuChildThread::GetInterfaceRegistryForConnection() {
318 return nullptr;
319 }
320
321 shell::InterfaceProvider* GpuChildThread::GetInterfaceProviderForConnection() {
322 return nullptr;
323 }
324
325 void GpuChildThread::SetActiveURL(const GURL& url) { 308 void GpuChildThread::SetActiveURL(const GURL& url) {
326 GetContentClient()->SetActiveURL(url); 309 GetContentClient()->SetActiveURL(url);
327 } 310 }
328 311
329 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { 312 void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
330 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); 313 Send(new GpuHostMsg_DidCreateOffscreenContext(active_url));
331 } 314 }
332 315
333 void GpuChildThread::DidDestroyChannel(int client_id) { 316 void GpuChildThread::DidDestroyChannel(int client_id) {
334 media_service_->RemoveChannel(client_id); 317 media_service_->RemoveChannel(client_id);
(...skipping 23 matching lines...) Expand all
358 } 341 }
359 #endif 342 #endif
360 343
361 void GpuChildThread::StoreShaderToDisk(int32_t client_id, 344 void GpuChildThread::StoreShaderToDisk(int32_t client_id,
362 const std::string& key, 345 const std::string& key,
363 const std::string& shader) { 346 const std::string& shader) {
364 Send(new GpuHostMsg_CacheShader(client_id, key, shader)); 347 Send(new GpuHostMsg_CacheShader(client_id, key, shader));
365 } 348 }
366 349
367 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) { 350 void GpuChildThread::OnInitialize(const gpu::GpuPreferences& gpu_preferences) {
368 if (!resume_interface_bindings_callback_.is_null()) 351 GetInterfaceRegistry()->ResumeBinding();
369 base::ResetAndReturn(&resume_interface_bindings_callback_).Run();
370 352
371 gpu_preferences_ = gpu_preferences; 353 gpu_preferences_ = gpu_preferences;
372 354
373 gpu_info_.video_decode_accelerator_capabilities = 355 gpu_info_.video_decode_accelerator_capabilities =
374 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_); 356 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences_);
375 gpu_info_.video_encode_accelerator_supported_profiles = 357 gpu_info_.video_encode_accelerator_supported_profiles =
376 media::GpuVideoEncodeAccelerator::GetSupportedProfiles( 358 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(
377 gpu_preferences_); 359 gpu_preferences_);
378 gpu_info_.jpeg_decode_accelerator_supported = 360 gpu_info_.jpeg_decode_accelerator_supported =
379 media::GpuJpegDecodeAccelerator::IsSupported(); 361 media::GpuJpegDecodeAccelerator::IsSupported();
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 #endif 560 #endif
579 561
580 void GpuChildThread::OnLoseAllContexts() { 562 void GpuChildThread::OnLoseAllContexts() {
581 if (gpu_channel_manager_) { 563 if (gpu_channel_manager_) {
582 gpu_channel_manager_->DestroyAllChannels(); 564 gpu_channel_manager_->DestroyAllChannels();
583 media_service_->DestroyAllChannels(); 565 media_service_->DestroyAllChannels();
584 } 566 }
585 } 567 }
586 568
587 void GpuChildThread::BindProcessControlRequest( 569 void GpuChildThread::BindProcessControlRequest(
588 mojo::InterfaceRequest<mojom::ProcessControl> request) { 570 mojom::ProcessControlRequest request) {
589 DVLOG(1) << "GPU: Binding ProcessControl request"; 571 DVLOG(1) << "GPU: Binding ProcessControl request";
590 DCHECK(process_control_); 572 DCHECK(process_control_);
591 process_control_bindings_.AddBinding(process_control_.get(), 573 process_control_bindings_.AddBinding(process_control_.get(),
592 std::move(request)); 574 std::move(request));
593 } 575 }
594 576
595 } // namespace content 577 } // namespace content
OLDNEW
« no previous file with comments | « content/gpu/gpu_child_thread.h ('k') | content/public/browser/render_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698