| 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 #if defined(OS_WIN) | 5 #if defined(OS_WIN) |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "content/browser/gpu_process_host.h" | 9 #include "content/browser/gpu_process_host.h" |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 gpu_thread_.reset(); | 95 gpu_thread_.reset(); |
| 96 } | 96 } |
| 97 | 97 |
| 98 private: | 98 private: |
| 99 scoped_ptr<GpuThread> gpu_thread_; | 99 scoped_ptr<GpuThread> gpu_thread_; |
| 100 std::string channel_id_; | 100 std::string channel_id_; |
| 101 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); | 101 DISALLOW_COPY_AND_ASSIGN(GpuMainThread); |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 // static | 104 // static |
| 105 GpuProcessHost* GpuProcessHost::Create(int host_id) { | 105 GpuProcessHost* GpuProcessHost::Create( |
| 106 int host_id, |
| 107 const GpuFeatureFlags& gpu_feature_flags) { |
| 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 108 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 107 | 109 |
| 108 GpuProcessHost* host = new GpuProcessHost(host_id); | 110 GpuProcessHost* host = new GpuProcessHost(host_id, gpu_feature_flags); |
| 109 if (!host->Init()) { | 111 if (!host->Init()) { |
| 110 delete host; | 112 delete host; |
| 111 return NULL; | 113 return NULL; |
| 112 } | 114 } |
| 113 | 115 |
| 114 return host; | 116 return host; |
| 115 } | 117 } |
| 116 | 118 |
| 117 // static | 119 // static |
| 118 GpuProcessHost* GpuProcessHost::FromID(int host_id) { | 120 GpuProcessHost* GpuProcessHost::FromID(int host_id) { |
| 119 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 120 | 122 |
| 121 if (host_id == 0) | 123 if (host_id == 0) |
| 122 return NULL; | 124 return NULL; |
| 123 | 125 |
| 124 return g_hosts_by_id.Lookup(host_id); | 126 return g_hosts_by_id.Lookup(host_id); |
| 125 } | 127 } |
| 126 | 128 |
| 127 GpuProcessHost::GpuProcessHost(int host_id) | 129 GpuProcessHost::GpuProcessHost( |
| 130 int host_id, |
| 131 const GpuFeatureFlags& gpu_feature_flags) |
| 128 : BrowserChildProcessHost(GPU_PROCESS, NULL), | 132 : BrowserChildProcessHost(GPU_PROCESS, NULL), |
| 129 host_id_(host_id) { | 133 host_id_(host_id), |
| 134 gpu_feature_flags_(gpu_feature_flags) { |
| 130 g_hosts_by_id.AddWithID(this, host_id_); | 135 g_hosts_by_id.AddWithID(this, host_id_); |
| 131 } | 136 } |
| 132 | 137 |
| 133 GpuProcessHost::~GpuProcessHost() { | 138 GpuProcessHost::~GpuProcessHost() { |
| 134 | 139 |
| 135 DCHECK(CalledOnValidThread()); | 140 DCHECK(CalledOnValidThread()); |
| 136 | 141 |
| 137 g_hosts_by_id.Remove(host_id_); | 142 g_hosts_by_id.Remove(host_id_); |
| 138 | 143 |
| 139 BrowserThread::PostTask(BrowserThread::UI, | 144 BrowserThread::PostTask(BrowserThread::UI, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 switches::kDisableLogging, | 294 switches::kDisableLogging, |
| 290 switches::kEnableAcceleratedDecoding, | 295 switches::kEnableAcceleratedDecoding, |
| 291 switches::kEnableLogging, | 296 switches::kEnableLogging, |
| 292 #if defined(OS_MACOSX) | 297 #if defined(OS_MACOSX) |
| 293 switches::kEnableSandboxLogging, | 298 switches::kEnableSandboxLogging, |
| 294 #endif | 299 #endif |
| 295 switches::kGpuStartupDialog, | 300 switches::kGpuStartupDialog, |
| 296 switches::kLoggingLevel, | 301 switches::kLoggingLevel, |
| 297 switches::kNoGpuSandbox, | 302 switches::kNoGpuSandbox, |
| 298 switches::kNoSandbox, | 303 switches::kNoSandbox, |
| 304 switches::kDisableGLMultisampling, |
| 299 }; | 305 }; |
| 300 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, | 306 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 301 arraysize(kSwitchNames)); | 307 arraysize(kSwitchNames)); |
| 302 | 308 |
| 309 if (gpu_feature_flags_.flags() & GpuFeatureFlags::kGpuFeatureMultisampling) { |
| 310 cmd_line->AppendSwitch(switches::kDisableGLMultisampling); |
| 311 } |
| 312 |
| 303 // If specified, prepend a launcher program to the command line. | 313 // If specified, prepend a launcher program to the command line. |
| 304 if (!gpu_launcher.empty()) | 314 if (!gpu_launcher.empty()) |
| 305 cmd_line->PrependWrapper(gpu_launcher); | 315 cmd_line->PrependWrapper(gpu_launcher); |
| 306 | 316 |
| 307 Launch( | 317 Launch( |
| 308 #if defined(OS_WIN) | 318 #if defined(OS_WIN) |
| 309 FilePath(), | 319 FilePath(), |
| 310 #elif defined(OS_POSIX) | 320 #elif defined(OS_POSIX) |
| 311 false, // Never use the zygote (GPU plugin can't be sandboxed). | 321 false, // Never use the zygote (GPU plugin can't be sandboxed). |
| 312 base::environment_vector(), | 322 base::environment_vector(), |
| 313 #endif | 323 #endif |
| 314 cmd_line); | 324 cmd_line); |
| 315 | 325 |
| 316 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", | 326 UMA_HISTOGRAM_ENUMERATION("GPU.GPUProcessLifetimeEvents", |
| 317 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); | 327 LAUNCHED, GPU_PROCESS_LIFETIME_EVENT_MAX); |
| 318 return true; | 328 return true; |
| 319 } | 329 } |
| OLD | NEW |