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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/android/android_overlay.h" 5 #include "media/base/android/android_overlay.h"
6 6
7 namespace media { 7 namespace media {
8 8
9 AndroidOverlay::AndroidOverlay() : weak_factory_(this) {}
10 AndroidOverlay::~AndroidOverlay() {}
11
12 void AndroidOverlay::AddSurfaceDestroyedCallback(
13 AndroidOverlayConfig::DestroyedCB cb) {
14 destruction_cbs_.push_back(std::move(cb));
15 }
16
17 void AndroidOverlay::RunSurfaceDestroyedCallbacks() {
18 if (destruction_cbs_.empty())
19 return;
20
21 // Move the list, in case it's modified during traversal.
22 std::list<AndroidOverlayConfig::DestroyedCB> cbs =
23 std::move(destruction_cbs_);
24
25 // Get a wp for |this|, in case it's destroyed during a callback.
26 base::WeakPtr<AndroidOverlay> wp = weak_factory_.GetWeakPtr();
27
28 for (auto& cb : cbs) {
29 std::move(cb).Run(this);
30 // If |this| has been deleted, then stop here.
31 if (!wp)
32 return;
33 }
34 }
35
9 } // namespace media 36 } // namespace media
OLDNEW
« 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