Index: chrome/browser/media/cast_transport_host_filter.cc |
diff --git a/chrome/browser/media/cast_transport_host_filter.cc b/chrome/browser/media/cast_transport_host_filter.cc |
index 0d8309a268ddcaf2c66f615453e48c0566565d11..f56bef7ad3c457f3998ea93ef2822bbb767f2a8b 100644 |
--- a/chrome/browser/media/cast_transport_host_filter.cc |
+++ b/chrome/browser/media/cast_transport_host_filter.cc |
@@ -6,6 +6,7 @@ |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/net/chrome_net_log.h" |
+#include "content/public/browser/power_save_blocker.h" |
#include "media/cast/net/cast_transport_sender.h" |
namespace { |
@@ -83,6 +84,14 @@ void CastTransportHostFilter::SendCastMessage( |
void CastTransportHostFilter::OnNew( |
int32 channel_id, |
const net::IPEndPoint& remote_end_point) { |
+ if (!power_save_blocker_) { |
+ DVLOG(1) << ("Preventing the application from being suspended while one or " |
+ "more transports are active for Cast Streaming."); |
+ power_save_blocker_ = content::PowerSaveBlocker::Create( |
+ content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension, |
+ "Cast is streaming content to a remote receiver.").Pass(); |
+ } |
+ |
if (id_map_.Lookup(channel_id)) { |
id_map_.Remove(channel_id); |
} |
@@ -112,6 +121,13 @@ void CastTransportHostFilter::OnDelete(int32 channel_id) { |
DVLOG(1) << "CastTransportHostFilter::Delete called " |
<< "on non-existing channel"; |
} |
+ |
+ if (id_map_.IsEmpty()) { |
+ DVLOG_IF(1, power_save_blocker_) << |
+ ("Releasing the block on application suspension since no transports " |
+ "are active anymore for Cast Streaming."); |
+ power_save_blocker_.reset(); |
+ } |
} |
void CastTransportHostFilter::OnInitializeAudio( |