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

Side by Side Diff: content/common/gpu/media/gpu_video_decode_accelerator.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
« no previous file with comments | « content/common/gpu/gpu_channel.cc ('k') | content/plugin/plugin_channel.cc » ('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/media/gpu_video_decode_accelerator.h" 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 public: 69 public:
70 explicit DebugAutoLock(base::Lock&) {} 70 explicit DebugAutoLock(base::Lock&) {}
71 }; 71 };
72 #endif 72 #endif
73 73
74 class GpuVideoDecodeAccelerator::MessageFilter : public IPC::MessageFilter { 74 class GpuVideoDecodeAccelerator::MessageFilter : public IPC::MessageFilter {
75 public: 75 public:
76 MessageFilter(GpuVideoDecodeAccelerator* owner, int32 host_route_id) 76 MessageFilter(GpuVideoDecodeAccelerator* owner, int32 host_route_id)
77 : owner_(owner), host_route_id_(host_route_id) {} 77 : owner_(owner), host_route_id_(host_route_id) {}
78 78
79 virtual void OnChannelError() OVERRIDE { channel_ = NULL; } 79 virtual void OnChannelError() OVERRIDE { sender_ = NULL; }
80 80
81 virtual void OnChannelClosing() OVERRIDE { channel_ = NULL; } 81 virtual void OnChannelClosing() OVERRIDE { sender_ = NULL; }
82 82
83 virtual void OnFilterAdded(IPC::Channel* channel) OVERRIDE { 83 virtual void OnFilterAdded(IPC::Sender* sender) OVERRIDE {
84 channel_ = channel; 84 sender_ = sender;
85 } 85 }
86 86
87 virtual void OnFilterRemoved() OVERRIDE { 87 virtual void OnFilterRemoved() OVERRIDE {
88 // This will delete |owner_| and |this|. 88 // This will delete |owner_| and |this|.
89 owner_->OnFilterRemoved(); 89 owner_->OnFilterRemoved();
90 } 90 }
91 91
92 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE { 92 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE {
93 if (msg.routing_id() != host_route_id_) 93 if (msg.routing_id() != host_route_id_)
94 return false; 94 return false;
95 95
96 IPC_BEGIN_MESSAGE_MAP(MessageFilter, msg) 96 IPC_BEGIN_MESSAGE_MAP(MessageFilter, msg)
97 IPC_MESSAGE_FORWARD(AcceleratedVideoDecoderMsg_Decode, owner_, 97 IPC_MESSAGE_FORWARD(AcceleratedVideoDecoderMsg_Decode, owner_,
98 GpuVideoDecodeAccelerator::OnDecode) 98 GpuVideoDecodeAccelerator::OnDecode)
99 IPC_MESSAGE_UNHANDLED(return false;) 99 IPC_MESSAGE_UNHANDLED(return false;)
100 IPC_END_MESSAGE_MAP() 100 IPC_END_MESSAGE_MAP()
101 return true; 101 return true;
102 } 102 }
103 103
104 bool SendOnIOThread(IPC::Message* message) { 104 bool SendOnIOThread(IPC::Message* message) {
105 DCHECK(!message->is_sync()); 105 DCHECK(!message->is_sync());
106 if (!channel_) { 106 if (!sender_) {
107 delete message; 107 delete message;
108 return false; 108 return false;
109 } 109 }
110 return channel_->Send(message); 110 return sender_->Send(message);
111 } 111 }
112 112
113 protected: 113 protected:
114 virtual ~MessageFilter() {} 114 virtual ~MessageFilter() {}
115 115
116 private: 116 private:
117 GpuVideoDecodeAccelerator* owner_; 117 GpuVideoDecodeAccelerator* owner_;
118 int32 host_route_id_; 118 int32 host_route_id_;
119 // The channel to which this filter was added. 119 // The sender to which this filter was added.
120 IPC::Channel* channel_; 120 IPC::Sender* sender_;
121 }; 121 };
122 122
123 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( 123 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
124 int32 host_route_id, 124 int32 host_route_id,
125 GpuCommandBufferStub* stub, 125 GpuCommandBufferStub* stub,
126 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) 126 const scoped_refptr<base::MessageLoopProxy>& io_message_loop)
127 : host_route_id_(host_route_id), 127 : host_route_id_(host_route_id),
128 stub_(stub), 128 stub_(stub),
129 texture_target_(0), 129 texture_target_(0),
130 filter_removed_(true, false), 130 filter_removed_(true, false),
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 return stub_->channel()->Send(message); 505 return stub_->channel()->Send(message);
506 } 506 }
507 507
508 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, 508 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message,
509 bool succeeded) { 509 bool succeeded) {
510 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); 510 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded);
511 Send(message); 511 Send(message);
512 } 512 }
513 513
514 } // namespace content 514 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_channel.cc ('k') | content/plugin/plugin_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698