Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(773)

Side by Side Diff: content/browser/gpu/browser_gpu_channel_host_factory.cc

Issue 9958034: Convert plugin and GPU process to brokered handle duplication. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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,
157 const GPUInfo& gpu_info) { 156 const GPUInfo& gpu_info) {
158 request->channel_handle = channel_handle; 157 request->channel_handle = channel_handle;
159 request->gpu_process_handle = gpu_process_handle;
160 request->gpu_info = gpu_info; 158 request->gpu_info = gpu_info;
161 request->event.Signal(); 159 request->event.Signal();
162 } 160 }
163 161
164 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( 162 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync(
165 CauseForGpuLaunch cause_for_gpu_launch) { 163 CauseForGpuLaunch cause_for_gpu_launch) {
166 if (gpu_channel_.get()) { 164 if (gpu_channel_.get()) {
167 // Recreate the channel if it has been lost. 165 // Recreate the channel if it has been lost.
168 if (gpu_channel_->state() == GpuChannelHost::kLost) 166 if (gpu_channel_->state() == GpuChannelHost::kLost)
169 gpu_channel_ = NULL; 167 gpu_channel_ = NULL;
(...skipping 14 matching lines...) Expand all
184 // We're blocking the UI thread, which is generally undesirable. 182 // We're blocking the UI thread, which is generally undesirable.
185 // In this case we need to wait for this before we can show any UI /anyway/, 183 // In this case we need to wait for this before we can show any UI /anyway/,
186 // so it won't cause additional jank. 184 // so it won't cause additional jank.
187 // TODO(piman): Make this asynchronous. 185 // TODO(piman): Make this asynchronous.
188 request.event.Wait(); 186 request.event.Wait();
189 187
190 if (request.channel_handle.name.empty() || 188 if (request.channel_handle.name.empty() ||
191 request.gpu_process_handle == base::kNullProcessHandle) 189 request.gpu_process_handle == base::kNullProcessHandle)
192 return NULL; 190 return NULL;
193 191
194 base::ProcessHandle browser_process_for_gpu; 192 gpu_channel_ = new GpuChannelHost(this, gpu_client_id_);
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
208 gpu_channel_ = new GpuChannelHost(this, gpu_host_id_, gpu_client_id_);
apatrick_chromium 2012/04/09 18:40:58 gpu_host_id_ is not a PID. I think a mistake has b
jschuh 2012/04/10 19:02:12 Okay, I plumbed it back in. Oddly enough, it seems
209 gpu_channel_->set_gpu_info(request.gpu_info); 193 gpu_channel_->set_gpu_info(request.gpu_info);
210 content::GetContentClient()->SetGpuInfo(request.gpu_info); 194 content::GetContentClient()->SetGpuInfo(request.gpu_info);
211 195
212 // Connect to the GPU process if a channel name was received. 196 // Connect to the GPU process if a channel name was received.
213 gpu_channel_->Connect(request.channel_handle, browser_process_for_gpu); 197 gpu_channel_->Connect(request.channel_handle);
214 198
215 return gpu_channel_.get(); 199 return gpu_channel_.get();
216 } 200 }
217 201
218 } // namespace content 202 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698