summaryrefslogtreecommitdiff
path: root/chromium/ui/gl/progress_reporter.h
blob: 165283e052e76df4f755e875b9226303876cfbd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GL_PROGRESS_REPORTER_H_
#define UI_GL_PROGRESS_REPORTER_H_

namespace gl {

// ProgressReporter is used by ContextGroup and GrGLInterface to report when it
// is making forward progress in execution, delaying activation of the watchdog
// timeout.
class ProgressReporter {
 public:
  virtual ~ProgressReporter() = default;

  virtual void ReportProgress() = 0;
};

class ScopedProgressReporter {
 public:
  ScopedProgressReporter(ProgressReporter* progress_reporter)
      : progress_reporter_(progress_reporter) {
    if (progress_reporter_)
      progress_reporter_->ReportProgress();
  }
  ~ScopedProgressReporter() {
    if (progress_reporter_)
      progress_reporter_->ReportProgress();
  }

 private:
  ProgressReporter* progress_reporter_;
};

}  // namespace gl

#endif  // UI_GL_PROGRESS_REPORTER_H_