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

Side by Side Diff: chrome/renderer/media/cast_ipc_dispatcher.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/renderer/media/cast_ipc_dispatcher.h" 5 #include "chrome/renderer/media/cast_ipc_dispatcher.h"
6 6
7 #include "chrome/common/cast_messages.h" 7 #include "chrome/common/cast_messages.h"
8 #include "chrome/renderer/media/cast_transport_sender_ipc.h" 8 #include "chrome/renderer/media/cast_transport_sender_ipc.h"
9 #include "ipc/ipc_message_macros.h" 9 #include "ipc/ipc_message_macros.h"
10 10
11 CastIPCDispatcher* CastIPCDispatcher::global_instance_ = NULL; 11 CastIPCDispatcher* CastIPCDispatcher::global_instance_ = NULL;
12 12
13 CastIPCDispatcher::CastIPCDispatcher( 13 CastIPCDispatcher::CastIPCDispatcher(
14 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) 14 const scoped_refptr<base::MessageLoopProxy>& io_message_loop)
15 : channel_(NULL), 15 : sender_(NULL),
16 io_message_loop_(io_message_loop) { 16 io_message_loop_(io_message_loop) {
17 DCHECK(io_message_loop_); 17 DCHECK(io_message_loop_);
18 DCHECK(!global_instance_); 18 DCHECK(!global_instance_);
19 } 19 }
20 20
21 CastIPCDispatcher::~CastIPCDispatcher() { 21 CastIPCDispatcher::~CastIPCDispatcher() {
22 DCHECK(io_message_loop_->BelongsToCurrentThread()); 22 DCHECK(io_message_loop_->BelongsToCurrentThread());
23 DCHECK(!global_instance_); 23 DCHECK(!global_instance_);
24 } 24 }
25 25
26 CastIPCDispatcher* CastIPCDispatcher::Get() { 26 CastIPCDispatcher* CastIPCDispatcher::Get() {
27 return global_instance_; 27 return global_instance_;
28 } 28 }
29 29
30 void CastIPCDispatcher::Send(IPC::Message* message) { 30 void CastIPCDispatcher::Send(IPC::Message* message) {
31 DCHECK(io_message_loop_->BelongsToCurrentThread()); 31 DCHECK(io_message_loop_->BelongsToCurrentThread());
32 if (channel_) { 32 if (sender_) {
33 channel_->Send(message); 33 sender_->Send(message);
34 } else { 34 } else {
35 delete message; 35 delete message;
36 } 36 }
37 } 37 }
38 38
39 int32 CastIPCDispatcher::AddSender(CastTransportSenderIPC* sender) { 39 int32 CastIPCDispatcher::AddSender(CastTransportSenderIPC* sender) {
40 return id_map_.Add(sender); 40 return id_map_.Add(sender);
41 } 41 }
42 42
43 void CastIPCDispatcher::RemoveSender(int32 channel_id) { 43 void CastIPCDispatcher::RemoveSender(int32 channel_id) {
44 return id_map_.Remove(channel_id); 44 return id_map_.Remove(channel_id);
45 } 45 }
46 46
47 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { 47 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) {
48 DCHECK(io_message_loop_->BelongsToCurrentThread()); 48 DCHECK(io_message_loop_->BelongsToCurrentThread());
49 bool handled = true; 49 bool handled = true;
50 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) 50 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message)
51 IPC_MESSAGE_HANDLER(CastMsg_ReceivedPacket, OnReceivedPacket) 51 IPC_MESSAGE_HANDLER(CastMsg_ReceivedPacket, OnReceivedPacket)
52 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange) 52 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange)
53 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents) 53 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents)
54 IPC_MESSAGE_UNHANDLED(handled = false); 54 IPC_MESSAGE_UNHANDLED(handled = false);
55 IPC_END_MESSAGE_MAP(); 55 IPC_END_MESSAGE_MAP();
56 return handled; 56 return handled;
57 } 57 }
58 58
59 void CastIPCDispatcher::OnFilterAdded(IPC::Channel* channel) { 59 void CastIPCDispatcher::OnFilterAdded(IPC::Sender* sender) {
60 DCHECK(io_message_loop_->BelongsToCurrentThread()); 60 DCHECK(io_message_loop_->BelongsToCurrentThread());
61 DCHECK(!global_instance_); 61 DCHECK(!global_instance_);
62 global_instance_ = this; 62 global_instance_ = this;
63 channel_ = channel; 63 sender_ = sender;
64 } 64 }
65 65
66 void CastIPCDispatcher::OnFilterRemoved() { 66 void CastIPCDispatcher::OnFilterRemoved() {
67 DCHECK(io_message_loop_->BelongsToCurrentThread()); 67 DCHECK(io_message_loop_->BelongsToCurrentThread());
68 DCHECK_EQ(this, global_instance_); 68 DCHECK_EQ(this, global_instance_);
69 global_instance_ = NULL; 69 global_instance_ = NULL;
70 channel_ = NULL; 70 sender_ = NULL;
71 } 71 }
72 72
73 void CastIPCDispatcher::OnChannelClosing() { 73 void CastIPCDispatcher::OnChannelClosing() {
74 DCHECK(io_message_loop_->BelongsToCurrentThread()); 74 DCHECK(io_message_loop_->BelongsToCurrentThread());
75 DCHECK_EQ(this, global_instance_); 75 DCHECK_EQ(this, global_instance_);
76 } 76 }
77 77
78 void CastIPCDispatcher::OnReceivedPacket( 78 void CastIPCDispatcher::OnReceivedPacket(
79 int32 channel_id, 79 int32 channel_id,
80 const media::cast::transport::Packet& packet) { 80 const media::cast::transport::Packet& packet) {
(...skipping 21 matching lines...) Expand all
102 void CastIPCDispatcher::OnRawEvents( 102 void CastIPCDispatcher::OnRawEvents(
103 int32 channel_id, 103 int32 channel_id,
104 const std::vector<media::cast::PacketEvent>& packet_events) { 104 const std::vector<media::cast::PacketEvent>& packet_events) {
105 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); 105 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id);
106 if (sender) { 106 if (sender) {
107 sender->OnRawEvents(packet_events); 107 sender->OnRawEvents(packet_events);
108 } else { 108 } else {
109 DVLOG(1) << "CastIPCDispatcher::OnRawEvents on non-existing channel."; 109 DVLOG(1) << "CastIPCDispatcher::OnRawEvents on non-existing channel.";
110 } 110 }
111 } 111 }
OLDNEW
« no previous file with comments | « chrome/renderer/media/cast_ipc_dispatcher.h ('k') | chrome/renderer/media/webrtc_logging_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698