[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / task_management / task_manager_observer.h
blob1dc9d84bd181aad7e2e9c5fb24d08f0f3e06b2fb
1 // Copyright 2015 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.
5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_OBSERVER_H_
6 #define CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_OBSERVER_H_
8 #include <vector>
10 #include "base/time/time.h"
12 namespace task_management {
14 typedef int64 TaskId;
15 typedef std::vector<TaskId> TaskIdList;
17 // Defines a list of types of resources that an observer needs to be refreshed
18 // on every task manager refresh cycle.
19 enum RefreshType {
20 REFRESH_TYPE_CPU = 1,
21 REFRESH_TYPE_MEMORY = 1 << 1,
22 REFRESH_TYPE_GPU_MEMORY = 1 << 2,
23 REFRESH_TYPE_V8_MEMORY = 1 << 3,
24 REFRESH_TYPE_SQLITE_MEMORY = 1 << 4,
25 REFRESH_TYPE_WEBCACHE_STATS = 1 << 5,
26 REFRESH_TYPE_NETWORK_USAGE = 1 << 6,
27 REFRESH_TYPE_NACL = 1 << 7,
28 REFRESH_TYPE_IDLE_WAKEUPS = 1 << 8,
29 REFRESH_TYPE_HANDLES = 1 << 9,
32 // Defines the interface for observers of the task manager.
33 class TaskManagerObserver {
34 public:
35 // Constructs a TaskManagerObserver given the minimum |refresh_time| that it
36 // it requires the task manager to be refreshing the values at, along with the
37 // |resources_flags| that it needs to be calculated on each refresh cycle of
38 // the task manager (use the above flags in |ResourceType|).
40 // Notes:
41 // 1- The task manager will refresh at least once every |refresh_time| as
42 // long as this observer is added to it. There might be other observers that
43 // require more frequent refreshes.
44 // 2- Refresh time values less than 1 second will be considered as 1 second.
45 // 3- Depending on the other observers, the task manager may refresh more
46 // resources than those defined in |resources_flags|.
47 // 4- Upon the removal of the observer from the task manager, the task manager
48 // will update its refresh time and the calculated resources to be the minimum
49 // required value of all the remaining observers.
50 TaskManagerObserver(base::TimeDelta refresh_time, int64 resources_flags);
51 virtual ~TaskManagerObserver();
53 // Notifies the observer that a chrome task with |id| has started and the task
54 // manager is now monitoring it. The resource usage of this newly-added task
55 // will remain invalid until the next refresh cycle of the task manager.
56 virtual void OnTaskAdded(TaskId id) = 0;
58 // Notifies the observer that a chrome task with |id| is about to be destroyed
59 // and removed from the task manager right after this call. Observers which
60 // are interested in doing some calculations related to the resource usage of
61 // this task upon its removal may do so inside this call.
62 virtual void OnTaskToBeRemoved(TaskId id) = 0;
64 // Notifies the observer that the task manager has just finished a refresh
65 // cycle to calculate the resources usage of all tasks.
66 virtual void OnTasksRefreshed(const TaskIdList& task_ids) = 0;
68 const base::TimeDelta& desired_refresh_time() const {
69 return desired_refresh_time_;
72 int64 desired_resources_flags() const { return desired_resources_flags_; }
74 private:
75 // The minimum update time of the task manager that this observer needs to
76 // do its job.
77 base::TimeDelta desired_refresh_time_;
79 // The flags that contain the resources that this observer needs to be
80 // calculated on each refresh.
81 int64 desired_resources_flags_;
83 DISALLOW_COPY_AND_ASSIGN(TaskManagerObserver);
86 } // namespace task_management
89 #endif // CHROME_BROWSER_TASK_MANAGEMENT_TASK_MANAGER_OBSERVER_H_