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"
6 #include "base/process_util.h"
7 #include "content/browser/media/webrtc_internals.h"
8 #include "content/common/media/peer_connection_tracker_messages.h"
12 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id
)
13 : render_process_id_(render_process_id
) {}
15 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message
& message
,
16 bool* message_was_ok
) {
19 IPC_BEGIN_MESSAGE_MAP_EX(PeerConnectionTrackerHost
, message
, *message_was_ok
)
20 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection
,
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()
32 void PeerConnectionTrackerHost::OverrideThreadForMessage(
33 const IPC::Message
& message
, BrowserThread::ID
* thread
) {
34 if (IPC_MESSAGE_CLASS(message
) == PeerConnectionTrackerMsgStart
)
35 *thread
= BrowserThread::UI
;
38 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() {
41 void PeerConnectionTrackerHost::OnAddPeerConnection(
42 const PeerConnectionInfo
& info
) {
43 WebRTCInternals::GetInstance()->OnAddPeerConnection(
45 base::GetProcId(peer_handle()),
52 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid
) {
53 WebRTCInternals::GetInstance()->OnRemovePeerConnection(
54 base::GetProcId(peer_handle()), lid
);
57 void PeerConnectionTrackerHost::OnUpdatePeerConnection(
58 int lid
, const std::string
& type
, const std::string
& value
) {
59 WebRTCInternals::GetInstance()->OnUpdatePeerConnection(
60 base::GetProcId(peer_handle()),
66 void PeerConnectionTrackerHost::OnAddStats(int lid
,
67 const base::ListValue
& value
) {
68 WebRTCInternals::GetInstance()->OnAddStats(
69 base::GetProcId(peer_handle()), lid
, value
);
72 } // namespace content