| 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 "base/threading/thread_restrictions.h" | 8 #include "base/threading/thread_restrictions.h" |
| 9 #include "content/browser/gpu/gpu_data_manager_impl.h" | 9 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 10 #include "content/browser/gpu/gpu_process_host.h" | 10 #include "content/browser/gpu/gpu_process_host.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 EstablishGpuChannelOnIO(request); | 244 EstablishGpuChannelOnIO(request); |
| 245 } else { | 245 } else { |
| 246 request->channel_handle = channel_handle; | 246 request->channel_handle = channel_handle; |
| 247 request->gpu_info = gpu_info; | 247 request->gpu_info = gpu_info; |
| 248 request->event.Signal(); | 248 request->event.Signal(); |
| 249 } | 249 } |
| 250 } | 250 } |
| 251 | 251 |
| 252 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( | 252 GpuChannelHost* BrowserGpuChannelHostFactory::EstablishGpuChannelSync( |
| 253 CauseForGpuLaunch cause_for_gpu_launch) { | 253 CauseForGpuLaunch cause_for_gpu_launch) { |
| 254 if (gpu_channel_) { | 254 if (gpu_channel_.get()) { |
| 255 // Recreate the channel if it has been lost. | 255 // Recreate the channel if it has been lost. |
| 256 if (gpu_channel_->state() == GpuChannelHost::kLost) | 256 if (gpu_channel_->state() == GpuChannelHost::kLost) |
| 257 gpu_channel_ = NULL; | 257 gpu_channel_ = NULL; |
| 258 else | 258 else |
| 259 return gpu_channel_.get(); | 259 return gpu_channel_.get(); |
| 260 } | 260 } |
| 261 // Ensure initialization on the main thread. | 261 // Ensure initialization on the main thread. |
| 262 GpuDataManagerImpl::GetInstance(); | 262 GpuDataManagerImpl::GetInstance(); |
| 263 | 263 |
| 264 EstablishRequest request(cause_for_gpu_launch); | 264 EstablishRequest request(cause_for_gpu_launch); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 291 return gpu_channel_.get(); | 291 return gpu_channel_.get(); |
| 292 } | 292 } |
| 293 | 293 |
| 294 // static | 294 // static |
| 295 void BrowserGpuChannelHostFactory::AddFilterOnIO( | 295 void BrowserGpuChannelHostFactory::AddFilterOnIO( |
| 296 int host_id, | 296 int host_id, |
| 297 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { | 297 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { |
| 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 299 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 299 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
| 300 if (host) | 300 if (host) |
| 301 host->AddFilter(filter); | 301 host->AddFilter(filter.get()); |
| 302 } | 302 } |
| 303 | 303 |
| 304 void BrowserGpuChannelHostFactory::SetHandlerForControlMessages( | 304 void BrowserGpuChannelHostFactory::SetHandlerForControlMessages( |
| 305 const uint32* message_ids, | 305 const uint32* message_ids, |
| 306 size_t num_messages, | 306 size_t num_messages, |
| 307 const base::Callback<void(const IPC::Message&)>& handler, | 307 const base::Callback<void(const IPC::Message&)>& handler, |
| 308 base::TaskRunner* target_task_runner) { | 308 base::TaskRunner* target_task_runner) { |
| 309 scoped_refptr<IPC::ForwardingMessageFilter> filter = | 309 scoped_refptr<IPC::ForwardingMessageFilter> filter = |
| 310 new IPC::ForwardingMessageFilter(message_ids, | 310 new IPC::ForwardingMessageFilter(message_ids, |
| 311 num_messages, | 311 num_messages, |
| 312 target_task_runner); | 312 target_task_runner); |
| 313 filter->AddRoute(MSG_ROUTING_CONTROL, handler); | 313 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
| 314 | 314 |
| 315 GetIOLoopProxy()->PostTask( | 315 GetIOLoopProxy()->PostTask( |
| 316 FROM_HERE, | 316 FROM_HERE, |
| 317 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, | 317 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
| 318 gpu_host_id_, | 318 gpu_host_id_, |
| 319 filter)); | 319 filter)); |
| 320 } | 320 } |
| 321 | 321 |
| 322 } // namespace content | 322 } // namespace content |
| OLD | NEW |