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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 147 |
148 // The most likely reason CreateViewCommandBuffer will fail is | 148 // The most likely reason CreateViewCommandBuffer will fail is |
149 // that the GPU process crashed. In this case the GPU channel | 149 // that the GPU process crashed. In this case the GPU channel |
150 // needs to be considered lost. The caller will then set up a new | 150 // needs to be considered lost. The caller will then set up a new |
151 // connection, and the GPU channel and any view command buffers | 151 // connection, and the GPU channel and any view command buffers |
152 // will all be associated with the same GPU process. | 152 // will all be associated with the same GPU process. |
153 DCHECK(MessageLoopProxy::current().get()); | 153 DCHECK(MessageLoopProxy::current().get()); |
154 | 154 |
155 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); | 155 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); |
156 io_loop->PostTask(FROM_HERE, | 156 io_loop->PostTask(FROM_HERE, |
157 base::Bind(&GpuChannelHost::MessageFilter::OnChannelError, | 157 base::Bind(&GpuChannelHost::MessageFilter::OnSenderError, |
158 channel_filter_.get())); | 158 channel_filter_.get())); |
159 | 159 |
160 return NULL; | 160 return NULL; |
161 } | 161 } |
162 | 162 |
163 CommandBufferProxyImpl* command_buffer = | 163 CommandBufferProxyImpl* command_buffer = |
164 new CommandBufferProxyImpl(this, route_id); | 164 new CommandBufferProxyImpl(this, route_id); |
165 AddRoute(route_id, command_buffer->AsWeakPtr()); | 165 AddRoute(route_id, command_buffer->AsWeakPtr()); |
166 | 166 |
167 AutoLock lock(context_lock_); | 167 AutoLock lock(context_lock_); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 const GpuListenerInfo& info = it->second; | 361 const GpuListenerInfo& info = it->second; |
362 info.loop->PostTask( | 362 info.loop->PostTask( |
363 FROM_HERE, | 363 FROM_HERE, |
364 base::Bind( | 364 base::Bind( |
365 base::IgnoreResult(&IPC::Listener::OnMessageReceived), | 365 base::IgnoreResult(&IPC::Listener::OnMessageReceived), |
366 info.listener, | 366 info.listener, |
367 message)); | 367 message)); |
368 return true; | 368 return true; |
369 } | 369 } |
370 | 370 |
371 void GpuChannelHost::MessageFilter::OnChannelError() { | 371 void GpuChannelHost::MessageFilter::OnSenderError() { |
372 // Set the lost state before signalling the proxies. That way, if they | 372 // Set the lost state before signalling the proxies. That way, if they |
373 // themselves post a task to recreate the context, they will not try to re-use | 373 // themselves post a task to recreate the context, they will not try to re-use |
374 // this channel host. | 374 // this channel host. |
375 { | 375 { |
376 AutoLock lock(lock_); | 376 AutoLock lock(lock_); |
377 lost_ = true; | 377 lost_ = true; |
378 } | 378 } |
379 | 379 |
380 // Inform all the proxies that an error has occurred. This will be reported | 380 // Inform all the proxies that an error has occurred. This will be reported |
381 // via OpenGL as a lost context. | 381 // via OpenGL as a lost context. |
382 for (ListenerMap::iterator it = listeners_.begin(); | 382 for (ListenerMap::iterator it = listeners_.begin(); |
383 it != listeners_.end(); | 383 it != listeners_.end(); |
384 it++) { | 384 it++) { |
385 const GpuListenerInfo& info = it->second; | 385 const GpuListenerInfo& info = it->second; |
386 info.loop->PostTask( | 386 info.loop->PostTask( |
387 FROM_HERE, | 387 FROM_HERE, |
388 base::Bind(&IPC::Listener::OnChannelError, info.listener)); | 388 base::Bind(&IPC::Listener::OnChannelError, info.listener)); |
389 } | 389 } |
390 | 390 |
391 listeners_.clear(); | 391 listeners_.clear(); |
392 } | 392 } |
393 | 393 |
394 bool GpuChannelHost::MessageFilter::IsLost() const { | 394 bool GpuChannelHost::MessageFilter::IsLost() const { |
395 AutoLock lock(lock_); | 395 AutoLock lock(lock_); |
396 return lost_; | 396 return lost_; |
397 } | 397 } |
398 | 398 |
399 } // namespace content | 399 } // namespace content |
OLD | NEW |