| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gpu_channel_manager.h" | 5 #include "content/common/gpu/gpu_channel_manager.h" |
| 6 | 6 |
| 7 #include "content/common/child_thread.h" | 7 #include "content/common/child_thread.h" |
| 8 #include "content/common/gpu/gpu_channel.h" | 8 #include "content/common/gpu/gpu_channel.h" |
| 9 #include "content/common/gpu/gpu_messages.h" | 9 #include "content/common/gpu/gpu_messages.h" |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 if (channel->Init(io_message_loop_, shutdown_event_)) | 95 if (channel->Init(io_message_loop_, shutdown_event_)) |
| 96 gpu_channels_[renderer_id] = channel; | 96 gpu_channels_[renderer_id] = channel; |
| 97 else | 97 else |
| 98 channel = NULL; | 98 channel = NULL; |
| 99 | 99 |
| 100 if (channel.get()) { | 100 if (channel.get()) { |
| 101 channel_handle.name = channel->GetChannelName(); | 101 channel_handle.name = channel->GetChannelName(); |
| 102 #if defined(OS_POSIX) | 102 #if defined(OS_POSIX) |
| 103 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so | 103 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so |
| 104 // that it gets closed after it has been sent. | 104 // that it gets closed after it has been sent. |
| 105 int renderer_fd = channel->GetRendererFileDescriptor(); | 105 int renderer_fd = channel->TakeRendererFileDescriptor(); |
| 106 DCHECK_NE(-1, renderer_fd); | 106 DCHECK_NE(-1, renderer_fd); |
| 107 channel_handle.socket = base::FileDescriptor(dup(renderer_fd), true); | 107 channel_handle.socket = base::FileDescriptor(renderer_fd, true); |
| 108 #endif | 108 #endif |
| 109 } | 109 } |
| 110 | 110 |
| 111 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); | 111 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void GpuChannelManager::OnCloseChannel( | 114 void GpuChannelManager::OnCloseChannel( |
| 115 const IPC::ChannelHandle& channel_handle) { | 115 const IPC::ChannelHandle& channel_handle) { |
| 116 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); | 116 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); |
| 117 iter != gpu_channels_.end(); ++iter) { | 117 iter != gpu_channels_.end(); ++iter) { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 void GpuChannelManager::LoseAllContexts() { | 176 void GpuChannelManager::LoseAllContexts() { |
| 177 MessageLoop::current()->PostTask( | 177 MessageLoop::current()->PostTask( |
| 178 FROM_HERE, method_factory_.NewRunnableMethod( | 178 FROM_HERE, method_factory_.NewRunnableMethod( |
| 179 &GpuChannelManager::OnLoseAllContexts)); | 179 &GpuChannelManager::OnLoseAllContexts)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void GpuChannelManager::OnLoseAllContexts() { | 182 void GpuChannelManager::OnLoseAllContexts() { |
| 183 gpu_channels_.clear(); | 183 gpu_channels_.clear(); |
| 184 } | 184 } |
| OLD | NEW |