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

Side by Side Diff: content/browser/media/webrtc/webrtc_eventlog_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "content/browser/media/webrtc/webrtc_eventlog_host.h" 5 #include "content/browser/media/webrtc/webrtc_eventlog_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 number_active_log_files_ = 0; 118 number_active_log_files_ = 0;
119 rtc_event_logging_enabled_ = false; 119 rtc_event_logging_enabled_ = false;
120 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_); 120 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
121 if (host) { 121 if (host) {
122 for (int local_id : active_peer_connection_local_ids_) 122 for (int local_id : active_peer_connection_local_ids_)
123 host->Send(new PeerConnectionTracker_StopEventLog(local_id)); 123 host->Send(new PeerConnectionTracker_StopEventLog(local_id));
124 } 124 }
125 return true; 125 return true;
126 } 126 }
127 127
128 base::WeakPtr<WebRTCEventLogHost> WebRTCEventLogHost::GetWeakPtr() {
129 return weak_ptr_factory_.GetWeakPtr();
130 }
131
128 bool WebRTCEventLogHost::StartEventLogForPeerConnection( 132 bool WebRTCEventLogHost::StartEventLogForPeerConnection(
129 int peer_connection_local_id) { 133 int peer_connection_local_id) {
130 if (number_active_log_files_ < kMaxNumberLogFiles) { 134 if (number_active_log_files_ < kMaxNumberLogFiles) {
131 ++number_active_log_files_; 135 ++number_active_log_files_;
132 BrowserThread::PostTaskAndReplyWithResult( 136 BrowserThread::PostTaskAndReplyWithResult(
133 BrowserThread::FILE, FROM_HERE, 137 BrowserThread::FILE, FROM_HERE,
134 base::Bind(&CreateFileForProcess, base_file_path_, render_process_id_, 138 base::Bind(&CreateFileForProcess, base_file_path_, render_process_id_,
135 peer_connection_local_id), 139 peer_connection_local_id),
136 base::Bind(&WebRTCEventLogHost::SendEventLogFileToRenderer, 140 base::Bind(&WebRTCEventLogHost::SendEventLogFileToRenderer,
137 weak_ptr_factory_.GetWeakPtr(), peer_connection_local_id)); 141 weak_ptr_factory_.GetWeakPtr(), peer_connection_local_id));
(...skipping 12 matching lines...) Expand all
150 if (rph) { 154 if (rph) {
151 rph->Send(new PeerConnectionTracker_StartEventLog(peer_connection_local_id, 155 rph->Send(new PeerConnectionTracker_StartEventLog(peer_connection_local_id,
152 file_for_transit)); 156 file_for_transit));
153 } else { 157 } else {
154 --number_active_log_files_; 158 --number_active_log_files_;
155 IPC::PlatformFileForTransitToFile(file_for_transit).Close(); 159 IPC::PlatformFileForTransitToFile(file_for_transit).Close();
156 } 160 }
157 } 161 }
158 162
159 } // namespace content 163 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698