Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(646)

Side by Side Diff: content/common/gpu/gpu_channel_manager.cc

Issue 299003004: Fix leak in GpuChannel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gpu_channel_manager.h" 5 #include "content/common/gpu/gpu_channel_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 #include "content/common/gpu/gpu_memory_manager.h" 10 #include "content/common/gpu/gpu_memory_manager.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 void GpuChannelManager::RemoveRoute(int32 routing_id) { 92 void GpuChannelManager::RemoveRoute(int32 routing_id) {
93 router_->RemoveRoute(routing_id); 93 router_->RemoveRoute(routing_id);
94 } 94 }
95 95
96 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) { 96 GpuChannel* GpuChannelManager::LookupChannel(int32 client_id) {
97 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id); 97 GpuChannelMap::const_iterator iter = gpu_channels_.find(client_id);
98 if (iter == gpu_channels_.end()) 98 if (iter == gpu_channels_.end())
99 return NULL; 99 return NULL;
100 else 100 else
101 return iter->second.get(); 101 return iter->second;
102 } 102 }
103 103
104 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { 104 bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) {
105 bool handled = true; 105 bool handled = true;
106 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg) 106 IPC_BEGIN_MESSAGE_MAP(GpuChannelManager, msg)
107 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) 107 IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
108 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) 108 IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
109 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, 109 IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
110 OnCreateViewCommandBuffer) 110 OnCreateViewCommandBuffer)
111 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage) 111 IPC_MESSAGE_HANDLER(GpuMsg_CreateImage, OnCreateImage)
(...skipping 14 matching lines...) Expand all
126 if (share_context) { 126 if (share_context) {
127 if (!share_group_.get()) { 127 if (!share_group_.get()) {
128 share_group_ = new gfx::GLShareGroup; 128 share_group_ = new gfx::GLShareGroup;
129 DCHECK(!mailbox_manager_.get()); 129 DCHECK(!mailbox_manager_.get());
130 mailbox_manager_ = new gpu::gles2::MailboxManager; 130 mailbox_manager_ = new gpu::gles2::MailboxManager;
131 } 131 }
132 share_group = share_group_.get(); 132 share_group = share_group_.get();
133 mailbox_manager = mailbox_manager_.get(); 133 mailbox_manager = mailbox_manager_.get();
134 } 134 }
135 135
136 scoped_refptr<GpuChannel> channel = new GpuChannel(this, 136 scoped_ptr<GpuChannel> channel(new GpuChannel(
137 watchdog_, 137 this, watchdog_, share_group, mailbox_manager, client_id, false));
138 share_group,
139 mailbox_manager,
140 client_id,
141 false);
142 channel->Init(io_message_loop_.get(), shutdown_event_); 138 channel->Init(io_message_loop_.get(), shutdown_event_);
143 gpu_channels_[client_id] = channel;
144 channel_handle.name = channel->GetChannelName(); 139 channel_handle.name = channel->GetChannelName();
145 140
146 #if defined(OS_POSIX) 141 #if defined(OS_POSIX)
147 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so 142 // On POSIX, pass the renderer-side FD. Also mark it as auto-close so
148 // that it gets closed after it has been sent. 143 // that it gets closed after it has been sent.
149 int renderer_fd = channel->TakeRendererFileDescriptor(); 144 int renderer_fd = channel->TakeRendererFileDescriptor();
150 DCHECK_NE(-1, renderer_fd); 145 DCHECK_NE(-1, renderer_fd);
151 channel_handle.socket = base::FileDescriptor(renderer_fd, true); 146 channel_handle.socket = base::FileDescriptor(renderer_fd, true);
152 #endif 147 #endif
153 148
149 gpu_channels_.set(client_id, channel.Pass());
150
154 Send(new GpuHostMsg_ChannelEstablished(channel_handle)); 151 Send(new GpuHostMsg_ChannelEstablished(channel_handle));
155 } 152 }
156 153
157 void GpuChannelManager::OnCloseChannel( 154 void GpuChannelManager::OnCloseChannel(
158 const IPC::ChannelHandle& channel_handle) { 155 const IPC::ChannelHandle& channel_handle) {
159 for (GpuChannelMap::iterator iter = gpu_channels_.begin(); 156 for (GpuChannelMap::iterator iter = gpu_channels_.begin();
160 iter != gpu_channels_.end(); ++iter) { 157 iter != gpu_channels_.end(); ++iter) {
161 if (iter->second->GetChannelName() == channel_handle.name) { 158 if (iter->second->GetChannelName() == channel_handle.name) {
162 gpu_channels_.erase(iter); 159 gpu_channels_.erase(iter);
163 return; 160 return;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 296
300 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() { 297 gfx::GLSurface* GpuChannelManager::GetDefaultOffscreenSurface() {
301 if (!default_offscreen_surface_.get()) { 298 if (!default_offscreen_surface_.get()) {
302 default_offscreen_surface_ = 299 default_offscreen_surface_ =
303 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); 300 gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1));
304 } 301 }
305 return default_offscreen_surface_.get(); 302 return default_offscreen_surface_.get();
306 } 303 }
307 304
308 } // namespace content 305 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698