| 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/common/gpu/client/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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 // Currently we need to choose between two different mechanisms for sending. | 105 // Currently we need to choose between two different mechanisms for sending. |
| 106 // On the main thread we use the regular channel Send() method, on another | 106 // On the main thread we use the regular channel Send() method, on another |
| 107 // thread we use SyncMessageFilter. We also have to be careful interpreting | 107 // thread we use SyncMessageFilter. We also have to be careful interpreting |
| 108 // IsMainThread() since it might return false during shutdown, | 108 // IsMainThread() since it might return false during shutdown, |
| 109 // impl we are actually calling from the main thread (discard message then). | 109 // impl we are actually calling from the main thread (discard message then). |
| 110 // | 110 // |
| 111 // TODO: Can we just always use sync_filter_ since we setup the channel | 111 // TODO: Can we just always use sync_filter_ since we setup the channel |
| 112 // without a main listener? | 112 // without a main listener? |
| 113 if (factory_->IsMainThread()) { | 113 if (factory_->IsMainThread()) { |
| 114 if (channel_.get()) { | 114 if (channel_) { |
| 115 // http://crbug.com/125264 | 115 // http://crbug.com/125264 |
| 116 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 116 base::ThreadRestrictions::ScopedAllowWait allow_wait; |
| 117 return channel_->Send(message); | 117 return channel_->Send(message); |
| 118 } | 118 } |
| 119 } else if (MessageLoop::current()) { | 119 } else if (MessageLoop::current()) { |
| 120 return sync_filter_->Send(message); | 120 return sync_filter_->Send(message); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Callee takes ownership of message, regardless of whether Send is | 123 // Callee takes ownership of message, regardless of whether Send is |
| 124 // successful. See IPC::Sender. | 124 // successful. See IPC::Sender. |
| 125 delete message; | 125 delete message; |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 | 128 |
| 129 CommandBufferProxyImpl* GpuChannelHost::CreateViewCommandBuffer( | 129 CommandBufferProxyImpl* GpuChannelHost::CreateViewCommandBuffer( |
| 130 int32 surface_id, | 130 int32 surface_id, |
| 131 CommandBufferProxyImpl* share_group, | 131 CommandBufferProxyImpl* share_group, |
| 132 const std::string& allowed_extensions, | 132 const std::string& allowed_extensions, |
| 133 const std::vector<int32>& attribs, | 133 const std::vector<int32>& attribs, |
| 134 const GURL& active_url, | 134 const GURL& active_url, |
| 135 gfx::GpuPreference gpu_preference) { | 135 gfx::GpuPreference gpu_preference) { |
| 136 TRACE_EVENT1("gpu", | 136 TRACE_EVENT1("gpu", |
| 137 "GpuChannelHost::CreateViewCommandBuffer", | 137 "GpuChannelHost::CreateViewCommandBuffer", |
| 138 "surface_id", | 138 "surface_id", |
| 139 surface_id); | 139 surface_id); |
| 140 | 140 |
| 141 AutoLock lock(context_lock_); | 141 AutoLock lock(context_lock_); |
| 142 // An error occurred. Need to get the host again to reinitialize it. | 142 // An error occurred. Need to get the host again to reinitialize it. |
| 143 if (!channel_.get()) | 143 if (!channel_) |
| 144 return NULL; | 144 return NULL; |
| 145 | 145 |
| 146 GPUCreateCommandBufferConfig init_params; | 146 GPUCreateCommandBufferConfig init_params; |
| 147 init_params.share_group_id = | 147 init_params.share_group_id = |
| 148 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; | 148 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; |
| 149 init_params.allowed_extensions = allowed_extensions; | 149 init_params.allowed_extensions = allowed_extensions; |
| 150 init_params.attribs = attribs; | 150 init_params.attribs = attribs; |
| 151 init_params.active_url = active_url; | 151 init_params.active_url = active_url; |
| 152 init_params.gpu_preference = gpu_preference; | 152 init_params.gpu_preference = gpu_preference; |
| 153 int32 route_id = factory_->CreateViewCommandBuffer(surface_id, init_params); | 153 int32 route_id = factory_->CreateViewCommandBuffer(surface_id, init_params); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 165 const gfx::Size& size, | 165 const gfx::Size& size, |
| 166 CommandBufferProxyImpl* share_group, | 166 CommandBufferProxyImpl* share_group, |
| 167 const std::string& allowed_extensions, | 167 const std::string& allowed_extensions, |
| 168 const std::vector<int32>& attribs, | 168 const std::vector<int32>& attribs, |
| 169 const GURL& active_url, | 169 const GURL& active_url, |
| 170 gfx::GpuPreference gpu_preference) { | 170 gfx::GpuPreference gpu_preference) { |
| 171 TRACE_EVENT0("gpu", "GpuChannelHost::CreateOffscreenCommandBuffer"); | 171 TRACE_EVENT0("gpu", "GpuChannelHost::CreateOffscreenCommandBuffer"); |
| 172 | 172 |
| 173 AutoLock lock(context_lock_); | 173 AutoLock lock(context_lock_); |
| 174 // An error occurred. Need to get the host again to reinitialize it. | 174 // An error occurred. Need to get the host again to reinitialize it. |
| 175 if (!channel_.get()) | 175 if (!channel_) |
| 176 return NULL; | 176 return NULL; |
| 177 | 177 |
| 178 GPUCreateCommandBufferConfig init_params; | 178 GPUCreateCommandBufferConfig init_params; |
| 179 init_params.share_group_id = | 179 init_params.share_group_id = |
| 180 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; | 180 share_group ? share_group->GetRouteID() : MSG_ROUTING_NONE; |
| 181 init_params.allowed_extensions = allowed_extensions; | 181 init_params.allowed_extensions = allowed_extensions; |
| 182 init_params.attribs = attribs; | 182 init_params.attribs = attribs; |
| 183 init_params.active_url = active_url; | 183 init_params.active_url = active_url; |
| 184 init_params.gpu_preference = gpu_preference; | 184 init_params.gpu_preference = gpu_preference; |
| 185 int32 route_id; | 185 int32 route_id; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 247 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
| 248 io_loop->PostTask(FROM_HERE, | 248 io_loop->PostTask(FROM_HERE, |
| 249 base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, | 249 base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, |
| 250 channel_filter_.get(), route_id)); | 250 channel_filter_.get(), route_id)); |
| 251 } | 251 } |
| 252 | 252 |
| 253 base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess( | 253 base::SharedMemoryHandle GpuChannelHost::ShareToGpuProcess( |
| 254 base::SharedMemory* shared_memory) { | 254 base::SharedMemory* shared_memory) { |
| 255 AutoLock lock(context_lock_); | 255 AutoLock lock(context_lock_); |
| 256 | 256 |
| 257 if (!channel_.get()) | 257 if (!channel_) |
| 258 return base::SharedMemory::NULLHandle(); | 258 return base::SharedMemory::NULLHandle(); |
| 259 | 259 |
| 260 base::SharedMemoryHandle handle; | 260 base::SharedMemoryHandle handle; |
| 261 #if defined(OS_WIN) | 261 #if defined(OS_WIN) |
| 262 // Windows needs to explicitly duplicate the handle out to another process. | 262 // Windows needs to explicitly duplicate the handle out to another process. |
| 263 if (!BrokerDuplicateHandle(shared_memory->handle(), | 263 if (!BrokerDuplicateHandle(shared_memory->handle(), |
| 264 channel_->peer_pid(), | 264 channel_->peer_pid(), |
| 265 &handle, | 265 &handle, |
| 266 FILE_MAP_WRITE, | 266 FILE_MAP_WRITE, |
| 267 0)) { | 267 0)) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 const GpuListenerInfo& info = it->second; | 394 const GpuListenerInfo& info = it->second; |
| 395 info.loop->PostTask( | 395 info.loop->PostTask( |
| 396 FROM_HERE, | 396 FROM_HERE, |
| 397 base::Bind(&IPC::Listener::OnChannelError, info.listener)); | 397 base::Bind(&IPC::Listener::OnChannelError, info.listener)); |
| 398 } | 398 } |
| 399 | 399 |
| 400 listeners_.clear(); | 400 listeners_.clear(); |
| 401 } | 401 } |
| 402 | 402 |
| 403 } // namespace content | 403 } // namespace content |
| OLD | NEW |