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

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

Issue 324143002: Decouple IPC::MessageFilter from IPC::Channel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Landing Created 6 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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/common/gpu/gpu_channel.h" 9 #include "content/common/gpu/gpu_channel.h"
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message 70 // posting a task to insert the GpuCommandBufferMsg_RetireSyncPoint message
71 // into the channel's queue. 71 // into the channel's queue.
72 // - it generates mailbox names for clients of the GPU process on the IO thread. 72 // - it generates mailbox names for clients of the GPU process on the IO thread.
73 class GpuChannelMessageFilter : public IPC::MessageFilter { 73 class GpuChannelMessageFilter : public IPC::MessageFilter {
74 public: 74 public:
75 GpuChannelMessageFilter(base::WeakPtr<GpuChannel> gpu_channel, 75 GpuChannelMessageFilter(base::WeakPtr<GpuChannel> gpu_channel,
76 scoped_refptr<SyncPointManager> sync_point_manager, 76 scoped_refptr<SyncPointManager> sync_point_manager,
77 scoped_refptr<base::MessageLoopProxy> message_loop) 77 scoped_refptr<base::MessageLoopProxy> message_loop)
78 : preemption_state_(IDLE), 78 : preemption_state_(IDLE),
79 gpu_channel_(gpu_channel), 79 gpu_channel_(gpu_channel),
80 channel_(NULL), 80 sender_(NULL),
81 sync_point_manager_(sync_point_manager), 81 sync_point_manager_(sync_point_manager),
82 message_loop_(message_loop), 82 message_loop_(message_loop),
83 messages_forwarded_to_channel_(0), 83 messages_forwarded_to_channel_(0),
84 a_stub_is_descheduled_(false) {} 84 a_stub_is_descheduled_(false) {}
85 85
86 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE { 86 virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE {
87 DCHECK(!channel_); 87 DCHECK(!sender_);
88 channel_ = channel; 88 sender_ = sender;
89 } 89 }
90 90
91 virtual void OnFilterRemoved() OVERRIDE { 91 virtual void OnFilterRemoved() OVERRIDE {
92 DCHECK(channel_); 92 DCHECK(sender_);
93 channel_ = NULL; 93 sender_ = NULL;
94 } 94 }
95 95
96 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { 96 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
97 DCHECK(channel_); 97 DCHECK(sender_);
98 98
99 bool handled = false; 99 bool handled = false;
100 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) { 100 if (message.type() == GpuCommandBufferMsg_RetireSyncPoint::ID) {
101 // This message should not be sent explicitly by the renderer. 101 // This message should not be sent explicitly by the renderer.
102 DLOG(ERROR) << "Client should not send " 102 DLOG(ERROR) << "Client should not send "
103 "GpuCommandBufferMsg_RetireSyncPoint message"; 103 "GpuCommandBufferMsg_RetireSyncPoint message";
104 handled = true; 104 handled = true;
105 } 105 }
106 106
107 // All other messages get processed by the GpuChannel. 107 // All other messages get processed by the GpuChannel.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 preempting_flag_ = preempting_flag; 141 preempting_flag_ = preempting_flag;
142 a_stub_is_descheduled_ = a_stub_is_descheduled; 142 a_stub_is_descheduled_ = a_stub_is_descheduled;
143 } 143 }
144 144
145 void UpdateStubSchedulingState(bool a_stub_is_descheduled) { 145 void UpdateStubSchedulingState(bool a_stub_is_descheduled) {
146 a_stub_is_descheduled_ = a_stub_is_descheduled; 146 a_stub_is_descheduled_ = a_stub_is_descheduled;
147 UpdatePreemptionState(); 147 UpdatePreemptionState();
148 } 148 }
149 149
150 bool Send(IPC::Message* message) { 150 bool Send(IPC::Message* message) {
151 return channel_->Send(message); 151 return sender_->Send(message);
152 } 152 }
153 153
154 protected: 154 protected:
155 virtual ~GpuChannelMessageFilter() {} 155 virtual ~GpuChannelMessageFilter() {}
156 156
157 private: 157 private:
158 enum PreemptionState { 158 enum PreemptionState {
159 // Either there's no other channel to preempt, there are no messages 159 // Either there's no other channel to preempt, there are no messages
160 // pending processing, or we just finished preempting and have to wait 160 // pending processing, or we just finished preempting and have to wait
161 // before preempting again. 161 // before preempting again.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 } else { 352 } else {
353 gpu_channel->MessageProcessed(); 353 gpu_channel->MessageProcessed();
354 } 354 }
355 } 355 }
356 manager->RetireSyncPoint(sync_point); 356 manager->RetireSyncPoint(sync_point);
357 } 357 }
358 358
359 // NOTE: this weak pointer is never dereferenced on the IO thread, it's only 359 // NOTE: this weak pointer is never dereferenced on the IO thread, it's only
360 // passed through - therefore the WeakPtr assumptions are respected. 360 // passed through - therefore the WeakPtr assumptions are respected.
361 base::WeakPtr<GpuChannel> gpu_channel_; 361 base::WeakPtr<GpuChannel> gpu_channel_;
362 IPC::Channel* channel_; 362 IPC::Sender* sender_;
363 scoped_refptr<SyncPointManager> sync_point_manager_; 363 scoped_refptr<SyncPointManager> sync_point_manager_;
364 scoped_refptr<base::MessageLoopProxy> message_loop_; 364 scoped_refptr<base::MessageLoopProxy> message_loop_;
365 scoped_refptr<gpu::PreemptionFlag> preempting_flag_; 365 scoped_refptr<gpu::PreemptionFlag> preempting_flag_;
366 366
367 std::queue<PendingMessage> pending_messages_; 367 std::queue<PendingMessage> pending_messages_;
368 368
369 // Count of the number of IPCs forwarded to the GpuChannel. 369 // Count of the number of IPCs forwarded to the GpuChannel.
370 uint64 messages_forwarded_to_channel_; 370 uint64 messages_forwarded_to_channel_;
371 371
372 base::OneShotTimer<GpuChannelMessageFilter> timer_; 372 base::OneShotTimer<GpuChannelMessageFilter> timer_;
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 uint64 GpuChannel::GetMemoryUsage() { 836 uint64 GpuChannel::GetMemoryUsage() {
837 uint64 size = 0; 837 uint64 size = 0;
838 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_); 838 for (StubMap::Iterator<GpuCommandBufferStub> it(&stubs_);
839 !it.IsAtEnd(); it.Advance()) { 839 !it.IsAtEnd(); it.Advance()) {
840 size += it.GetCurrentValue()->GetMemoryUsage(); 840 size += it.GetCurrentValue()->GetMemoryUsage();
841 } 841 }
842 return size; 842 return size;
843 } 843 }
844 844
845 } // namespace content 845 } // namespace content
OLDNEW
« no previous file with comments | « content/common/font_cache_dispatcher_win.cc ('k') | content/common/gpu/media/gpu_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698