| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/gpu_process_host.h" | 5 #include "chrome/browser/gpu_process_host.h" |
| 6 | 6 |
| 7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/thread.h" | 9 #include "base/thread.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (exe_path.empty()) | 83 if (exe_path.empty()) |
| 84 return false; | 84 return false; |
| 85 | 85 |
| 86 CommandLine* cmd_line = new CommandLine(exe_path); | 86 CommandLine* cmd_line = new CommandLine(exe_path); |
| 87 cmd_line->AppendSwitchWithValue(switches::kProcessType, | 87 cmd_line->AppendSwitchWithValue(switches::kProcessType, |
| 88 switches::kGpuProcess); | 88 switches::kGpuProcess); |
| 89 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, | 89 cmd_line->AppendSwitchWithValue(switches::kProcessChannelID, |
| 90 ASCIIToWide(channel_id())); | 90 ASCIIToWide(channel_id())); |
| 91 | 91 |
| 92 // Propagate relevant command line switches. | 92 // Propagate relevant command line switches. |
| 93 static const char* const switch_names[] = { | 93 static const char* const kSwitchNames[] = { |
| 94 switches::kUseGL, | 94 switches::kUseGL, |
| 95 switches::kDisableLogging, |
| 96 switches::kEnableLogging, |
| 97 switches::kGpuStartupDialog, |
| 98 switches::kLoggingLevel, |
| 95 }; | 99 }; |
| 96 | 100 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 97 for (size_t i = 0; i < arraysize(switch_names); ++i) { | 101 arraysize(kSwitchNames)); |
| 98 if (browser_command_line.HasSwitch(switch_names[i])) { | |
| 99 cmd_line->AppendSwitchWithValue(switch_names[i], | |
| 100 browser_command_line.GetSwitchValueASCII(switch_names[i])); | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 const CommandLine& browser_cmd_line = *CommandLine::ForCurrentProcess(); | |
| 105 PropagateBrowserCommandLineToGpu(browser_cmd_line, cmd_line); | |
| 106 | 102 |
| 107 // If specified, prepend a launcher program to the command line. | 103 // If specified, prepend a launcher program to the command line. |
| 108 if (!gpu_launcher.empty()) | 104 if (!gpu_launcher.empty()) |
| 109 cmd_line->PrependWrapper(gpu_launcher); | 105 cmd_line->PrependWrapper(gpu_launcher); |
| 110 | 106 |
| 111 Launch( | 107 Launch( |
| 112 #if defined(OS_WIN) | 108 #if defined(OS_WIN) |
| 113 FilePath(), | 109 FilePath(), |
| 114 #elif defined(OS_POSIX) | 110 #elif defined(OS_POSIX) |
| 115 false, // Never use the zygote (GPU plugin can't be sandboxed). | 111 false, // Never use the zygote (GPU plugin can't be sandboxed). |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 ResourceMessageFilter* filter) { | 204 ResourceMessageFilter* filter) { |
| 209 ViewMsg_GpuChannelEstablished* message = | 205 ViewMsg_GpuChannelEstablished* message = |
| 210 new ViewMsg_GpuChannelEstablished(channel); | 206 new ViewMsg_GpuChannelEstablished(channel); |
| 211 // If the renderer process is performing synchronous initialization, | 207 // If the renderer process is performing synchronous initialization, |
| 212 // it needs to handle this message before receiving the reply for | 208 // it needs to handle this message before receiving the reply for |
| 213 // the synchronous ViewHostMsg_SynchronizeGpu message. | 209 // the synchronous ViewHostMsg_SynchronizeGpu message. |
| 214 message->set_unblock(true); | 210 message->set_unblock(true); |
| 215 filter->Send(message); | 211 filter->Send(message); |
| 216 } | 212 } |
| 217 | 213 |
| 218 void GpuProcessHost::PropagateBrowserCommandLineToGpu( | |
| 219 const CommandLine& browser_cmd, | |
| 220 CommandLine* gpu_cmd) const { | |
| 221 // Propagate the following switches to the GPU process command line (along | |
| 222 // with any associated values) if present in the browser command line. | |
| 223 static const char* const switch_names[] = { | |
| 224 switches::kDisableLogging, | |
| 225 switches::kEnableLogging, | |
| 226 switches::kGpuStartupDialog, | |
| 227 switches::kLoggingLevel, | |
| 228 }; | |
| 229 | |
| 230 for (size_t i = 0; i < arraysize(switch_names); ++i) { | |
| 231 if (browser_cmd.HasSwitch(switch_names[i])) { | |
| 232 gpu_cmd->AppendSwitchWithValue(switch_names[i], | |
| 233 browser_cmd.GetSwitchValueASCII(switch_names[i])); | |
| 234 } | |
| 235 } | |
| 236 } | |
| 237 | |
| 238 URLRequestContext* GpuProcessHost::GetRequestContext( | 214 URLRequestContext* GpuProcessHost::GetRequestContext( |
| 239 uint32 request_id, | 215 uint32 request_id, |
| 240 const ViewHostMsg_Resource_Request& request_data) { | 216 const ViewHostMsg_Resource_Request& request_data) { |
| 241 return NULL; | 217 return NULL; |
| 242 } | 218 } |
| 243 | 219 |
| 244 bool GpuProcessHost::CanShutdown() { | 220 bool GpuProcessHost::CanShutdown() { |
| 245 return true; | 221 return true; |
| 246 } | 222 } |
| OLD | NEW |