| 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/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 <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 base::Bind(&GpuProcessHostUIShim::Destroy, | 545 base::Bind(&GpuProcessHostUIShim::Destroy, |
| 546 host_id_, | 546 host_id_, |
| 547 message)); | 547 message)); |
| 548 } | 548 } |
| 549 | 549 |
| 550 bool GpuProcessHost::Init() { | 550 bool GpuProcessHost::Init() { |
| 551 init_start_time_ = base::TimeTicks::Now(); | 551 init_start_time_ = base::TimeTicks::Now(); |
| 552 | 552 |
| 553 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); | 553 TRACE_EVENT_INSTANT0("gpu", "LaunchGpuProcess", TRACE_EVENT_SCOPE_THREAD); |
| 554 | 554 |
| 555 const std::string mojo_channel_token = | 555 std::string channel_id = process_->GetHost()->CreateChannel(); |
| 556 process_->GetHost()->CreateChannelMojo(child_token_); | 556 if (channel_id.empty()) |
| 557 if (mojo_channel_token.empty()) | |
| 558 return false; | 557 return false; |
| 559 | 558 |
| 560 DCHECK(!mojo_child_connection_); | 559 DCHECK(!mojo_child_connection_); |
| 561 mojo_child_connection_.reset(new MojoChildConnection( | 560 mojo_child_connection_.reset(new MojoChildConnection( |
| 562 kGpuMojoApplicationName, | 561 kGpuMojoApplicationName, |
| 563 "", | 562 "", |
| 564 child_token_, | 563 child_token_, |
| 565 MojoShellContext::GetConnectorForIOThread())); | 564 MojoShellContext::GetConnectorForIOThread())); |
| 566 | 565 |
| 567 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); | 566 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); |
| 568 if (in_process_) { | 567 if (in_process_) { |
| 569 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 568 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 570 DCHECK(g_gpu_main_thread_factory); | 569 DCHECK(g_gpu_main_thread_factory); |
| 571 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( | 570 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( |
| 572 InProcessChildThreadParams( | 571 InProcessChildThreadParams( |
| 573 std::string(), base::ThreadTaskRunnerHandle::Get(), | 572 channel_id, base::ThreadTaskRunnerHandle::Get(), std::string(), |
| 574 mojo_channel_token, mojo_child_connection_->service_token()), | 573 mojo_child_connection_->service_token()), |
| 575 gpu_preferences)); | 574 gpu_preferences)); |
| 576 base::Thread::Options options; | 575 base::Thread::Options options; |
| 577 #if defined(OS_WIN) | 576 #if defined(OS_WIN) |
| 578 // WGL needs to create its own window and pump messages on it. | 577 // WGL needs to create its own window and pump messages on it. |
| 579 options.message_loop_type = base::MessageLoop::TYPE_UI; | 578 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 580 #endif | 579 #endif |
| 581 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 580 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 582 options.priority = base::ThreadPriority::DISPLAY; | 581 options.priority = base::ThreadPriority::DISPLAY; |
| 583 #endif | 582 #endif |
| 584 in_process_gpu_thread_->StartWithOptions(options); | 583 in_process_gpu_thread_->StartWithOptions(options); |
| 585 | 584 |
| 586 OnProcessLaunched(); // Fake a callback that the process is ready. | 585 OnProcessLaunched(); // Fake a callback that the process is ready. |
| 587 } else if (!LaunchGpuProcess(mojo_channel_token, &gpu_preferences)) { | 586 } else if (!LaunchGpuProcess(channel_id, &gpu_preferences)) { |
| 588 return false; | 587 return false; |
| 589 } | 588 } |
| 590 | 589 |
| 591 if (!Send(new GpuMsg_Initialize(gpu_preferences))) | 590 if (!Send(new GpuMsg_Initialize(gpu_preferences))) |
| 592 return false; | 591 return false; |
| 593 | 592 |
| 594 return true; | 593 return true; |
| 595 } | 594 } |
| 596 | 595 |
| 597 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { | 596 void GpuProcessHost::RouteOnUIThread(const IPC::Message& message) { |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 if (g_gpu_process_hosts[kind_] == this) | 949 if (g_gpu_process_hosts[kind_] == this) |
| 951 g_gpu_process_hosts[kind_] = NULL; | 950 g_gpu_process_hosts[kind_] = NULL; |
| 952 | 951 |
| 953 process_->ForceShutdown(); | 952 process_->ForceShutdown(); |
| 954 } | 953 } |
| 955 | 954 |
| 956 void GpuProcessHost::StopGpuProcess() { | 955 void GpuProcessHost::StopGpuProcess() { |
| 957 Send(new GpuMsg_Finalize()); | 956 Send(new GpuMsg_Finalize()); |
| 958 } | 957 } |
| 959 | 958 |
| 960 bool GpuProcessHost::LaunchGpuProcess(const std::string& mojo_channel_token, | 959 bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id, |
| 961 gpu::GpuPreferences* gpu_preferences) { | 960 gpu::GpuPreferences* gpu_preferences) { |
| 962 if (!(gpu_enabled_ && | 961 if (!(gpu_enabled_ && |
| 963 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && | 962 GpuDataManagerImpl::GetInstance()->ShouldUseSwiftShader()) && |
| 964 !hardware_gpu_enabled_) { | 963 !hardware_gpu_enabled_) { |
| 965 SendOutstandingReplies(); | 964 SendOutstandingReplies(); |
| 966 return false; | 965 return false; |
| 967 } | 966 } |
| 968 | 967 |
| 969 const base::CommandLine& browser_command_line = | 968 const base::CommandLine& browser_command_line = |
| 970 *base::CommandLine::ForCurrentProcess(); | 969 *base::CommandLine::ForCurrentProcess(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 986 int child_flags = ChildProcessHost::CHILD_NORMAL; | 985 int child_flags = ChildProcessHost::CHILD_NORMAL; |
| 987 #endif | 986 #endif |
| 988 | 987 |
| 989 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); | 988 base::FilePath exe_path = ChildProcessHost::GetChildPath(child_flags); |
| 990 if (exe_path.empty()) | 989 if (exe_path.empty()) |
| 991 return false; | 990 return false; |
| 992 | 991 |
| 993 base::CommandLine* cmd_line = new base::CommandLine(exe_path); | 992 base::CommandLine* cmd_line = new base::CommandLine(exe_path); |
| 994 #endif | 993 #endif |
| 995 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); | 994 cmd_line->AppendSwitchASCII(switches::kProcessType, switches::kGpuProcess); |
| 996 cmd_line->AppendSwitchASCII(switches::kMojoChannelToken, mojo_channel_token); | 995 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 997 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, | 996 cmd_line->AppendSwitchASCII(switches::kMojoApplicationChannelToken, |
| 998 mojo_child_connection_->service_token()); | 997 mojo_child_connection_->service_token()); |
| 999 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); | 998 BrowserChildProcessHostImpl::CopyFeatureAndFieldTrialFlags(cmd_line); |
| 1000 | 999 |
| 1001 #if defined(OS_WIN) | 1000 #if defined(OS_WIN) |
| 1002 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); | 1001 cmd_line->AppendArg(switches::kPrefetchArgumentGpu); |
| 1003 #endif // defined(OS_WIN) | 1002 #endif // defined(OS_WIN) |
| 1004 | 1003 |
| 1005 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) | 1004 if (kind_ == GPU_PROCESS_KIND_UNSANDBOXED) |
| 1006 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); | 1005 cmd_line->AppendSwitch(switches::kDisableGpuSandbox); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1182 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); | 1181 TRACE_EVENT0("gpu", "GpuProcessHost::OnCacheShader"); |
| 1183 ClientIdToShaderCacheMap::iterator iter = | 1182 ClientIdToShaderCacheMap::iterator iter = |
| 1184 client_id_to_shader_cache_.find(client_id); | 1183 client_id_to_shader_cache_.find(client_id); |
| 1185 // If the cache doesn't exist then this is an off the record profile. | 1184 // If the cache doesn't exist then this is an off the record profile. |
| 1186 if (iter == client_id_to_shader_cache_.end()) | 1185 if (iter == client_id_to_shader_cache_.end()) |
| 1187 return; | 1186 return; |
| 1188 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); | 1187 iter->second->Cache(GetShaderPrefixKey() + ":" + key, shader); |
| 1189 } | 1188 } |
| 1190 | 1189 |
| 1191 } // namespace content | 1190 } // namespace content |
| OLD | NEW |