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/renderer/gpu/gpu_channel_host.h" | 5 #include "content/common/gpu/client/gpu_channel_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
10 #include "content/common/child_thread.h" | 10 #include "content/common/child_thread.h" |
| 11 #include "content/common/gpu/client/command_buffer_proxy.h" |
11 #include "content/common/gpu/gpu_messages.h" | 12 #include "content/common/gpu/gpu_messages.h" |
12 #include "content/renderer/gpu/command_buffer_proxy.h" | |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 #include "ipc/ipc_sync_message_filter.h" | 14 #include "ipc/ipc_sync_message_filter.h" |
15 | 15 |
16 GpuChannelHostFactory* GpuChannelHostFactory::instance_ = NULL; | 16 GpuChannelHostFactory* GpuChannelHostFactory::instance_ = NULL; |
17 | 17 |
18 GpuChannelHostFactory::~GpuChannelHostFactory() { | 18 GpuChannelHostFactory::~GpuChannelHostFactory() { |
19 DCHECK(!instance_); | 19 DCHECK(!instance_); |
20 } | 20 } |
21 | 21 |
22 using base::AutoLock; | 22 using base::AutoLock; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory) | 102 GpuChannelHost::GpuChannelHost(GpuChannelHostFactory* factory) |
103 : factory_(factory), | 103 : factory_(factory), |
104 state_(kUnconnected) { | 104 state_(kUnconnected) { |
105 } | 105 } |
106 | 106 |
107 GpuChannelHost::~GpuChannelHost() { | 107 GpuChannelHost::~GpuChannelHost() { |
108 } | 108 } |
109 | 109 |
110 void GpuChannelHost::Connect( | 110 void GpuChannelHost::Connect( |
111 const IPC::ChannelHandle& channel_handle, | 111 const IPC::ChannelHandle& channel_handle, |
112 base::ProcessHandle renderer_process_for_gpu) { | 112 base::ProcessHandle client_process_for_gpu) { |
113 DCHECK(factory_->IsMainThread()); | 113 DCHECK(factory_->IsMainThread()); |
114 // Open a channel to the GPU process. We pass NULL as the main listener here | 114 // Open a channel to the GPU process. We pass NULL as the main listener here |
115 // since we need to filter everything to route it to the right thread. | 115 // since we need to filter everything to route it to the right thread. |
116 channel_.reset(new IPC::SyncChannel( | 116 channel_.reset(new IPC::SyncChannel( |
117 channel_handle, IPC::Channel::MODE_CLIENT, NULL, | 117 channel_handle, IPC::Channel::MODE_CLIENT, NULL, |
118 factory_->GetIOLoopProxy(), true, | 118 factory_->GetIOLoopProxy(), true, |
119 factory_->GetShutDownEvent())); | 119 factory_->GetShutDownEvent())); |
120 | 120 |
121 sync_filter_ = new IPC::SyncMessageFilter( | 121 sync_filter_ = new IPC::SyncMessageFilter( |
122 factory_->GetShutDownEvent()); | 122 factory_->GetShutDownEvent()); |
123 | 123 |
124 channel_->AddFilter(sync_filter_.get()); | 124 channel_->AddFilter(sync_filter_.get()); |
125 | 125 |
126 channel_filter_ = new MessageFilter(this); | 126 channel_filter_ = new MessageFilter(this); |
127 | 127 |
128 // Install the filter last, because we intercept all leftover | 128 // Install the filter last, because we intercept all leftover |
129 // messages. | 129 // messages. |
130 channel_->AddFilter(channel_filter_.get()); | 130 channel_->AddFilter(channel_filter_.get()); |
131 | 131 |
132 // It is safe to send IPC messages before the channel completes the connection | 132 // It is safe to send IPC messages before the channel completes the connection |
133 // and receives the hello message from the GPU process. The messages get | 133 // and receives the hello message from the GPU process. The messages get |
134 // cached. | 134 // cached. |
135 state_ = kConnected; | 135 state_ = kConnected; |
136 | 136 |
137 // Notify the GPU process of our process handle. This gives it the ability | 137 // Notify the GPU process of our process handle. This gives it the ability |
138 // to map renderer handles into the GPU process. | 138 // to map client handles into the GPU process. |
139 Send(new GpuChannelMsg_Initialize(renderer_process_for_gpu)); | 139 Send(new GpuChannelMsg_Initialize(client_process_for_gpu)); |
140 } | 140 } |
141 | 141 |
142 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { | 142 void GpuChannelHost::set_gpu_info(const content::GPUInfo& gpu_info) { |
143 gpu_info_ = gpu_info; | 143 gpu_info_ = gpu_info; |
144 } | 144 } |
145 | 145 |
146 const content::GPUInfo& GpuChannelHost::gpu_info() const { | 146 const content::GPUInfo& GpuChannelHost::gpu_info() const { |
147 return gpu_info_; | 147 return gpu_info_; |
148 } | 148 } |
149 | 149 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 &result))) { | 309 &result))) { |
310 return false; | 310 return false; |
311 } | 311 } |
312 return result; | 312 return result; |
313 } | 313 } |
314 | 314 |
315 void GpuChannelHost::ForciblyCloseChannel() { | 315 void GpuChannelHost::ForciblyCloseChannel() { |
316 Send(new GpuChannelMsg_CloseChannel()); | 316 Send(new GpuChannelMsg_CloseChannel()); |
317 SetStateLost(); | 317 SetStateLost(); |
318 } | 318 } |
OLD | NEW |