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

Unified Diff: content/browser/media/media_web_contents_observer.cc

Issue 2003803002: Remove dependency of power_save_blocker_android on various content bits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@power-save-task-runners
Patch Set: only .reset() Created 4 years, 6 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
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | content/browser/power_save_blocker_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/media/media_web_contents_observer.cc
diff --git a/content/browser/media/media_web_contents_observer.cc b/content/browser/media/media_web_contents_observer.cc
index 14251a7c6f5daf223744b61bbe41cf6c2c27e9ae..fd3a9c06e63730e877ad81cc5d6d301507364142 100644
--- a/content/browser/media/media_web_contents_observer.cc
+++ b/content/browser/media/media_web_contents_observer.cc
@@ -35,6 +35,9 @@ MediaWebContentsObserver::~MediaWebContentsObserver() {}
void MediaWebContentsObserver::WebContentsDestroyed() {
g_audible_metrics.Get().UpdateAudibleWebContentsState(web_contents(), false);
+#if defined(OS_ANDROID)
+ view_weak_factory_.reset();
+#endif
}
void MediaWebContentsObserver::RenderFrameDeleted(
@@ -193,8 +196,12 @@ void MediaWebContentsObserver::CreateVideoPowerSaveBlocker() {
PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
PowerSaveBlocker::kReasonVideoPlayback, "Playing video");
#if defined(OS_ANDROID)
- static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get())
- ->InitDisplaySleepBlocker(web_contents());
+ if (web_contents()->GetNativeView()) {
+ view_weak_factory_.reset(new base::WeakPtrFactory<ui::ViewAndroid>(
+ web_contents()->GetNativeView()));
+ static_cast<PowerSaveBlockerImpl*>(video_power_save_blocker_.get())
+ ->InitDisplaySleepBlocker(view_weak_factory_->GetWeakPtr());
+ }
#endif
}
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | content/browser/power_save_blocker_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698