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

Side by Side Diff: content/browser/renderer_host/media/peer_connection_tracker_host.cc

Issue 2187243002: Changed raw pointer to WeakPtr to prevent use-after-free on destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h"
5 5
6 #include "base/power_monitor/power_monitor.h" 6 #include "base/power_monitor/power_monitor.h"
7 #include "content/browser/media/webrtc/webrtc_eventlog_host.h" 7 #include "content/browser/media/webrtc/webrtc_eventlog_host.h"
8 #include "content/browser/media/webrtc/webrtc_internals.h" 8 #include "content/browser/media/webrtc/webrtc_internals.h"
9 #include "content/browser/renderer_host/render_process_host_impl.h" 9 #include "content/browser/renderer_host/render_process_host_impl.h"
10 #include "content/common/media/peer_connection_tracker_messages.h" 10 #include "content/common/media/peer_connection_tracker_messages.h"
11 11
12 namespace content { 12 namespace content {
13 13
14 PeerConnectionTrackerHost::PeerConnectionTrackerHost( 14 PeerConnectionTrackerHost::PeerConnectionTrackerHost(
15 int render_process_id, 15 int render_process_id,
16 WebRTCEventLogHost* event_log_host) 16 const base::WeakPtr<WebRTCEventLogHost>& event_log_host)
17 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), 17 : BrowserMessageFilter(PeerConnectionTrackerMsgStart),
18 render_process_id_(render_process_id), 18 render_process_id_(render_process_id),
19 event_log_host_(event_log_host) { 19 event_log_host_(event_log_host) {
20 DCHECK(event_log_host); 20 DCHECK(event_log_host);
21 } 21 }
22 22
23 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { 23 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) {
24 bool handled = true; 24 bool handled = true;
25 25
26 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) 26 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 void PeerConnectionTrackerHost::OnAddPeerConnection( 70 void PeerConnectionTrackerHost::OnAddPeerConnection(
71 const PeerConnectionInfo& info) { 71 const PeerConnectionInfo& info) {
72 WebRTCInternals::GetInstance()->OnAddPeerConnection( 72 WebRTCInternals::GetInstance()->OnAddPeerConnection(
73 render_process_id_, 73 render_process_id_,
74 peer_pid(), 74 peer_pid(),
75 info.lid, 75 info.lid,
76 info.url, 76 info.url,
77 info.rtc_configuration, 77 info.rtc_configuration,
78 info.constraints); 78 info.constraints);
79 event_log_host_->PeerConnectionAdded(info.lid); 79 if (event_log_host_)
80 event_log_host_->PeerConnectionAdded(info.lid);
80 } 81 }
81 82
82 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) { 83 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) {
83 WebRTCInternals::GetInstance()->OnRemovePeerConnection(peer_pid(), lid); 84 WebRTCInternals::GetInstance()->OnRemovePeerConnection(peer_pid(), lid);
84 event_log_host_->PeerConnectionRemoved(lid); 85 if (event_log_host_)
86 event_log_host_->PeerConnectionRemoved(lid);
85 } 87 }
86 88
87 void PeerConnectionTrackerHost::OnUpdatePeerConnection( 89 void PeerConnectionTrackerHost::OnUpdatePeerConnection(
88 int lid, const std::string& type, const std::string& value) { 90 int lid, const std::string& type, const std::string& value) {
89 WebRTCInternals::GetInstance()->OnUpdatePeerConnection( 91 WebRTCInternals::GetInstance()->OnUpdatePeerConnection(
90 peer_pid(), 92 peer_pid(),
91 lid, 93 lid,
92 type, 94 type,
93 value); 95 value);
94 } 96 }
(...skipping 25 matching lines...) Expand all
120 122
121 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() { 123 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() {
122 DCHECK_CURRENTLY_ON(BrowserThread::UI); 124 DCHECK_CURRENTLY_ON(BrowserThread::UI);
123 content::RenderProcessHost* host = 125 content::RenderProcessHost* host =
124 content::RenderProcessHost::FromID(render_process_id_); 126 content::RenderProcessHost::FromID(render_process_id_);
125 if (host) 127 if (host)
126 host->Send(new PeerConnectionTracker_OnSuspend()); 128 host->Send(new PeerConnectionTracker_OnSuspend());
127 } 129 }
128 130
129 } // namespace content 131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698