tracing_model.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2018 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. #ifndef ASH_SYSTEM_MODEL_TRACING_MODEL_H_
  5. #define ASH_SYSTEM_MODEL_TRACING_MODEL_H_
  6. #include "ash/ash_export.h"
  7. #include "base/observer_list.h"
  8. namespace ash {
  9. class ASH_EXPORT TracingObserver {
  10. public:
  11. virtual ~TracingObserver() {}
  12. // Notifies when tracing mode changes.
  13. virtual void OnTracingModeChanged() = 0;
  14. };
  15. // Model to store whether users enable performance tracing at chrome://slow.
  16. class ASH_EXPORT TracingModel {
  17. public:
  18. TracingModel();
  19. TracingModel(const TracingModel&) = delete;
  20. TracingModel& operator=(const TracingModel&) = delete;
  21. ~TracingModel();
  22. void AddObserver(TracingObserver* observer);
  23. void RemoveObserver(TracingObserver* observer);
  24. void SetIsTracing(bool is_tracing);
  25. bool is_tracing() const { return is_tracing_; }
  26. private:
  27. void NotifyChanged();
  28. // True if performance tracing is enabled.
  29. bool is_tracing_ = false;
  30. base::ObserverList<TracingObserver>::Unchecked observers_;
  31. };
  32. } // namespace ash
  33. #endif // ASH_SYSTEM_MODEL_TRACING_MODEL_H_