projector_session_impl.cc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2021 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. #include "ash/projector/model/projector_session_impl.h"
  5. #include "ash/projector/projector_metrics.h"
  6. namespace ash {
  7. ProjectorSessionImpl::ProjectorSessionImpl() = default;
  8. ProjectorSessionImpl::~ProjectorSessionImpl() = default;
  9. void ProjectorSessionImpl::Start(const std::string& storage_dir) {
  10. DCHECK(!active_);
  11. active_ = true;
  12. storage_dir_ = storage_dir;
  13. NotifySessionActiveStateChanged(active_);
  14. RecordCreationFlowMetrics(ProjectorCreationFlow::kSessionStarted);
  15. }
  16. void ProjectorSessionImpl::Stop() {
  17. DCHECK(active_);
  18. active_ = false;
  19. screencast_container_path_.reset();
  20. NotifySessionActiveStateChanged(active_);
  21. RecordCreationFlowMetrics(ProjectorCreationFlow::kSessionStopped);
  22. }
  23. void ProjectorSessionImpl::AddObserver(ProjectorSessionObserver* observer) {
  24. observers_.AddObserver(observer);
  25. }
  26. void ProjectorSessionImpl::RemoveObserver(ProjectorSessionObserver* observer) {
  27. observers_.RemoveObserver(observer);
  28. }
  29. void ProjectorSessionImpl::NotifySessionActiveStateChanged(bool active) {
  30. for (ProjectorSessionObserver& observer : observers_)
  31. observer.OnProjectorSessionActiveStateChanged(active);
  32. }
  33. } // namespace ash