Chromium Code Reviews| Index: content/browser/renderer_host/media/peer_connection_tracker_host.cc |
| diff --git a/content/browser/renderer_host/media/peer_connection_tracker_host.cc b/content/browser/renderer_host/media/peer_connection_tracker_host.cc |
| index ac863e7eb898e825ed504abcb11b8dc7a83adb9a..7dcc9334ce735499ff2728a522358355917946f4 100644 |
| --- a/content/browser/renderer_host/media/peer_connection_tracker_host.cc |
| +++ b/content/browser/renderer_host/media/peer_connection_tracker_host.cc |
| @@ -3,14 +3,20 @@ |
| // found in the LICENSE file. |
| #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
| +#include "base/power_monitor/power_monitor.h" |
| #include "content/browser/media/webrtc_internals.h" |
| #include "content/common/media/peer_connection_tracker_messages.h" |
| +#include "content/public/browser/render_process_host.h" |
| namespace content { |
| PeerConnectionTrackerHost::PeerConnectionTrackerHost(int render_process_id) |
| : BrowserMessageFilter(PeerConnectionTrackerMsgStart), |
| - render_process_id_(render_process_id) {} |
| + render_process_id_(render_process_id) { |
| + base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| + if (power_monitor) |
| + power_monitor->AddObserver(this); |
| +} |
| bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { |
| bool handled = true; |
| @@ -35,7 +41,17 @@ void PeerConnectionTrackerHost::OverrideThreadForMessage( |
| *thread = BrowserThread::UI; |
| } |
| +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.
|
| + content::RenderProcessHost* host = |
| + content::RenderProcessHost::FromID(render_process_id_); |
| + 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.
|
| + host->Send(new PeerConnectionTracker_OnSuspend()); |
| +} |
| + |
| PeerConnectionTrackerHost::~PeerConnectionTrackerHost() { |
| + base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| + if (power_monitor) |
| + power_monitor->RemoveObserver(this); |
| } |
| void PeerConnectionTrackerHost::OnAddPeerConnection( |