| OLD | NEW |
| 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 <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 336 |
| 337 PeerConnectionTracker::~PeerConnectionTracker() { | 337 PeerConnectionTracker::~PeerConnectionTracker() { |
| 338 } | 338 } |
| 339 | 339 |
| 340 bool PeerConnectionTracker::OnControlMessageReceived( | 340 bool PeerConnectionTracker::OnControlMessageReceived( |
| 341 const IPC::Message& message) { | 341 const IPC::Message& message) { |
| 342 bool handled = true; | 342 bool handled = true; |
| 343 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTracker, message) | 343 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTracker, message) |
| 344 IPC_MESSAGE_HANDLER(PeerConnectionTracker_GetAllStats, OnGetAllStats) | 344 IPC_MESSAGE_HANDLER(PeerConnectionTracker_GetAllStats, OnGetAllStats) |
| 345 IPC_MESSAGE_HANDLER(PeerConnectionTracker_OnSuspend, OnSuspend) | 345 IPC_MESSAGE_HANDLER(PeerConnectionTracker_OnSuspend, OnSuspend) |
| 346 IPC_MESSAGE_HANDLER(PeerConnectionTracker_StartEventLog, OnStartEventLog) |
| 347 IPC_MESSAGE_HANDLER(PeerConnectionTracker_StopEventLog, OnStopEventLog) |
| 346 IPC_MESSAGE_UNHANDLED(handled = false) | 348 IPC_MESSAGE_UNHANDLED(handled = false) |
| 347 IPC_END_MESSAGE_MAP() | 349 IPC_END_MESSAGE_MAP() |
| 348 return handled; | 350 return handled; |
| 349 } | 351 } |
| 350 | 352 |
| 351 void PeerConnectionTracker::OnGetAllStats() { | 353 void PeerConnectionTracker::OnGetAllStats() { |
| 352 DCHECK(main_thread_.CalledOnValidThread()); | 354 DCHECK(main_thread_.CalledOnValidThread()); |
| 353 | 355 |
| 354 const std::string empty_track_id; | 356 const std::string empty_track_id; |
| 355 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); | 357 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 373 } | 375 } |
| 374 | 376 |
| 375 void PeerConnectionTracker::OnSuspend() { | 377 void PeerConnectionTracker::OnSuspend() { |
| 376 DCHECK(main_thread_.CalledOnValidThread()); | 378 DCHECK(main_thread_.CalledOnValidThread()); |
| 377 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); | 379 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); |
| 378 it != peer_connection_id_map_.end(); ++it) { | 380 it != peer_connection_id_map_.end(); ++it) { |
| 379 it->first->CloseClientPeerConnection(); | 381 it->first->CloseClientPeerConnection(); |
| 380 } | 382 } |
| 381 } | 383 } |
| 382 | 384 |
| 385 void PeerConnectionTracker::OnStartEventLog(int peer_connection_id, |
| 386 IPC::PlatformFileForTransit file) { |
| 387 DCHECK(main_thread_.CalledOnValidThread()); |
| 388 for (auto& it : peer_connection_id_map_) { |
| 389 if (it.second == peer_connection_id) { |
| 390 #if defined(OS_ANDROID) |
| 391 // A lower maximum filesize is used on Android because storage space is |
| 392 // more scarce on mobile. This upper limit applies to each peerconnection |
| 393 // individually, so the total amount of used storage can be a multiple of |
| 394 // this. |
| 395 const int64_t kMaxFilesizeBytes = 10000000; |
| 396 #else |
| 397 const int64_t kMaxFilesizeBytes = 60000000; |
| 398 #endif |
| 399 it.first->StartEventLog(file, kMaxFilesizeBytes); |
| 400 return; |
| 401 } |
| 402 } |
| 403 } |
| 404 |
| 405 void PeerConnectionTracker::OnStopEventLog(int peer_connection_id) { |
| 406 DCHECK(main_thread_.CalledOnValidThread()); |
| 407 for (auto& it : peer_connection_id_map_) { |
| 408 if (it.second == peer_connection_id) { |
| 409 it.first->StopEventLog(); |
| 410 return; |
| 411 } |
| 412 } |
| 413 } |
| 414 |
| 383 void PeerConnectionTracker::RegisterPeerConnection( | 415 void PeerConnectionTracker::RegisterPeerConnection( |
| 384 RTCPeerConnectionHandler* pc_handler, | 416 RTCPeerConnectionHandler* pc_handler, |
| 385 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 417 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 386 const blink::WebMediaConstraints& constraints, | 418 const blink::WebMediaConstraints& constraints, |
| 387 const blink::WebFrame* frame) { | 419 const blink::WebFrame* frame) { |
| 388 DCHECK(main_thread_.CalledOnValidThread()); | 420 DCHECK(main_thread_.CalledOnValidThread()); |
| 389 DCHECK_EQ(GetLocalIDForHandler(pc_handler), -1); | 421 DCHECK_EQ(GetLocalIDForHandler(pc_handler), -1); |
| 390 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; | 422 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; |
| 391 PeerConnectionInfo info; | 423 PeerConnectionInfo info; |
| 392 | 424 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 DCHECK(main_thread_.CalledOnValidThread()); | 738 DCHECK(main_thread_.CalledOnValidThread()); |
| 707 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( | 739 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 708 local_id, std::string(callback_type), value)); | 740 local_id, std::string(callback_type), value)); |
| 709 } | 741 } |
| 710 | 742 |
| 711 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { | 743 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { |
| 712 send_target_for_test_ = target; | 744 send_target_for_test_ = target; |
| 713 } | 745 } |
| 714 | 746 |
| 715 } // namespace content | 747 } // namespace content |
| OLD | NEW |