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

Side by Side Diff: chrome/renderer/media/cast_ipc_dispatcher.cc

Issue 1123733002: [chrome/renderer/media] Replace MessageLoopProxy usage with ThreadTaskRunnerHandle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed nit 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
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 "base/single_thread_task_runner.h"
7 #include "chrome/common/cast_messages.h" 8 #include "chrome/common/cast_messages.h"
8 #include "chrome/renderer/media/cast_transport_sender_ipc.h" 9 #include "chrome/renderer/media/cast_transport_sender_ipc.h"
9 #include "ipc/ipc_message_macros.h" 10 #include "ipc/ipc_message_macros.h"
10 11
11 CastIPCDispatcher* CastIPCDispatcher::global_instance_ = NULL; 12 CastIPCDispatcher* CastIPCDispatcher::global_instance_ = NULL;
12 13
13 CastIPCDispatcher::CastIPCDispatcher( 14 CastIPCDispatcher::CastIPCDispatcher(
14 const scoped_refptr<base::MessageLoopProxy>& io_message_loop) 15 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner)
15 : sender_(NULL), 16 : sender_(NULL),
16 io_message_loop_(io_message_loop) { 17 io_task_runner_(io_task_runner) {
17 DCHECK(io_message_loop_.get()); 18 DCHECK(io_task_runner_.get());
18 DCHECK(!global_instance_); 19 DCHECK(!global_instance_);
19 } 20 }
20 21
21 CastIPCDispatcher::~CastIPCDispatcher() { 22 CastIPCDispatcher::~CastIPCDispatcher() {
22 DCHECK(io_message_loop_->BelongsToCurrentThread()); 23 DCHECK(io_task_runner_->BelongsToCurrentThread());
23 DCHECK(!global_instance_); 24 DCHECK(!global_instance_);
24 } 25 }
25 26
26 CastIPCDispatcher* CastIPCDispatcher::Get() { 27 CastIPCDispatcher* CastIPCDispatcher::Get() {
27 return global_instance_; 28 return global_instance_;
28 } 29 }
29 30
30 void CastIPCDispatcher::Send(IPC::Message* message) { 31 void CastIPCDispatcher::Send(IPC::Message* message) {
31 DCHECK(io_message_loop_->BelongsToCurrentThread()); 32 DCHECK(io_task_runner_->BelongsToCurrentThread());
32 if (sender_) { 33 if (sender_) {
33 sender_->Send(message); 34 sender_->Send(message);
34 } else { 35 } else {
35 delete message; 36 delete message;
36 } 37 }
37 } 38 }
38 39
39 int32 CastIPCDispatcher::AddSender(CastTransportSenderIPC* sender) { 40 int32 CastIPCDispatcher::AddSender(CastTransportSenderIPC* sender) {
40 return id_map_.Add(sender); 41 return id_map_.Add(sender);
41 } 42 }
42 43
43 void CastIPCDispatcher::RemoveSender(int32 channel_id) { 44 void CastIPCDispatcher::RemoveSender(int32 channel_id) {
44 return id_map_.Remove(channel_id); 45 return id_map_.Remove(channel_id);
45 } 46 }
46 47
47 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) { 48 bool CastIPCDispatcher::OnMessageReceived(const IPC::Message& message) {
48 DCHECK(io_message_loop_->BelongsToCurrentThread()); 49 DCHECK(io_task_runner_->BelongsToCurrentThread());
49 bool handled = true; 50 bool handled = true;
50 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message) 51 IPC_BEGIN_MESSAGE_MAP(CastIPCDispatcher, message)
51 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange) 52 IPC_MESSAGE_HANDLER(CastMsg_NotifyStatusChange, OnNotifyStatusChange)
52 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents) 53 IPC_MESSAGE_HANDLER(CastMsg_RawEvents, OnRawEvents)
53 IPC_MESSAGE_HANDLER(CastMsg_Rtt, OnRtt) 54 IPC_MESSAGE_HANDLER(CastMsg_Rtt, OnRtt)
54 IPC_MESSAGE_HANDLER(CastMsg_RtcpCastMessage, OnRtcpCastMessage) 55 IPC_MESSAGE_HANDLER(CastMsg_RtcpCastMessage, OnRtcpCastMessage)
55 IPC_MESSAGE_HANDLER(CastMsg_ReceivedPacket, OnReceivedPacket) 56 IPC_MESSAGE_HANDLER(CastMsg_ReceivedPacket, OnReceivedPacket)
56 IPC_MESSAGE_UNHANDLED(handled = false); 57 IPC_MESSAGE_UNHANDLED(handled = false);
57 IPC_END_MESSAGE_MAP(); 58 IPC_END_MESSAGE_MAP();
58 return handled; 59 return handled;
59 } 60 }
60 61
61 void CastIPCDispatcher::OnFilterAdded(IPC::Sender* sender) { 62 void CastIPCDispatcher::OnFilterAdded(IPC::Sender* sender) {
62 DCHECK(io_message_loop_->BelongsToCurrentThread()); 63 DCHECK(io_task_runner_->BelongsToCurrentThread());
63 DCHECK(!global_instance_); 64 DCHECK(!global_instance_);
64 global_instance_ = this; 65 global_instance_ = this;
65 sender_ = sender; 66 sender_ = sender;
66 } 67 }
67 68
68 void CastIPCDispatcher::OnFilterRemoved() { 69 void CastIPCDispatcher::OnFilterRemoved() {
69 DCHECK(io_message_loop_->BelongsToCurrentThread()); 70 DCHECK(io_task_runner_->BelongsToCurrentThread());
70 DCHECK_EQ(this, global_instance_); 71 DCHECK_EQ(this, global_instance_);
71 global_instance_ = NULL; 72 global_instance_ = NULL;
72 sender_ = NULL; 73 sender_ = NULL;
73 } 74 }
74 75
75 void CastIPCDispatcher::OnChannelClosing() { 76 void CastIPCDispatcher::OnChannelClosing() {
76 DCHECK(io_message_loop_->BelongsToCurrentThread()); 77 DCHECK(io_task_runner_->BelongsToCurrentThread());
77 DCHECK_EQ(this, global_instance_); 78 DCHECK_EQ(this, global_instance_);
78 } 79 }
79 80
80 void CastIPCDispatcher::OnNotifyStatusChange( 81 void CastIPCDispatcher::OnNotifyStatusChange(
81 int32 channel_id, 82 int32 channel_id,
82 media::cast::CastTransportStatus status) { 83 media::cast::CastTransportStatus status) {
83 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); 84 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id);
84 if (sender) { 85 if (sender) {
85 sender->OnNotifyStatusChange(status); 86 sender->OnNotifyStatusChange(status);
86 } else { 87 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 void CastIPCDispatcher::OnReceivedPacket( 128 void CastIPCDispatcher::OnReceivedPacket(
128 int32 channel_id, 129 int32 channel_id,
129 const media::cast::Packet& packet) { 130 const media::cast::Packet& packet) {
130 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id); 131 CastTransportSenderIPC* sender = id_map_.Lookup(channel_id);
131 if (sender) { 132 if (sender) {
132 sender->OnReceivedPacket(packet); 133 sender->OnReceivedPacket(packet);
133 } else { 134 } else {
134 DVLOG(1) << "CastIPCDispatcher::OnReceievdPacket on non-existing channel."; 135 DVLOG(1) << "CastIPCDispatcher::OnReceievdPacket on non-existing channel.";
135 } 136 }
136 } 137 }
OLDNEW
« no previous file with comments | « chrome/renderer/media/cast_ipc_dispatcher.h ('k') | chrome/renderer/media/cast_ipc_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698