| 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 #include "base/threading/thread_checker.h" | |
| 10 | |
| 11 namespace content { | |
| 12 | |
| 13 namespace { | |
| 14 static base::LazyInstance<AVDASurfaceTracker> g_lazy_instance = | |
| 15 LAZY_INSTANCE_INITIALIZER; | |
| 16 } | |
| 17 | |
| 18 AVDASurfaceTracker::AVDASurfaceTracker() {} | |
| 19 | |
| 20 AVDASurfaceTracker::~AVDASurfaceTracker() {} | |
| 21 | |
| 22 void AVDASurfaceTracker::RegisterOnDestroyingSurfaceCallback( | |
| 23 const OnDestroyingSurfaceCallback& cb) { | |
| 24 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 25 callbacks_.push_back(cb); | |
| 26 } | |
| 27 | |
| 28 void AVDASurfaceTracker::UnregisterOnDestroyingSurfaceCallback( | |
| 29 const OnDestroyingSurfaceCallback& cb) { | |
| 30 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 31 for (auto it = callbacks_.begin(); it != callbacks_.end(); ++it) { | |
| 32 if (it->Equals(cb)) { | |
| 33 callbacks_.erase(it); | |
| 34 return; | |
| 35 } | |
| 36 } | |
| 37 } | |
| 38 | |
| 39 void AVDASurfaceTracker::NotifyDestroyingSurface(int surface_id) { | |
| 40 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 41 for (const auto& cb : callbacks_) | |
| 42 cb.Run(surface_id); | |
| 43 } | |
| 44 | |
| 45 AVDASurfaceTracker* AVDASurfaceTracker::GetInstance() { | |
| 46 return g_lazy_instance.Pointer(); | |
| 47 } | |
| 48 | |
| 49 } // namespace content | |
| OLD | NEW |