task_observer.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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 BASE_TASK_TASK_OBSERVER_H_
  5. #define BASE_TASK_TASK_OBSERVER_H_
  6. #include "base/base_export.h"
  7. #include "base/pending_task.h"
  8. namespace base {
  9. // A TaskObserver is an object that receives notifications about tasks being
  10. // processed on the thread it's associated with.
  11. //
  12. // NOTE: A TaskObserver implementation should be extremely fast!
  13. class BASE_EXPORT TaskObserver {
  14. public:
  15. // This method is called before processing a task.
  16. // |was_blocked_or_low_priority| indicates if the task was at some point in a
  17. // queue that was blocked or less important than "normal".
  18. virtual void WillProcessTask(const PendingTask& pending_task,
  19. bool was_blocked_or_low_priority) = 0;
  20. // This method is called after processing a task.
  21. virtual void DidProcessTask(const PendingTask& pending_task) = 0;
  22. protected:
  23. virtual ~TaskObserver() = default;
  24. };
  25. } // namespace base
  26. #endif // BASE_TASK_TASK_OBSERVER_H_