| 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/gpu/gpu_thread.h" | 5 #include "chrome/gpu/gpu_thread.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/gfx/gl/gl_context.h" | 10 #include "app/gfx/gl/gl_context.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 return sandbox_wrapper.InitializeSandbox(*parsed_command_line, | 37 return sandbox_wrapper.InitializeSandbox(*parsed_command_line, |
| 38 switches::kGpuProcess); | 38 switches::kGpuProcess); |
| 39 #else | 39 #else |
| 40 // TODO(port): Create GPU sandbox for linux and windows. | 40 // TODO(port): Create GPU sandbox for linux and windows. |
| 41 return true; | 41 return true; |
| 42 #endif | 42 #endif |
| 43 } | 43 } |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 GpuThread::GpuThread(const CommandLine& command_line) | 47 GpuThread::GpuThread() { |
| 48 : command_line_(command_line) {} | 48 } |
| 49 |
| 50 GpuThread::GpuThread(const std::string& channel_id) |
| 51 : ChildThread(channel_id) { |
| 52 } |
| 49 | 53 |
| 50 GpuThread::~GpuThread() { | 54 GpuThread::~GpuThread() { |
| 51 } | 55 } |
| 52 | 56 |
| 53 void GpuThread::Init(const base::Time& process_start_time) { | 57 void GpuThread::Init(const base::Time& process_start_time) { |
| 54 process_start_time_ = process_start_time; | 58 process_start_time_ = process_start_time; |
| 55 } | 59 } |
| 56 | 60 |
| 57 void GpuThread::RemoveChannel(int renderer_id) { | 61 void GpuThread::RemoveChannel(int renderer_id) { |
| 58 gpu_channels_.erase(renderer_id); | 62 gpu_channels_.erase(renderer_id); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // Flag GPU info as complete if the DirectX diagnostics cannot be collected. | 105 // Flag GPU info as complete if the DirectX diagnostics cannot be collected. |
| 102 gpu_info_.SetProgress(GPUInfo::kComplete); | 106 gpu_info_.SetProgress(GPUInfo::kComplete); |
| 103 } | 107 } |
| 104 #endif | 108 #endif |
| 105 | 109 |
| 106 // Record initialization only after collecting the GPU info because that can | 110 // Record initialization only after collecting the GPU info because that can |
| 107 // take a significant amount of time. | 111 // take a significant amount of time. |
| 108 gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time_); | 112 gpu_info_.SetInitializationTime(base::Time::Now() - process_start_time_); |
| 109 | 113 |
| 110 // Note that kNoSandbox will also disable the GPU sandbox. | 114 // Note that kNoSandbox will also disable the GPU sandbox. |
| 111 bool no_gpu_sandbox = command_line_.HasSwitch(switches::kNoGpuSandbox); | 115 bool no_gpu_sandbox = CommandLine::ForCurrentProcess()->HasSwitch( |
| 116 switches::kNoGpuSandbox); |
| 112 if (!no_gpu_sandbox) { | 117 if (!no_gpu_sandbox) { |
| 113 if (!InitializeGpuSandbox()) { | 118 if (!InitializeGpuSandbox()) { |
| 114 LOG(ERROR) << "Failed to initialize the GPU sandbox"; | 119 LOG(ERROR) << "Failed to initialize the GPU sandbox"; |
| 115 MessageLoop::current()->Quit(); | 120 MessageLoop::current()->Quit(); |
| 116 return; | 121 return; |
| 117 } | 122 } |
| 118 } else { | 123 } else { |
| 119 LOG(ERROR) << "Running without GPU sandbox"; | 124 LOG(ERROR) << "Running without GPU sandbox"; |
| 120 } | 125 } |
| 121 | 126 |
| 122 // In addition to disabling the watchdog if the command line switch is | 127 // In addition to disabling the watchdog if the command line switch is |
| 123 // present, disable it in two other cases. OSMesa is expected to run very | 128 // present, disable it in two other cases. OSMesa is expected to run very |
| 124 // slowly. Also disable the watchdog on valgrind because the code is expected | 129 // slowly. Also disable the watchdog on valgrind because the code is expected |
| 125 // to run slowly in that case. | 130 // to run slowly in that case. |
| 126 bool enable_watchdog = | 131 bool enable_watchdog = |
| 127 !command_line_.HasSwitch(switches::kDisableGpuWatchdog) && | 132 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 133 switches::kDisableGpuWatchdog) && |
| 128 gfx::GetGLImplementation() != gfx::kGLImplementationOSMesaGL && | 134 gfx::GetGLImplementation() != gfx::kGLImplementationOSMesaGL && |
| 129 !RunningOnValgrind(); | 135 !RunningOnValgrind(); |
| 130 | 136 |
| 131 // Disable the watchdog in debug builds because they tend to only be run by | 137 // Disable the watchdog in debug builds because they tend to only be run by |
| 132 // developers who will not appreciate the watchdog killing the GPU process. | 138 // developers who will not appreciate the watchdog killing the GPU process. |
| 133 #ifndef NDEBUG | 139 #ifndef NDEBUG |
| 134 enable_watchdog = false; | 140 enable_watchdog = false; |
| 135 #endif | 141 #endif |
| 136 | 142 |
| 137 // Disable the watchdog for Windows. It tends to abort when the GPU process | 143 // Disable the watchdog for Windows. It tends to abort when the GPU process |
| (...skipping 19 matching lines...) Expand all Loading... |
| 157 } | 163 } |
| 158 } | 164 } |
| 159 | 165 |
| 160 void GpuThread::OnEstablishChannel(int renderer_id) { | 166 void GpuThread::OnEstablishChannel(int renderer_id) { |
| 161 scoped_refptr<GpuChannel> channel; | 167 scoped_refptr<GpuChannel> channel; |
| 162 IPC::ChannelHandle channel_handle; | 168 IPC::ChannelHandle channel_handle; |
| 163 GPUInfo gpu_info; | 169 GPUInfo gpu_info; |
| 164 | 170 |
| 165 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); | 171 GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id); |
| 166 if (iter == gpu_channels_.end()) | 172 if (iter == gpu_channels_.end()) |
| 167 channel = new GpuChannel(renderer_id); | 173 channel = new GpuChannel(this, renderer_id); |
| 168 else | 174 else |
| 169 channel = iter->second; | 175 channel = iter->second; |
| 170 | 176 |
| 171 DCHECK(channel != NULL); | 177 DCHECK(channel != NULL); |
| 172 | 178 |
| 173 if (channel->Init()) | 179 if (channel->Init()) |
| 174 gpu_channels_[renderer_id] = channel; | 180 gpu_channels_[renderer_id] = channel; |
| 175 else | 181 else |
| 176 channel = NULL; | 182 channel = NULL; |
| 177 | 183 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 NewRunnableFunction(&GpuThread::SetDxDiagnostics, thread, node)); | 259 NewRunnableFunction(&GpuThread::SetDxDiagnostics, thread, node)); |
| 254 } | 260 } |
| 255 | 261 |
| 256 // Runs on the GPU thread. | 262 // Runs on the GPU thread. |
| 257 void GpuThread::SetDxDiagnostics(GpuThread* thread, const DxDiagNode& node) { | 263 void GpuThread::SetDxDiagnostics(GpuThread* thread, const DxDiagNode& node) { |
| 258 thread->gpu_info_.SetDxDiagnostics(node); | 264 thread->gpu_info_.SetDxDiagnostics(node); |
| 259 thread->gpu_info_.SetProgress(GPUInfo::kComplete); | 265 thread->gpu_info_.SetProgress(GPUInfo::kComplete); |
| 260 } | 266 } |
| 261 | 267 |
| 262 #endif | 268 #endif |
| OLD | NEW |