Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Unified Diff: content/browser/renderer_host/media/peer_connection_tracker_host.cc

Issue 482333003: Reland r290125: Close all active PeerConnections upon OS suspend (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove semi Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b1e286949bdac2294c2b0651c58073cbcfed417d 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;
@@ -36,6 +42,9 @@ void PeerConnectionTrackerHost::OverrideThreadForMessage(
}
PeerConnectionTrackerHost::~PeerConnectionTrackerHost() {
+ base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
+ if (power_monitor)
+ power_monitor->RemoveObserver(this);
}
void PeerConnectionTrackerHost::OnAddPeerConnection(
@@ -82,4 +91,11 @@ void PeerConnectionTrackerHost::OnGetUserMedia(
video_constraints);
}
+void PeerConnectionTrackerHost::OnSuspend() {
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(render_process_id_);
+ if (host)
+ host->Send(new PeerConnectionTracker_OnSuspend());
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698