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

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

Issue 1117183006: Remove BrowserGpuChannelHostFactory usage of UnsafeGetMessageLoopForThread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « content/common/gpu/client/gpu_channel_host.h ('k') | content/renderer/render_thread_impl.h » ('j') | 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/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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 29 matching lines...) Expand all
40 ProxyFlushInfo::~ProxyFlushInfo() { 40 ProxyFlushInfo::~ProxyFlushInfo() {
41 } 41 }
42 42
43 // static 43 // static
44 scoped_refptr<GpuChannelHost> GpuChannelHost::Create( 44 scoped_refptr<GpuChannelHost> GpuChannelHost::Create(
45 GpuChannelHostFactory* factory, 45 GpuChannelHostFactory* factory,
46 const gpu::GPUInfo& gpu_info, 46 const gpu::GPUInfo& gpu_info,
47 const IPC::ChannelHandle& channel_handle, 47 const IPC::ChannelHandle& channel_handle,
48 base::WaitableEvent* shutdown_event, 48 base::WaitableEvent* shutdown_event,
49 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) { 49 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) {
50 DCHECK(factory->IsMainThread()); 50 DCHECK(factory->GetMainTaskRunner()->BelongsToCurrentThread());
51 scoped_refptr<GpuChannelHost> host = 51 scoped_refptr<GpuChannelHost> host =
52 new GpuChannelHost(factory, gpu_info, gpu_memory_buffer_manager); 52 new GpuChannelHost(factory, gpu_info, gpu_memory_buffer_manager);
53 host->Connect(channel_handle, shutdown_event); 53 host->Connect(channel_handle, shutdown_event);
54 return host; 54 return host;
55 } 55 }
56 56
57 GpuChannelHost::GpuChannelHost( 57 GpuChannelHost::GpuChannelHost(
58 GpuChannelHostFactory* factory, 58 GpuChannelHostFactory* factory,
59 const gpu::GPUInfo& gpu_info, 59 const gpu::GPUInfo& gpu_info,
60 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager) 60 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 message->set_unblock(false); 98 message->set_unblock(false);
99 99
100 // Currently we need to choose between two different mechanisms for sending. 100 // Currently we need to choose between two different mechanisms for sending.
101 // On the main thread we use the regular channel Send() method, on another 101 // On the main thread we use the regular channel Send() method, on another
102 // thread we use SyncMessageFilter. We also have to be careful interpreting 102 // thread we use SyncMessageFilter. We also have to be careful interpreting
103 // IsMainThread() since it might return false during shutdown, 103 // IsMainThread() since it might return false during shutdown,
104 // impl we are actually calling from the main thread (discard message then). 104 // impl we are actually calling from the main thread (discard message then).
105 // 105 //
106 // TODO: Can we just always use sync_filter_ since we setup the channel 106 // TODO: Can we just always use sync_filter_ since we setup the channel
107 // without a main listener? 107 // without a main listener?
108 if (factory_->IsMainThread()) { 108 if (factory_->GetMainTaskRunner()->BelongsToCurrentThread()) {
109 // http://crbug.com/125264 109 // http://crbug.com/125264
110 base::ThreadRestrictions::ScopedAllowWait allow_wait; 110 base::ThreadRestrictions::ScopedAllowWait allow_wait;
111 bool result = channel_->Send(message.release()); 111 bool result = channel_->Send(message.release());
112 if (!result) 112 if (!result)
113 DVLOG(1) << "GpuChannelHost::Send failed: Channel::Send failed"; 113 DVLOG(1) << "GpuChannelHost::Send failed: Channel::Send failed";
114 return result; 114 return result;
115 } 115 }
116 116
117 bool result = sync_filter_->Send(message.release()); 117 bool result = sync_filter_->Send(message.release());
118 return result; 118 return result;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 AutoLock lock(context_lock_); 267 AutoLock lock(context_lock_);
268 proxies_.erase(route_id); 268 proxies_.erase(route_id);
269 if (flush_info_.flush_pending && flush_info_.route_id == route_id) 269 if (flush_info_.flush_pending && flush_info_.route_id == route_id)
270 flush_info_.flush_pending = false; 270 flush_info_.flush_pending = false;
271 271
272 delete command_buffer; 272 delete command_buffer;
273 } 273 }
274 274
275 void GpuChannelHost::DestroyChannel() { 275 void GpuChannelHost::DestroyChannel() {
276 // channel_ must be destroyed on the main thread. 276 // channel_ must be destroyed on the main thread.
277 if (channel_.get() && !factory_->IsMainThread()) 277 if (channel_.get()) {
278 factory_->GetMainLoop()->DeleteSoon(FROM_HERE, channel_.release()); 278 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner =
279 factory_->GetMainTaskRunner();
280 if (!main_task_runner->RunsTasksOnCurrentThread())
281 main_task_runner->DeleteSoon(FROM_HERE, channel_.release());
282 }
279 channel_.reset(); 283 channel_.reset();
280 } 284 }
281 285
282 void GpuChannelHost::AddRoute( 286 void GpuChannelHost::AddRoute(
283 int route_id, base::WeakPtr<IPC::Listener> listener) { 287 int route_id, base::WeakPtr<IPC::Listener> listener) {
284 DCHECK(MessageLoopProxy::current().get()); 288 DCHECK(MessageLoopProxy::current().get());
285 289
286 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy(); 290 scoped_refptr<base::MessageLoopProxy> io_loop = factory_->GetIOLoopProxy();
287 io_loop->PostTask(FROM_HERE, 291 io_loop->PostTask(FROM_HERE,
288 base::Bind(&GpuChannelHost::MessageFilter::AddRoute, 292 base::Bind(&GpuChannelHost::MessageFilter::AddRoute,
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 430
427 listeners_.clear(); 431 listeners_.clear();
428 } 432 }
429 433
430 bool GpuChannelHost::MessageFilter::IsLost() const { 434 bool GpuChannelHost::MessageFilter::IsLost() const {
431 AutoLock lock(lock_); 435 AutoLock lock(lock_);
432 return lost_; 436 return lost_;
433 } 437 }
434 438
435 } // namespace content 439 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/client/gpu_channel_host.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698