From a8759a3176d301bdc7d777d022a5941d151841a0 Mon Sep 17 00:00:00 2001 From: Andrew MacDonald Date: Fri, 4 Aug 2017 15:06:58 -0700 Subject: [PATCH] Ensure DesktopCapturers are destroyed when no longer needed. --- .../chrome/browser/media/desktop_media_list_observer.h | 3 +++ chromium_src/chrome/browser/media/native_desktop_media_list.cc | 3 +++ 2 files changed, 6 insertions(+) diff --git a/chromium_src/chrome/browser/media/desktop_media_list_observer.h b/chromium_src/chrome/browser/media/desktop_media_list_observer.h index 34cd626bf6bf..5df6f4f8b0e5 100644 --- a/chromium_src/chrome/browser/media/desktop_media_list_observer.h +++ b/chromium_src/chrome/browser/media/desktop_media_list_observer.h @@ -14,6 +14,9 @@ class DesktopMediaListObserver { virtual void OnSourceMoved(int old_index, int new_index) = 0; virtual void OnSourceNameChanged(int index) = 0; virtual void OnSourceThumbnailChanged(int index) = 0; + + // Return false to stop refreshing. The associated |DesktopMediaList| should + // no longer be used. virtual bool OnRefreshFinished() = 0; protected: diff --git a/chromium_src/chrome/browser/media/native_desktop_media_list.cc b/chromium_src/chrome/browser/media/native_desktop_media_list.cc index 4a9c0e03c8b0..f6a92a54942c 100644 --- a/chromium_src/chrome/browser/media/native_desktop_media_list.cc +++ b/chromium_src/chrome/browser/media/native_desktop_media_list.cc @@ -368,5 +368,8 @@ void NativeDesktopMediaList::OnRefreshFinished() { base::Bind(&NativeDesktopMediaList::Refresh, weak_factory_.GetWeakPtr()), update_period_); + } else { + // Destroy the capturers. + worker_.reset(); } }