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

Unified Diff: media/base/android/android_overlay.cc

Issue 2883913003: Add multiple destruction callbacks to AndroidOverlay. (Closed)
Patch Set: rebased.... though i got not conflicts? Created 3 years, 7 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 | « media/base/android/android_overlay.h ('k') | media/base/android/mock_android_overlay.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/android_overlay.cc
diff --git a/media/base/android/android_overlay.cc b/media/base/android/android_overlay.cc
index 53fe296681f1ad9d422591c8f72994e3433aefc7..e24c39c44e431ce0601125c6c07adb21baadd006 100644
--- a/media/base/android/android_overlay.cc
+++ b/media/base/android/android_overlay.cc
@@ -6,4 +6,31 @@
namespace media {
+AndroidOverlay::AndroidOverlay() : weak_factory_(this) {}
+AndroidOverlay::~AndroidOverlay() {}
+
+void AndroidOverlay::AddSurfaceDestroyedCallback(
+ AndroidOverlayConfig::DestroyedCB cb) {
+ destruction_cbs_.push_back(std::move(cb));
+}
+
+void AndroidOverlay::RunSurfaceDestroyedCallbacks() {
+ if (destruction_cbs_.empty())
+ return;
+
+ // Move the list, in case it's modified during traversal.
+ std::list<AndroidOverlayConfig::DestroyedCB> cbs =
+ std::move(destruction_cbs_);
+
+ // Get a wp for |this|, in case it's destroyed during a callback.
+ base::WeakPtr<AndroidOverlay> wp = weak_factory_.GetWeakPtr();
+
+ for (auto& cb : cbs) {
+ std::move(cb).Run(this);
+ // If |this| has been deleted, then stop here.
+ if (!wp)
+ return;
+ }
+}
+
} // namespace media
« no previous file with comments | « media/base/android/android_overlay.h ('k') | media/base/android/mock_android_overlay.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698