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" |
11 #include "content/browser/gpu/gpu_surface_tracker.h" | 11 #include "content/browser/gpu/gpu_surface_tracker.h" |
12 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
13 #include "content/common/child_process_host_impl.h" | 13 #include "content/common/child_process_host_impl.h" |
14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 16 #include "ipc/ipc_forwarding_message_filter.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; | 20 BrowserGpuChannelHostFactory* BrowserGpuChannelHostFactory::instance_ = NULL; |
20 | 21 |
21 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() | 22 BrowserGpuChannelHostFactory::CreateRequest::CreateRequest() |
22 : event(false, false), | 23 : event(false, false), |
23 gpu_host_id(0), | 24 gpu_host_id(0), |
24 route_id(MSG_ROUTING_NONE) { | 25 route_id(MSG_ROUTING_NONE) { |
25 } | 26 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 gpu_channel_ = new GpuChannelHost(this, request.gpu_host_id, gpu_client_id_); | 284 gpu_channel_ = new GpuChannelHost(this, request.gpu_host_id, gpu_client_id_); |
284 gpu_channel_->set_gpu_info(request.gpu_info); | 285 gpu_channel_->set_gpu_info(request.gpu_info); |
285 GetContentClient()->SetGpuInfo(request.gpu_info); | 286 GetContentClient()->SetGpuInfo(request.gpu_info); |
286 | 287 |
287 // Connect to the GPU process if a channel name was received. | 288 // Connect to the GPU process if a channel name was received. |
288 gpu_channel_->Connect(request.channel_handle); | 289 gpu_channel_->Connect(request.channel_handle); |
289 | 290 |
290 return gpu_channel_.get(); | 291 return gpu_channel_.get(); |
291 } | 292 } |
292 | 293 |
| 294 // static |
| 295 void BrowserGpuChannelHostFactory::AddFilterOnIO( |
| 296 int host_id, |
| 297 scoped_refptr<IPC::ChannelProxy::MessageFilter> filter) { |
| 298 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 299 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
| 300 if (host) |
| 301 host->AddFilter(filter); |
| 302 } |
| 303 |
| 304 void BrowserGpuChannelHostFactory::SetHandlerForControlMessages( |
| 305 const uint32* message_ids, |
| 306 size_t num_messages, |
| 307 const base::Callback<void(const IPC::Message&)>& handler, |
| 308 base::TaskRunner* target_task_runner) { |
| 309 scoped_refptr<IPC::ForwardingMessageFilter> filter = |
| 310 new IPC::ForwardingMessageFilter(message_ids, |
| 311 num_messages, |
| 312 target_task_runner); |
| 313 filter->AddRoute(MSG_ROUTING_CONTROL, handler); |
| 314 |
| 315 GetIOLoopProxy()->PostTask( |
| 316 FROM_HERE, |
| 317 base::Bind(&BrowserGpuChannelHostFactory::AddFilterOnIO, |
| 318 gpu_host_id_, |
| 319 filter)); |
| 320 } |
| 321 |
293 } // namespace content | 322 } // namespace content |
OLD | NEW |