| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/common/gpu/media/avda_surface_tracker.h" |
| 6 |
| 7 #include "base/callback.h" |
| 8 #include "base/lazy_instance.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 namespace { |
| 13 static base::LazyInstance<AVDASurfaceTracker> g_lazy_instance = |
| 14 LAZY_INSTANCE_INITIALIZER; |
| 15 } |
| 16 |
| 17 AVDASurfaceTracker::AVDASurfaceTracker() {} |
| 18 |
| 19 AVDASurfaceTracker::~AVDASurfaceTracker() {} |
| 20 |
| 21 void AVDASurfaceTracker::RegisterOnDestroyingSurfaceCallback( |
| 22 const OnDestroyingSurfaceCallback& cb) { |
| 23 callbacks_.push_back(cb); |
| 24 } |
| 25 |
| 26 void AVDASurfaceTracker::UnregisterOnDestroyingSurfaceCallback( |
| 27 const OnDestroyingSurfaceCallback& cb) { |
| 28 for (auto it = callbacks_.begin(); it != callbacks_.end(); ++it) { |
| 29 if (it->Equals(cb)) { |
| 30 callbacks_.erase(it); |
| 31 return; |
| 32 } |
| 33 } |
| 34 } |
| 35 |
| 36 void AVDASurfaceTracker::NotifyDestroyingSurface(int surface_id) { |
| 37 for (const auto& cb : callbacks_) |
| 38 cb.Run(surface_id); |
| 39 } |
| 40 |
| 41 AVDASurfaceTracker* AVDASurfaceTracker::GetInstance() { |
| 42 return g_lazy_instance.Pointer(); |
| 43 } |
| 44 |
| 45 } // namespace content |
| OLD | NEW |