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

Unified Diff: chrome/renderer/media/cast_transport_ipc.cc

Issue 2516243002: CastTransportIPC can send messages to uninitialized channel id. (Closed)
Patch Set: nit fix Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/media/cast_transport_ipc.cc
diff --git a/chrome/renderer/media/cast_transport_ipc.cc b/chrome/renderer/media/cast_transport_ipc.cc
index 518610fd3c41775523a5dbf9ca5a9372da43edde..b2c9e3243bbd3a11239a710eb24e16adc6d0d11c 100644
--- a/chrome/renderer/media/cast_transport_ipc.cc
+++ b/chrome/renderer/media/cast_transport_ipc.cc
@@ -21,14 +21,16 @@ CastTransportIPC::CastTransportIPC(
const media::cast::PacketReceiverCallback& packet_callback,
const media::cast::CastTransportStatusCallback& status_cb,
const media::cast::BulkRawEventsCallback& raw_events_cb)
- : packet_callback_(packet_callback),
+ : channel_id_(-1),
+ packet_callback_(packet_callback),
status_callback_(status_cb),
raw_events_callback_(raw_events_cb) {
if (CastIPCDispatcher::Get()) {
+ // TODO(miu): CastIPCDispatcher should be provided as a ctor argument.
channel_id_ = CastIPCDispatcher::Get()->AddSender(this);
+ Send(new CastHostMsg_New(channel_id_, local_end_point, remote_end_point,
+ *options));
}
- Send(new CastHostMsg_New(channel_id_, local_end_point, remote_end_point,
- *options));
}
CastTransportIPC::~CastTransportIPC() {
@@ -176,7 +178,7 @@ void CastTransportIPC::OnReceivedPacket(const media::cast::Packet& packet) {
}
void CastTransportIPC::Send(IPC::Message* message) {
- if (CastIPCDispatcher::Get()) {
+ if (CastIPCDispatcher::Get() && channel_id_ != -1) {
CastIPCDispatcher::Get()->Send(message);
} else {
delete message;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698