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

Side by Side Diff: content/browser/gpu/gpu_process_host.cc

Issue 1883323002: Reland of Use a token to initialise ChannelMojo and MojoApplication everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/browser/gpu/gpu_process_host.h ('k') | content/browser/mojo/mojo_application_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/browser/gpu/gpu_process_host.h" 5 #include "content/browser/gpu/gpu_process_host.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 25 matching lines...) Expand all
36 #include "content/common/in_process_child_thread_params.h" 36 #include "content/common/in_process_child_thread_params.h"
37 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
38 #include "content/public/browser/browser_thread.h" 38 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/content_browser_client.h" 39 #include "content/public/browser/content_browser_client.h"
40 #include "content/public/browser/gpu_utils.h" 40 #include "content/public/browser/gpu_utils.h"
41 #include "content/public/browser/render_process_host.h" 41 #include "content/public/browser/render_process_host.h"
42 #include "content/public/browser/render_widget_host_view.h" 42 #include "content/public/browser/render_widget_host_view.h"
43 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 43 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
44 #include "content/public/common/content_client.h" 44 #include "content/public/common/content_client.h"
45 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
46 #include "content/public/common/mojo_channel_switches.h"
46 #include "content/public/common/result_codes.h" 47 #include "content/public/common/result_codes.h"
47 #include "content/public/common/sandbox_type.h" 48 #include "content/public/common/sandbox_type.h"
48 #include "content/public/common/sandboxed_process_launcher_delegate.h" 49 #include "content/public/common/sandboxed_process_launcher_delegate.h"
49 #include "gpu/command_buffer/service/gpu_preferences.h" 50 #include "gpu/command_buffer/service/gpu_preferences.h"
50 #include "gpu/command_buffer/service/gpu_switches.h" 51 #include "gpu/command_buffer/service/gpu_switches.h"
51 #include "ipc/ipc_channel_handle.h" 52 #include "ipc/ipc_channel_handle.h"
52 #include "ipc/ipc_switches.h" 53 #include "ipc/ipc_switches.h"
53 #include "ipc/message_filter.h" 54 #include "ipc/message_filter.h"
54 #include "media/base/media_switches.h" 55 #include "media/base/media_switches.h"
55 #include "ui/base/ui_base_switches.h" 56 #include "ui/base/ui_base_switches.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 541
541 bool GpuProcessHost::Init() { 542 bool GpuProcessHost::Init() {
542 init_start_time_ = base::TimeTicks::Now(); 543 init_start_time_ = base::TimeTicks::Now();
543 544
544 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); 545 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD);
545 546
546 std::string channel_id = process_->GetHost()->CreateChannel(); 547 std::string channel_id = process_->GetHost()->CreateChannel();
547 if (channel_id.empty()) 548 if (channel_id.empty())
548 return false; 549 return false;
549 550
550 if (!SetupMojo()) 551 DCHECK(!mojo_application_host_);
551 return false; 552 mojo_application_host_.reset(new MojoApplicationHost);
552 553
553 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); 554 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine();
554 if (in_process_) { 555 if (in_process_) {
555 DCHECK_CURRENTLY_ON(BrowserThread::IO); 556 DCHECK_CURRENTLY_ON(BrowserThread::IO);
556 DCHECK(g_gpu_main_thread_factory); 557 DCHECK(g_gpu_main_thread_factory);
557 in_process_gpu_thread_.reset( 558 in_process_gpu_thread_.reset(
558 g_gpu_main_thread_factory(InProcessChildThreadParams( 559 g_gpu_main_thread_factory(InProcessChildThreadParams(
559 channel_id, base::MessageLoop::current()->task_runner()), 560 channel_id, base::MessageLoop::current()->task_runner(),
561 std::string(), mojo_application_host_->GetToken()),
560 gpu_preferences)); 562 gpu_preferences));
561 base::Thread::Options options; 563 base::Thread::Options options;
562 #if defined(OS_WIN) 564 #if defined(OS_WIN)
563 // WGL needs to create its own window and pump messages on it. 565 // WGL needs to create its own window and pump messages on it.
564 options.message_loop_type = base::MessageLoop::TYPE_UI; 566 options.message_loop_type = base::MessageLoop::TYPE_UI;
565 #endif 567 #endif
566 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 568 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
567 options.priority = base::ThreadPriority::DISPLAY; 569 options.priority = base::ThreadPriority::DISPLAY;
568 #endif 570 #endif
569 in_process_gpu_thread_->StartWithOptions(options); 571 in_process_gpu_thread_->StartWithOptions(options);
570 572
571 OnProcessLaunched(); // Fake a callback that the process is ready. 573 OnProcessLaunched(); // Fake a callback that the process is ready.
572 } else if (!LaunchGpuProcess(channel_id, &gpu_preferences)) { 574 } else if (!LaunchGpuProcess(channel_id, &gpu_preferences)) {
573 return false; 575 return false;
574 } 576 }
575 577
576 if (!Send(new GpuMsg_Initialize(gpu_preferences))) 578 if (!Send(new GpuMsg_Initialize(gpu_preferences)))
577 return false; 579 return false;
578 580
579 return true; 581 return true;
580 } 582 }
581 583
582 bool GpuProcessHost::SetupMojo() {
583 DCHECK(!mojo_application_host_);
584 mojo_application_host_.reset(new MojoApplicationHost);
585 return mojo_application_host_->Init();
586 }
587
588 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { 584 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) {
589 BrowserThread::PostTask( 585 BrowserThread::PostTask(
590 BrowserThread::UI, 586 BrowserThread::UI,
591 FROM_HERE, 587 FROM_HERE,
592 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message)); 588 base::Bind(&RouteToGpuProcessHostUIShimTask, host_id_, message));
593 } 589 }
594 590
595 bool GpuProcessHost::Send(IPC::Message* msg) { 591 bool GpuProcessHost::Send(IPC::Message* msg) {
596 DCHECK(CalledOnValidThread()); 592 DCHECK(CalledOnValidThread());
597 if (process_->GetHost()->IsChannelOpening()) { 593 if (process_->GetHost()->IsChannelOpening()) {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
901 #if defined(OS_MACOSX) 897 #if defined(OS_MACOSX)
902 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( 898 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped(
903 const IPC::Message& message) { 899 const IPC::Message& message) {
904 RenderWidgetResizeHelper::PostGpuProcessMsg(host_id_, message); 900 RenderWidgetResizeHelper::PostGpuProcessMsg(host_id_, message);
905 } 901 }
906 #endif 902 #endif
907 903
908 void GpuProcessHost::OnProcessLaunched() { 904 void GpuProcessHost::OnProcessLaunched() {
909 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime", 905 UMA_HISTOGRAM_TIMES("GPU.GPUProcessLaunchTime",
910 base::TimeTicks::Now() - init_start_time_); 906 base::TimeTicks::Now() - init_start_time_);
911
912 base::ProcessHandle handle;
913 if (in_process_)
914 handle = base::GetCurrentProcessHandle();
915 else
916 handle = process_->GetData().handle;
917
918 mojo_application_host_->Activate(this, handle);
919 } 907 }
920 908
921 void GpuProcessHost::OnProcessLaunchFailed() { 909 void GpuProcessHost::OnProcessLaunchFailed() {
922 RecordProcessCrash(); 910 RecordProcessCrash();
923 } 911 }
924 912
925 void GpuProcessHost::OnProcessCrashed(int exit_code) { 913 void GpuProcessHost::OnProcessCrashed(int exit_code) {
926 SendOutstandingReplies(); 914 SendOutstandingReplies();
927 RecordProcessCrash(); 915 RecordProcessCrash();
928 GpuDataManagerImpl::GetInstance()->ProcessCrashed( 916 GpuDataManagerImpl::GetInstance()->ProcessCrashed(
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 #endif 968 #endif
981 969
982 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); 970 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags);
983 if (exe_path.empty()) 971 if (exe_path.empty())
984 return false; 972 return false;
985 973
986 base::CommandLine* cmd_line = new base::CommandLine(exe_path); 974 base::CommandLine* cmd_line = new base::CommandLine(exe_path);
987 #endif 975 #endif
988 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); 976 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess);
989 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); 977 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id);
978 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken,
979 mojo_application_host_->GetToken());
990 980
991 #if defined(OS_WIN) 981 #if defined(OS_WIN)
992 if (GetContentClient()->browser()->ShouldUseWindowsPrefetchArgument()) 982 if (GetContentClient()->browser()->ShouldUseWindowsPrefetchArgument())
993 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); 983 cmd_line->AppendArg(switches::kPrefetchArgumentGpu);
994 #endif // defined(OS_WIN) 984 #endif // defined(OS_WIN)
995 985
996 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) 986 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED)
997 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); 987 cmd_line->AppendSwitch(switches::kDisableGpuSandbox);
998 988
999 // TODO(penghuang): Replace all GPU related switches with GpuPreferences. 989 // TODO(penghuang): Replace all GPU related switches with GpuPreferences.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); 1160 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader");
1171 ClientIdToShaderCacheMap::iterator iter = 1161 ClientIdToShaderCacheMap::iterator iter =
1172 client_id_to_shader_cache_.find(client_id); 1162 client_id_to_shader_cache_.find(client_id);
1173 // If the cache doesn't exist then this is an off the record profile. 1163 // If the cache doesn't exist then this is an off the record profile.
1174 if (iter == client_id_to_shader_cache_.end()) 1164 if (iter == client_id_to_shader_cache_.end())
1175 return; 1165 return;
1176 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); 1166 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader);
1177 } 1167 }
1178 1168
1179 } // namespace content 1169 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gpu/gpu_process_host.h ('k') | content/browser/mojo/mojo_application_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698