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 3 // found in the LICENSE file. 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" 5 6 #include "content/browser/media/webrtc_internals.h" 7 #include "content/common/media/peer_connection_tracker_messages.h" 8 9 namespace content { 10 11 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id) 12 : render_process_id_(render_process_id) {} 13 14 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message, 15 bool* message_was_ok) { 16 bool handled = true; 17 18 IPC_BEGIN_MESSAGE_MAP_EX(PeerConnectionTrackerHost, message, *message_was_ok) 19 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, 20 OnAddPeerConnection) 21 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, 22 OnRemovePeerConnection) 23 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_UpdatePeerConnection, 24 OnUpdatePeerConnection) 25 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddStats, OnAddStats) 26 IPC_MESSAGE_UNHANDLED(handled = false) 27 IPC_END_MESSAGE_MAP_EX() 28 return handled; 29 } 30 31 void PeerConnectionTrackerHost::OverrideThreadForMessage( 32 const IPC::Message& message, BrowserThread::ID* thread) { 33 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) 34 *thread = BrowserThread::UI; 35 } 36 37 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { 38 } 39 40 void PeerConnectionTrackerHost::OnAddPeerConnection( 41 const PeerConnectionInfo& info) { 42 WebRTCInternals::GetInstance()->OnAddPeerConnection( 43 render_process_id_, 44 peer_pid(), 45 info.lid, 46 info.url, 47 info.servers, 48 info.constraints); 49 } 50 51 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) { 52 WebRTCInternals::GetInstance()->OnRemovePeerConnection(peer_pid(), lid); 53 } 54 55 void PeerConnectionTrackerHost::OnUpdatePeerConnection( 56 int lid, const std::string& type, const std::string& value) { 57 WebRTCInternals::GetInstance()->OnUpdatePeerConnection( 58 peer_pid(), 59 lid, 60 type, 61 value); 62 } 63 64 void PeerConnectionTrackerHost::OnAddStats(int lid, 65 const base::ListValue& value) { 66 WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value); 67 } 68 69 } // namespace content 70