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

Side by Side 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 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(miu): CastIPCDispatcher should be provided as a ctor argument.
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 Send(new CastHostMsg_Delete(channel_id_));
36 if (CastIPCDispatcher::Get()) { 38 if (CastIPCDispatcher::Get()) {
37 CastIPCDispatcher::Get()->RemoveSender(channel_id_); 39 CastIPCDispatcher::Get()->RemoveSender(channel_id_);
38 } 40 }
39 } 41 }
40 42
41 void CastTransportIPC::InitializeStream( 43 void CastTransportIPC::InitializeStream(
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 // TODO(hubbe): Perhaps an non-ownership-transferring cb here? 171 // TODO(hubbe): Perhaps an non-ownership-transferring cb here?
170 std::unique_ptr<media::cast::Packet> packet_copy( 172 std::unique_ptr<media::cast::Packet> packet_copy(
171 new media::cast::Packet(packet)); 173 new media::cast::Packet(packet));
172 packet_callback_.Run(std::move(packet_copy)); 174 packet_callback_.Run(std::move(packet_copy));
173 } else { 175 } else {
174 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet."; 176 DVLOG(1) << "CastIPCDispatcher::OnReceivedPacket no packet callback yet.";
175 } 177 }
176 } 178 }
177 179
178 void CastTransportIPC::Send(IPC::Message* message) { 180 void CastTransportIPC::Send(IPC::Message* message) {
179 if (CastIPCDispatcher::Get()) { 181 if (CastIPCDispatcher::Get() && channel_id_ != -1) {
180 CastIPCDispatcher::Get()->Send(message); 182 CastIPCDispatcher::Get()->Send(message);
181 } else { 183 } else {
182 delete message; 184 delete message;
183 } 185 }
184 } 186 }
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