| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" | 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
| 5 | 5 |
| 6 #include "base/power_monitor/power_monitor.h" | |
| 7 #include "content/browser/media/webrtc_internals.h" | 6 #include "content/browser/media/webrtc_internals.h" |
| 8 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
| 9 #include "content/public/browser/render_process_host.h" | |
| 10 | 8 |
| 11 namespace content { | 9 namespace content { |
| 12 | 10 |
| 13 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id) | 11 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id) |
| 14 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), | 12 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), |
| 15 render_process_id_(render_process_id) { | 13 render_process_id_(render_process_id) {} |
| 16 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | |
| 17 if (power_monitor) | |
| 18 power_monitor->AddObserver(this); | |
| 19 } | |
| 20 | 14 |
| 21 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { | 15 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { |
| 22 bool handled = true; | 16 bool handled = true; |
| 23 | 17 |
| 24 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) | 18 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) |
| 25 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, | 19 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, |
| 26 OnAddPeerConnection) | 20 OnAddPeerConnection) |
| 27 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, | 21 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, |
| 28 OnRemovePeerConnection) | 22 OnRemovePeerConnection) |
| 29 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_UpdatePeerConnection, | 23 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_UpdatePeerConnection, |
| 30 OnUpdatePeerConnection) | 24 OnUpdatePeerConnection) |
| 31 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddStats, OnAddStats) | 25 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddStats, OnAddStats) |
| 32 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_GetUserMedia, OnGetUserMedia) | 26 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_GetUserMedia, OnGetUserMedia) |
| 33 IPC_MESSAGE_UNHANDLED(handled = false) | 27 IPC_MESSAGE_UNHANDLED(handled = false) |
| 34 IPC_END_MESSAGE_MAP() | 28 IPC_END_MESSAGE_MAP() |
| 35 return handled; | 29 return handled; |
| 36 } | 30 } |
| 37 | 31 |
| 38 void PeerConnectionTrackerHost::OverrideThreadForMessage( | 32 void PeerConnectionTrackerHost::OverrideThreadForMessage( |
| 39 const IPC::Message& message, BrowserThread::ID* thread) { | 33 const IPC::Message& message, BrowserThread::ID* thread) { |
| 40 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) | 34 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) |
| 41 *thread = BrowserThread::UI; | 35 *thread = BrowserThread::UI; |
| 42 } | 36 } |
| 43 | 37 |
| 44 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { | 38 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { |
| 45 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | |
| 46 if (power_monitor) | |
| 47 power_monitor->RemoveObserver(this); | |
| 48 } | 39 } |
| 49 | 40 |
| 50 void PeerConnectionTrackerHost::OnAddPeerConnection( | 41 void PeerConnectionTrackerHost::OnAddPeerConnection( |
| 51 const PeerConnectionInfo& info) { | 42 const PeerConnectionInfo& info) { |
| 52 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 43 WebRTCInternals::GetInstance()->OnAddPeerConnection( |
| 53 render_process_id_, | 44 render_process_id_, |
| 54 peer_pid(), | 45 peer_pid(), |
| 55 info.lid, | 46 info.lid, |
| 56 info.url, | 47 info.url, |
| 57 info.rtc_configuration, | 48 info.rtc_configuration, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 84 const std::string& video_constraints) { | 75 const std::string& video_constraints) { |
| 85 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, | 76 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, |
| 86 peer_pid(), | 77 peer_pid(), |
| 87 origin, | 78 origin, |
| 88 audio, | 79 audio, |
| 89 video, | 80 video, |
| 90 audio_constraints, | 81 audio_constraints, |
| 91 video_constraints); | 82 video_constraints); |
| 92 } | 83 } |
| 93 | 84 |
| 94 void PeerConnectionTrackerHost::OnSuspend() { | |
| 95 content::RenderProcessHost* host = | |
| 96 content::RenderProcessHost::FromID(render_process_id_); | |
| 97 CHECK(host); | |
| 98 host->Send(new PeerConnectionTracker_OnSuspend()); | |
| 99 } | |
| 100 | |
| 101 } // namespace content | 85 } // namespace content |
| OLD | NEW |