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