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

Side by Side Diff: content/common/gpu/client/gpu_channel_host.cc

Issue 10662005: Use IPC::Sender and IPC::Listener in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
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/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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 if (channel_.get()) { 94 if (channel_.get()) {
95 // http://crbug.com/125264 95 // http://crbug.com/125264
96 base::ThreadRestrictions::ScopedAllowWait allow_wait; 96 base::ThreadRestrictions::ScopedAllowWait allow_wait;
97 return channel_->Send(message); 97 return channel_->Send(message);
98 } 98 }
99 } else if (MessageLoop::current()) { 99 } else if (MessageLoop::current()) {
100 return sync_filter_->Send(message); 100 return sync_filter_->Send(message);
101 } 101 }
102 102
103 // Callee takes ownership of message, regardless of whether Send is 103 // Callee takes ownership of message, regardless of whether Send is
104 // successful. See IPC::Message::Sender. 104 // successful. See IPC::Sender.
105 delete message; 105 delete message;
106 return false; 106 return false;
107 } 107 }
108 108
109 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( 109 CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer(
110 int32 surface_id, 110 int32 surface_id,
111 CommandBufferProxy* share_group, 111 CommandBufferProxy* share_group,
112 const std::string& allowed_extensions, 112 const std::string& allowed_extensions,
113 const std::vector<int32>& attribs, 113 const std::vector<int32>& attribs,
114 const GURL& active_url, 114 const GURL& active_url,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id)); 208 Send(new GpuChannelMsg_DestroyCommandBuffer(route_id));
209 // Check the proxy has not already been removed after a channel error. 209 // Check the proxy has not already been removed after a channel error.
210 if (proxies_.find(route_id) != proxies_.end()) 210 if (proxies_.find(route_id) != proxies_.end())
211 proxies_.erase(route_id); 211 proxies_.erase(route_id);
212 RemoveRoute(route_id); 212 RemoveRoute(route_id);
213 delete command_buffer; 213 delete command_buffer;
214 #endif 214 #endif
215 } 215 }
216 216
217 void GpuChannelHost::AddRoute( 217 void GpuChannelHost::AddRoute(
218 int route_id, base::WeakPtr<IPC::Channel::Listener> listener) { 218 int route_id, base::WeakPtr<IPC::Listener> listener) {
219 DCHECK(MessageLoopProxy::current()); 219 DCHECK(MessageLoopProxy::current());
220 220
221 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); 221 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy();
222 io_loop->PostTask(FROM_HERE, 222 io_loop->PostTask(FROM_HERE,
223 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, 223 base::Bind(&GpuChannelHost::MessageFilter::AddRoute,
224 channel_filter_.get(), route_id, listener, 224 channel_filter_.get(), route_id, listener,
225 MessageLoopProxy::current())); 225 MessageLoopProxy::current()));
226 } 226 }
227 227
228 void GpuChannelHost::RemoveRoute(int route_id) { 228 void GpuChannelHost::RemoveRoute(int route_id) {
229 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); 229 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy();
230 io_loop->PostTask(FROM_HERE, 230 io_loop->PostTask(FROM_HERE,
231 base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute, 231 base::Bind(&GpuChannelHost::MessageFilter::RemoveRoute,
232 channel_filter_.get(), route_id)); 232 channel_filter_.get(), route_id));
233 } 233 }
234 234
235 GpuChannelHost::~GpuChannelHost() {} 235 GpuChannelHost::~GpuChannelHost() {}
236 236
237 237
238 GpuChannelHost::MessageFilter::MessageFilter(GpuChannelHost* parent) 238 GpuChannelHost::MessageFilter::MessageFilter(GpuChannelHost* parent)
239 : parent_(parent) { 239 : parent_(parent) {
240 } 240 }
241 241
242 GpuChannelHost::MessageFilter::~MessageFilter() {} 242 GpuChannelHost::MessageFilter::~MessageFilter() {}
243 243
244 void GpuChannelHost::MessageFilter::AddRoute( 244 void GpuChannelHost::MessageFilter::AddRoute(
245 int route_id, 245 int route_id,
246 base::WeakPtr<IPC::Channel::Listener> listener, 246 base::WeakPtr<IPC::Listener> listener,
247 scoped_refptr<MessageLoopProxy> loop) { 247 scoped_refptr<MessageLoopProxy> loop) {
248 DCHECK(parent_->factory_->IsIOThread()); 248 DCHECK(parent_->factory_->IsIOThread());
249 DCHECK(listeners_.find(route_id) == listeners_.end()); 249 DCHECK(listeners_.find(route_id) == listeners_.end());
250 GpuListenerInfo info; 250 GpuListenerInfo info;
251 info.listener = listener; 251 info.listener = listener;
252 info.loop = loop; 252 info.loop = loop;
253 listeners_[route_id] = info; 253 listeners_[route_id] = info;
254 } 254 }
255 255
256 void GpuChannelHost::MessageFilter::RemoveRoute(int route_id) { 256 void GpuChannelHost::MessageFilter::RemoveRoute(int route_id) {
(...skipping 12 matching lines...) Expand all
269 269
270 DCHECK(message.routing_id() != MSG_ROUTING_CONTROL); 270 DCHECK(message.routing_id() != MSG_ROUTING_CONTROL);
271 271
272 ListenerMap::iterator it = listeners_.find(message.routing_id()); 272 ListenerMap::iterator it = listeners_.find(message.routing_id());
273 273
274 if (it != listeners_.end()) { 274 if (it != listeners_.end()) {
275 const GpuListenerInfo& info = it->second; 275 const GpuListenerInfo& info = it->second;
276 info.loop->PostTask( 276 info.loop->PostTask(
277 FROM_HERE, 277 FROM_HERE,
278 base::Bind( 278 base::Bind(
279 base::IgnoreResult(&IPC::Channel::Listener::OnMessageReceived), 279 base::IgnoreResult(&IPC::Listener::OnMessageReceived),
280 info.listener, 280 info.listener,
281 message)); 281 message));
282 } 282 }
283 283
284 return true; 284 return true;
285 } 285 }
286 286
287 void GpuChannelHost::MessageFilter::OnChannelError() { 287 void GpuChannelHost::MessageFilter::OnChannelError() {
288 DCHECK(parent_->factory_->IsIOThread()); 288 DCHECK(parent_->factory_->IsIOThread());
289 // Inform all the proxies that an error has occurred. This will be reported 289 // Inform all the proxies that an error has occurred. This will be reported
290 // via OpenGL as a lost context. 290 // via OpenGL as a lost context.
291 for (ListenerMap::iterator it = listeners_.begin(); 291 for (ListenerMap::iterator it = listeners_.begin();
292 it != listeners_.end(); 292 it != listeners_.end();
293 it++) { 293 it++) {
294 const GpuListenerInfo& info = it->second; 294 const GpuListenerInfo& info = it->second;
295 info.loop->PostTask( 295 info.loop->PostTask(
296 FROM_HERE, 296 FROM_HERE,
297 base::Bind(&IPC::Channel::Listener::OnChannelError, info.listener)); 297 base::Bind(&IPC::Listener::OnChannelError, info.listener));
298 } 298 }
299 299
300 listeners_.clear(); 300 listeners_.clear();
301 301
302 MessageLoop* main_loop = parent_->factory_->GetMainLoop(); 302 MessageLoop* main_loop = parent_->factory_->GetMainLoop();
303 main_loop->PostTask(FROM_HERE, 303 main_loop->PostTask(FROM_HERE,
304 base::Bind(&GpuChannelHost::OnChannelError, parent_)); 304 base::Bind(&GpuChannelHost::OnChannelError, parent_));
305 } 305 }
306 306
307 307
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_channel_host.h ('k') | content/common/gpu/client/gpu_video_decode_accelerator_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698