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

Side by Side Diff: content/renderer/media/peer_connection_tracker.cc

Issue 577483002: Close all active PeerConnections upon OS suspend (relanding r290125 and r291213) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crashing Created 6 years, 3 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/renderer/media/peer_connection_tracker.h" 4 #include "content/renderer/media/peer_connection_tracker.h"
5 5
6 #include "base/strings/string_number_conversions.h" 6 #include "base/strings/string_number_conversions.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/common/media/peer_connection_tracker_messages.h" 8 #include "content/common/media/peer_connection_tracker_messages.h"
9 #include "content/renderer/media/rtc_media_constraints.h" 9 #include "content/renderer/media/rtc_media_constraints.h"
10 #include "content/renderer/media/rtc_peer_connection_handler.h" 10 #include "content/renderer/media/rtc_peer_connection_handler.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 } 272 }
273 273
274 PeerConnectionTracker::~PeerConnectionTracker() { 274 PeerConnectionTracker::~PeerConnectionTracker() {
275 } 275 }
276 276
277 bool PeerConnectionTracker::OnControlMessageReceived( 277 bool PeerConnectionTracker::OnControlMessageReceived(
278 const IPC::Message& message) { 278 const IPC::Message& message) {
279 bool handled = true; 279 bool handled = true;
280 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTracker, message) 280 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTracker, message)
281 IPC_MESSAGE_HANDLER(PeerConnectionTracker_GetAllStats, OnGetAllStats) 281 IPC_MESSAGE_HANDLER(PeerConnectionTracker_GetAllStats, OnGetAllStats)
282 IPC_MESSAGE_HANDLER(PeerConnectionTracker_OnSuspend, OnSuspend)
282 IPC_MESSAGE_UNHANDLED(handled = false) 283 IPC_MESSAGE_UNHANDLED(handled = false)
283 IPC_END_MESSAGE_MAP() 284 IPC_END_MESSAGE_MAP()
284 return handled; 285 return handled;
285 } 286 }
286 287
287 void PeerConnectionTracker::OnGetAllStats() { 288 void PeerConnectionTracker::OnGetAllStats() {
288 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); 289 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin();
289 it != peer_connection_id_map_.end(); ++it) { 290 it != peer_connection_id_map_.end(); ++it) {
290 291
291 rtc::scoped_refptr<InternalStatsObserver> observer( 292 rtc::scoped_refptr<InternalStatsObserver> observer(
292 new rtc::RefCountedObject<InternalStatsObserver>(it->second)); 293 new rtc::RefCountedObject<InternalStatsObserver>(it->second));
293 294
294 it->first->GetStats( 295 it->first->GetStats(
295 observer, 296 observer,
296 NULL, 297 NULL,
297 webrtc::PeerConnectionInterface::kStatsOutputLevelDebug); 298 webrtc::PeerConnectionInterface::kStatsOutputLevelDebug);
298 } 299 }
299 } 300 }
300 301
302 void PeerConnectionTracker::OnSuspend() {
303 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin();
304 it != peer_connection_id_map_.end(); ++it) {
305 it->first->CloseClientPeerConnection();
306 }
307 }
308
301 void PeerConnectionTracker::RegisterPeerConnection( 309 void PeerConnectionTracker::RegisterPeerConnection(
302 RTCPeerConnectionHandler* pc_handler, 310 RTCPeerConnectionHandler* pc_handler,
303 const webrtc::PeerConnectionInterface::RTCConfiguration& config, 311 const webrtc::PeerConnectionInterface::RTCConfiguration& config,
304 const RTCMediaConstraints& constraints, 312 const RTCMediaConstraints& constraints,
305 const blink::WebFrame* frame) { 313 const blink::WebFrame* frame) {
306 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; 314 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()";
307 PeerConnectionInfo info; 315 PeerConnectionInfo info;
308 316
309 info.lid = GetNextLocalID(); 317 info.lid = GetNextLocalID();
310 info.rtc_configuration = 318 info.rtc_configuration =
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 const std::string& value) { 537 const std::string& value) {
530 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) 538 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end())
531 return; 539 return;
532 540
533 RenderThreadImpl::current()->Send( 541 RenderThreadImpl::current()->Send(
534 new PeerConnectionTrackerHost_UpdatePeerConnection( 542 new PeerConnectionTrackerHost_UpdatePeerConnection(
535 peer_connection_id_map_[pc_handler], type, value)); 543 peer_connection_id_map_[pc_handler], type, value));
536 } 544 }
537 545
538 } // namespace content 546 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/peer_connection_tracker.h ('k') | content/renderer/media/rtc_peer_connection_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698