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/browser_gpu_channel_host_factory.h" | 5 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "content/browser/gpu/gpu_data_manager_impl.h" | 8 #include "content/browser/gpu/gpu_data_manager_impl.h" |
9 #include "content/browser/gpu/gpu_process_host.h" | 9 #include "content/browser/gpu/gpu_process_host.h" |
10 #include "content/browser/gpu/gpu_surface_tracker.h" | 10 #include "content/browser/gpu/gpu_surface_tracker.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 gpu_client_id_, | 146 gpu_client_id_, |
147 true, | 147 true, |
148 base::Bind(&BrowserGpuChannelHostFactory::GpuChannelEstablishedOnIO, | 148 base::Bind(&BrowserGpuChannelHostFactory::GpuChannelEstablishedOnIO, |
149 request)); | 149 request)); |
150 } | 150 } |
151 | 151 |
152 // static | 152 // static |
153 void BrowserGpuChannelHostFactory::GpuChannelEstablishedOnIO( | 153 void BrowserGpuChannelHostFactory::GpuChannelEstablishedOnIO( |
154 EstablishRequest* request, | 154 EstablishRequest* request, |
155 const IPC::ChannelHandle& channel_handle, | 155 const IPC::ChannelHandle& channel_handle, |
| 156 base::ProcessHandle gpu_process_handle, |
156 const GPUInfo& gpu_info) { | 157 const GPUInfo& gpu_info) { |
157 request->channel_handle = channel_handle; | 158 request->channel_handle = channel_handle; |
| 159 request->gpu_process_handle = gpu_process_handle; |
158 request->gpu_info = gpu_info; | 160 request->gpu_info = gpu_info; |
159 request->event.Signal(); | 161 request->event.Signal(); |
160 } | 162 } |
161 | 163 |
162 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( | 164 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( |
163 CauseForGpuLaunch cause_for_gpu_launch) { | 165 CauseForGpuLaunch cause_for_gpu_launch) { |
164 if (gpu_channel_.get()) { | 166 if (gpu_channel_.get()) { |
165 // Recreate the channel if it has been lost. | 167 // Recreate the channel if it has been lost. |
166 if (gpu_channel_->state() == GpuChannelHost::kLost) | 168 if (gpu_channel_->state() == GpuChannelHost::kLost) |
167 gpu_channel_ = NULL; | 169 gpu_channel_ = NULL; |
(...skipping 14 matching lines...) Expand all Loading... |
182 // We're blocking the UI thread, which is generally undesirable. | 184 // We're blocking the UI thread, which is generally undesirable. |
183 // In this case we need to wait for this before we can show any UI /anyway/, | 185 // In this case we need to wait for this before we can show any UI /anyway/, |
184 // so it won't cause additional jank. | 186 // so it won't cause additional jank. |
185 // TODO(piman): Make this asynchronous. | 187 // TODO(piman): Make this asynchronous. |
186 request.event.Wait(); | 188 request.event.Wait(); |
187 | 189 |
188 if (request.channel_handle.name.empty() || | 190 if (request.channel_handle.name.empty() || |
189 request.gpu_process_handle == base::kNullProcessHandle) | 191 request.gpu_process_handle == base::kNullProcessHandle) |
190 return NULL; | 192 return NULL; |
191 | 193 |
| 194 base::ProcessHandle browser_process_for_gpu; |
| 195 #if defined(OS_WIN) |
| 196 // Create a process handle that the GPU process can use to access our handles. |
| 197 DuplicateHandle(base::GetCurrentProcessHandle(), |
| 198 base::GetCurrentProcessHandle(), |
| 199 request.gpu_process_handle, |
| 200 &browser_process_for_gpu, |
| 201 PROCESS_DUP_HANDLE, |
| 202 FALSE, |
| 203 0); |
| 204 #else |
| 205 browser_process_for_gpu = base::GetCurrentProcessHandle(); |
| 206 #endif |
| 207 |
192 gpu_channel_ = new GpuChannelHost(this, gpu_host_id_, gpu_client_id_); | 208 gpu_channel_ = new GpuChannelHost(this, gpu_host_id_, gpu_client_id_); |
193 gpu_channel_->set_gpu_info(request.gpu_info); | 209 gpu_channel_->set_gpu_info(request.gpu_info); |
194 content::GetContentClient()->SetGpuInfo(request.gpu_info); | 210 content::GetContentClient()->SetGpuInfo(request.gpu_info); |
195 | 211 |
196 // Connect to the GPU process if a channel name was received. | 212 // Connect to the GPU process if a channel name was received. |
197 gpu_channel_->Connect(request.channel_handle); | 213 gpu_channel_->Connect(request.channel_handle, browser_process_for_gpu); |
198 | 214 |
199 return gpu_channel_.get(); | 215 return gpu_channel_.get(); |
200 } | 216 } |
201 | 217 |
202 } // namespace content | 218 } // namespace content |
OLD | NEW |