Save errno for logging before potentially overwriting it.
[chromium-blink-merge.git] / content / browser / renderer_host / media / peer_connection_tracker_host.cc
blob4ba1a0a2ffcd6914d9a0c4e83165efb53d220379
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"
10 namespace content {
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) {
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_UNHANDLED(handled = false)
28 IPC_END_MESSAGE_MAP_EX()
29 return handled;
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(
44 render_process_id_,
45 base::GetProcId(peer_handle()),
46 info.lid,
47 info.url,
48 info.servers,
49 info.constraints);
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()),
61 lid,
62 type,
63 value);
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