Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / renderer_host / media / peer_connection_tracker_host.cc
blob96029b99304179d87b9b2a1c5f390c3c19d4983b
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 "content/browser/media/webrtc_internals.h"
7 #include "content/common/media/peer_connection_tracker_messages.h"
9 namespace content {
11 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id)
12 : BrowserMessageFilter(PeerConnectionTrackerMsgStart),
13 render_process_id_(render_process_id) {}
15 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message,
16 bool* message_was_ok) {
17 bool handled = true;
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_HANDLER(PeerConnectionTrackerHost_GetUserMedia, OnGetUserMedia)
28 IPC_MESSAGE_UNHANDLED(handled = false)
29 IPC_END_MESSAGE_MAP_EX()
30 return handled;
33 void PeerConnectionTrackerHost::OverrideThreadForMessage(
34 const IPC::Message& message, BrowserThread::ID* thread) {
35 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart)
36 *thread = BrowserThread::UI;
39 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() {
42 void PeerConnectionTrackerHost::OnAddPeerConnection(
43 const PeerConnectionInfo& info) {
44 WebRTCInternals::GetInstance()->OnAddPeerConnection(
45 render_process_id_,
46 peer_pid(),
47 info.lid,
48 info.url,
49 info.servers,
50 info.constraints);
53 void PeerConnectionTrackerHost::OnRemovePeerConnection(int lid) {
54 WebRTCInternals::GetInstance()->OnRemovePeerConnection(peer_pid(), lid);
57 void PeerConnectionTrackerHost::OnUpdatePeerConnection(
58 int lid, const std::string& type, const std::string& value) {
59 WebRTCInternals::GetInstance()->OnUpdatePeerConnection(
60 peer_pid(),
61 lid,
62 type,
63 value);
66 void PeerConnectionTrackerHost::OnAddStats(int lid,
67 const base::ListValue& value) {
68 WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value);
71 void PeerConnectionTrackerHost::OnGetUserMedia(
72 const std::string& origin,
73 bool audio,
74 bool video,
75 const std::string& audio_constraints,
76 const std::string& video_constraints) {
77 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_,
78 peer_pid(),
79 origin,
80 audio,
81 video,
82 audio_constraints,
83 video_constraints);
86 } // namespace content