progress_reporter.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 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. #ifndef UI_GL_PROGRESS_REPORTER_H_
  5. #define UI_GL_PROGRESS_REPORTER_H_
  6. #include "base/memory/raw_ptr.h"
  7. namespace gl {
  8. // ProgressReporter is used by ContextGroup and GrGLInterface to report when it
  9. // is making forward progress in execution, delaying activation of the watchdog
  10. // timeout.
  11. class ProgressReporter {
  12. public:
  13. virtual ~ProgressReporter() = default;
  14. virtual void ReportProgress() = 0;
  15. };
  16. class ScopedProgressReporter {
  17. public:
  18. ScopedProgressReporter(ProgressReporter* progress_reporter)
  19. : progress_reporter_(progress_reporter) {
  20. if (progress_reporter_)
  21. progress_reporter_->ReportProgress();
  22. }
  23. ~ScopedProgressReporter() {
  24. if (progress_reporter_)
  25. progress_reporter_->ReportProgress();
  26. }
  27. private:
  28. raw_ptr<ProgressReporter> progress_reporter_;
  29. };
  30. } // namespace gl
  31. #endif // UI_GL_PROGRESS_REPORTER_H_