xref: /aosp_15_r20/external/cronet/base/task/task_observer.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef BASE_TASK_TASK_OBSERVER_H_
6 #define BASE_TASK_TASK_OBSERVER_H_
7 
8 #include "base/base_export.h"
9 #include "base/pending_task.h"
10 
11 namespace base {
12 
13 // A TaskObserver is an object that receives notifications about tasks being
14 // processed on the thread it's associated with.
15 //
16 // NOTE: A TaskObserver implementation should be extremely fast!
17 
18 class BASE_EXPORT TaskObserver {
19  public:
20   // This method is called before processing a task.
21   // |was_blocked_or_low_priority| indicates if the task was at some point in a
22   // queue that was blocked or less important than "normal".
23   virtual void WillProcessTask(const PendingTask& pending_task,
24                                bool was_blocked_or_low_priority) = 0;
25 
26   // This method is called after processing a task.
27   virtual void DidProcessTask(const PendingTask& pending_task) = 0;
28 
29  protected:
30   virtual ~TaskObserver() = default;
31 };
32 
33 }  // namespace base
34 
35 #endif  // BASE_TASK_TASK_OBSERVER_H_
36