Chromium Code Reviews| 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" | |
| 6 #include "content/browser/media/webrtc_internals.h" | 7 #include "content/browser/media/webrtc_internals.h" |
| 7 #include "content/common/media/peer_connection_tracker_messages.h" | 8 #include "content/common/media/peer_connection_tracker_messages.h" |
| 9 #include "content/public/browser/render_process_host.h" | |
| 8 | 10 |
| 9 namespace content { | 11 namespace content { |
| 10 | 12 |
| 11 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id) | 13 PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id) |
| 12 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), | 14 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), |
| 13 render_process_id_(render_process_id) {} | 15 render_process_id_(render_process_id) { |
| 16 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | |
| 17 if (power_monitor) | |
| 18 power_monitor->AddObserver(this); | |
| 19 } | |
| 14 | 20 |
| 15 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { | 21 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { |
| 16 bool handled = true; | 22 bool handled = true; |
| 17 | 23 |
| 18 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) | 24 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) |
| 19 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, | 25 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, |
| 20 OnAddPeerConnection) | 26 OnAddPeerConnection) |
| 21 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, | 27 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_RemovePeerConnection, |
| 22 OnRemovePeerConnection) | 28 OnRemovePeerConnection) |
| 23 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_UpdatePeerConnection, | 29 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_UpdatePeerConnection, |
| 24 OnUpdatePeerConnection) | 30 OnUpdatePeerConnection) |
| 25 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddStats, OnAddStats) | 31 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddStats, OnAddStats) |
| 26 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_GetUserMedia, OnGetUserMedia) | 32 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_GetUserMedia, OnGetUserMedia) |
| 27 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
| 28 IPC_END_MESSAGE_MAP() | 34 IPC_END_MESSAGE_MAP() |
| 29 return handled; | 35 return handled; |
| 30 } | 36 } |
| 31 | 37 |
| 32 void PeerConnectionTrackerHost::OverrideThreadForMessage( | 38 void PeerConnectionTrackerHost::OverrideThreadForMessage( |
| 33 const IPC::Message& message, BrowserThread::ID* thread) { | 39 const IPC::Message& message, BrowserThread::ID* thread) { |
| 34 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) | 40 if (IPC_MESSAGE_CLASS(message) == PeerConnectionTrackerMsgStart) |
| 35 *thread = BrowserThread::UI; | 41 *thread = BrowserThread::UI; |
| 36 } | 42 } |
| 37 | 43 |
| 44 void PeerConnectionTrackerHost::OnSuspend() { | |
|
nasko
2014/08/15 19:14:19
nit: I'd move this below with the rest of the meth
vrk (LEFT CHROMIUM)
2014/08/15 23:35:25
Done.
| |
| 45 content::RenderProcessHost* host = | |
| 46 content::RenderProcessHost::FromID(render_process_id_); | |
| 47 if (host) | |
|
nasko
2014/08/15 19:14:18
This object is created and owned by RenderProcessH
vrk (LEFT CHROMIUM)
2014/08/15 23:35:26
Good point, Done.
| |
| 48 host->Send(new PeerConnectionTracker_OnSuspend()); | |
| 49 } | |
| 50 | |
| 38 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { | 51 PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { |
| 52 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | |
| 53 if (power_monitor) | |
| 54 power_monitor->RemoveObserver(this); | |
| 39 } | 55 } |
| 40 | 56 |
| 41 void PeerConnectionTrackerHost::OnAddPeerConnection( | 57 void PeerConnectionTrackerHost::OnAddPeerConnection( |
| 42 const PeerConnectionInfo& info) { | 58 const PeerConnectionInfo& info) { |
| 43 WebRTCInternals::GetInstance()->OnAddPeerConnection( | 59 WebRTCInternals::GetInstance()->OnAddPeerConnection( |
| 44 render_process_id_, | 60 render_process_id_, |
| 45 peer_pid(), | 61 peer_pid(), |
| 46 info.lid, | 62 info.lid, |
| 47 info.url, | 63 info.url, |
| 48 info.rtc_configuration, | 64 info.rtc_configuration, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 76 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, | 92 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, |
| 77 peer_pid(), | 93 peer_pid(), |
| 78 origin, | 94 origin, |
| 79 audio, | 95 audio, |
| 80 video, | 96 video, |
| 81 audio_constraints, | 97 audio_constraints, |
| 82 video_constraints); | 98 video_constraints); |
| 83 } | 99 } |
| 84 | 100 |
| 85 } // namespace content | 101 } // namespace content |
| OLD | NEW |