Index: media/remoting/remoting_cdm_controller.cc |
diff --git a/media/gpu/avda_surface_tracker.cc b/media/remoting/remoting_cdm_controller.cc |
similarity index 27% |
copy from media/gpu/avda_surface_tracker.cc |
copy to media/remoting/remoting_cdm_controller.cc |
index 8638f5ce50af7ab2d30cf659c9404c7caa137474..73752188223177a1a9f21c46efc827a60df0c424 100644 |
--- a/media/gpu/avda_surface_tracker.cc |
+++ b/media/remoting/remoting_cdm_controller.cc |
@@ -2,48 +2,58 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "media/gpu/avda_surface_tracker.h" |
+#include "media/remoting/remoting_cdm_controller.h" |
-#include "base/callback.h" |
-#include "base/lazy_instance.h" |
+#include "base/bind.h" |
+#include "base/callback_helpers.h" |
+#include "base/logging.h" |
#include "base/threading/thread_checker.h" |
namespace media { |
-namespace { |
-static base::LazyInstance<AVDASurfaceTracker> g_lazy_instance = |
- LAZY_INSTANCE_INITIALIZER; |
+RemotingCdmController::RemotingCdmController( |
+ scoped_refptr<RemotingSourceImpl> remoting_source) |
+ : remoting_source_(std::move(remoting_source)) { |
+ remoting_source_->AddClient(this); |
} |
-AVDASurfaceTracker::AVDASurfaceTracker() {} |
+RemotingCdmController::~RemotingCdmController() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
-AVDASurfaceTracker::~AVDASurfaceTracker() {} |
+ remoting_source_->RemoveClient(this); |
+} |
-void AVDASurfaceTracker::RegisterOnDestroyingSurfaceCallback( |
- const OnDestroyingSurfaceCallback& cb) { |
+void RemotingCdmController::OnStarted(bool success) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- callbacks_.push_back(cb); |
+ |
+ DCHECK(!cdm_check_cb_.is_null()); |
+ base::ResetAndReturn(&cdm_check_cb_).Run(success); |
+ is_remoting_ = success; |
} |
-void AVDASurfaceTracker::UnregisterOnDestroyingSurfaceCallback( |
- const OnDestroyingSurfaceCallback& cb) { |
+void RemotingCdmController::OnSessionStateChanged() { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- for (auto it = callbacks_.begin(); it != callbacks_.end(); ++it) { |
- if (it->Equals(cb)) { |
- callbacks_.erase(it); |
- return; |
- } |
+ |
+ if (is_remoting_ && |
+ remoting_source_->state() == RemotingSessionState::SESSION_STOPPING) { |
+ remoting_source_->ShutDown(); |
+ is_remoting_ = false; |
} |
} |
-void AVDASurfaceTracker::NotifyDestroyingSurface(int surface_id) { |
+void RemotingCdmController::ShouldCreateRemotingCdm( |
+ const CdmCheckCallback& cb) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
- for (const auto& cb : callbacks_) |
- cb.Run(surface_id); |
-} |
+ DCHECK(!cb.is_null()); |
+ |
+ if (is_remoting_) { |
+ cb.Run(true); |
+ return; |
+ } |
-AVDASurfaceTracker* AVDASurfaceTracker::GetInstance() { |
- return g_lazy_instance.Pointer(); |
+ DCHECK(cdm_check_cb_.is_null()); |
+ cdm_check_cb_ = cb; |
+ remoting_source_->StartRemoting(this); |
} |
} // namespace media |