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

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

Issue 2516243002: CastTransportIPC can send messages to uninitialized channel id. (Closed)
Patch Set: miu comment 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_transport_ipc.h" 5 #include "chrome/renderer/media/cast_transport_ipc.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/id_map.h" 11 #include "base/id_map.h"
12 #include "chrome/common/cast_messages.h" 12 #include "chrome/common/cast_messages.h"
13 #include "chrome/renderer/media/cast_ipc_dispatcher.h" 13 #include "chrome/renderer/media/cast_ipc_dispatcher.h"
14 #include "ipc/ipc_channel_proxy.h" 14 #include "ipc/ipc_channel_proxy.h"
15 #include "media/cast/cast_sender.h" 15 #include "media/cast/cast_sender.h"
16 16
17 CastTransportIPC::CastTransportIPC( 17 CastTransportIPC::CastTransportIPC(
18 const net::IPEndPoint& local_end_point, 18 const net::IPEndPoint& local_end_point,
19 const net::IPEndPoint& remote_end_point, 19 const net::IPEndPoint& remote_end_point,
20 std::unique_ptr<base::DictionaryValue> options, 20 std::unique_ptr<base::DictionaryValue> options,
21 const media::cast::PacketReceiverCallback& packet_callback, 21 const media::cast::PacketReceiverCallback& packet_callback,
22 const media::cast::CastTransportStatusCallback& status_cb, 22 const media::cast::CastTransportStatusCallback& status_cb,
23 const media::cast::BulkRawEventsCallback& raw_events_cb) 23 const media::cast::BulkRawEventsCallback& raw_events_cb)
24 : packet_callback_(packet_callback), 24 : channel_id_(-1),
25 packet_callback_(packet_callback),
25 status_callback_(status_cb), 26 status_callback_(status_cb),
26 raw_events_callback_(raw_events_cb) { 27 raw_events_callback_(raw_events_cb) {
27 if (CastIPCDispatcher::Get()) { 28 if (CastIPCDispatcher::Get()) {
29 // TODO: CastIPCDispatcher should be provided as a ctor argument.
miu 2016/11/21 21:11:54 nit: In Chromium, TODO comments should have author
28 channel_id_ = CastIPCDispatcher::Get()->AddSender(this); 30 channel_id_ = CastIPCDispatcher::Get()->AddSender(this);
31 Send(new CastHostMsg_New(channel_id_, local_end_point, remote_end_point,
32 *options));
29 } 33 }
30 Send(new CastHostMsg_New(channel_id_, local_end_point, remote_end_point,
31 *options));
32 } 34 }
33 35
34 CastTransportIPC::~CastTransportIPC() { 36 CastTransportIPC::~CastTransportIPC() {
35 Send(new CastHostMsg_Delete(channel_id_)); 37 if (channel_id_ != -1) {
miu 2016/11/21 21:11:54 nit: This check isn't needed either (since Send()
38 Send(new CastHostMsg_Delete(channel_id_));
39 }
36 if (CastIPCDispatcher::Get()) { 40 if (CastIPCDispatcher::Get()) {
37 CastIPCDispatcher::Get()->RemoveSender(channel_id_); 41 CastIPCDispatcher::Get()->RemoveSender(channel_id_);
38 } 42 }
39 } 43 }
40 44
41 void CastTransportIPC::InitializeStream( 45 void CastTransportIPC::InitializeStream(
42 const media::cast::CastTransportRtpConfig& config, 46 const media::cast::CastTransportRtpConfig& config,
43 std::unique_ptr<media::cast::RtcpObserver> rtcp_observer) { 47 std::unique_ptr<media::cast::RtcpObserver> rtcp_observer) {
44 if (rtcp_observer) { 48 if (rtcp_observer) {
45 DCHECK(clients_.find(config.ssrc) == clients_.end()); 49 DCHECK(clients_.find(config.ssrc) == clients_.end());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? 173 // TODO(hubbe): Perhaps an non-ownership-transferring cb here?
170 std::unique_ptr<media::cast::Packet> packet_copy( 174 std::unique_ptr<media::cast::Packet> packet_copy(
171 new media::cast::Packet(packet)); 175 new media::cast::Packet(packet));
172 packet_callback_.Run(std::move(packet_copy)); 176 packet_callback_.Run(std::move(packet_copy));
173 } else { 177 } else {
174 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; 178 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet.";
175 } 179 }
176 } 180 }
177 181
178 void CastTransportIPC::Send(IPC::Message* message) { 182 void CastTransportIPC::Send(IPC::Message* message) {
179 if (CastIPCDispatcher::Get()) { 183 if (CastIPCDispatcher::Get() && channel_id_ != -1) {
180 CastIPCDispatcher::Get()->Send(message); 184 CastIPCDispatcher::Get()->Send(message);
181 } else { 185 } else {
182 delete message; 186 delete message;
183 } 187 }
184 } 188 }
OLDNEW
« 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