OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | 6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 PLUGIN, /* A plugin process. */ | 30 PLUGIN, /* A plugin process. */ |
31 WORKER, /* A web worker process. */ | 31 WORKER, /* A web worker process. */ |
32 NACL, /* A NativeClient loader or broker process. */ | 32 NACL, /* A NativeClient loader or broker process. */ |
33 UTILITY, /* A browser utility process. */ | 33 UTILITY, /* A browser utility process. */ |
34 ZYGOTE, /* A Linux zygote process. */ | 34 ZYGOTE, /* A Linux zygote process. */ |
35 SANDBOX_HELPER, /* A sandbox helper process. */ | 35 SANDBOX_HELPER, /* A sandbox helper process. */ |
36 GPU, /* A graphics process. */ | 36 GPU, /* A graphics process. */ |
37 }; | 37 }; |
38 | 38 |
39 // Create a task with the given |title| and the given favicon |icon|. This | 39 // Create a task with the given |title| and the given favicon |icon|. This |
40 // task runs on a process whose handle is |handle|. | 40 // task runs on a process whose handle is |handle|. |rappor_sample| is the |
| 41 // name of the sample to be recorded if this task needs to be reported by |
| 42 // Rappor. |
41 Task(const base::string16& title, | 43 Task(const base::string16& title, |
| 44 const std::string& rappor_sample, |
42 const gfx::ImageSkia* icon, | 45 const gfx::ImageSkia* icon, |
43 base::ProcessHandle handle); | 46 base::ProcessHandle handle); |
44 virtual ~Task(); | 47 virtual ~Task(); |
45 | 48 |
46 // Activates this TaskManager's task by bringing its container to the front | 49 // Activates this TaskManager's task by bringing its container to the front |
47 // (if possible). | 50 // (if possible). |
48 virtual void Activate(); | 51 virtual void Activate(); |
49 | 52 |
50 // Will be called to let the task refresh itself between refresh cycles. | 53 // Will be called to let the task refresh itself between refresh cycles. |
51 // |update_interval| is the time since the last task manager refresh. | 54 // |update_interval| is the time since the last task manager refresh. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // them if it does. | 93 // them if it does. |
91 virtual bool ReportsWebCacheStats() const; | 94 virtual bool ReportsWebCacheStats() const; |
92 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; | 95 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; |
93 | 96 |
94 // Checking whether the task reports network usage. | 97 // Checking whether the task reports network usage. |
95 bool ReportsNetworkUsage() const; | 98 bool ReportsNetworkUsage() const; |
96 | 99 |
97 int64 task_id() const { return task_id_; } | 100 int64 task_id() const { return task_id_; } |
98 int64 network_usage() const { return network_usage_; } | 101 int64 network_usage() const { return network_usage_; } |
99 const base::string16& title() const { return title_; } | 102 const base::string16& title() const { return title_; } |
| 103 const std::string& rappor_sample_name() const { return rappor_sample_name_; } |
100 const gfx::ImageSkia& icon() const { return icon_; } | 104 const gfx::ImageSkia& icon() const { return icon_; } |
101 const base::ProcessHandle& process_handle() const { return process_handle_; } | 105 const base::ProcessHandle& process_handle() const { return process_handle_; } |
102 const base::ProcessId& process_id() const { return process_id_; } | 106 const base::ProcessId& process_id() const { return process_id_; } |
103 | 107 |
104 protected: | 108 protected: |
105 void set_title(const base::string16& new_title) { title_ = new_title; } | 109 void set_title(const base::string16& new_title) { title_ = new_title; } |
| 110 void set_rappor_sample_name(const std::string& sample) { |
| 111 rappor_sample_name_ = sample; |
| 112 } |
106 void set_icon(const gfx::ImageSkia& new_icon) { icon_ = new_icon; } | 113 void set_icon(const gfx::ImageSkia& new_icon) { icon_ = new_icon; } |
107 | 114 |
108 private: | 115 private: |
109 // The unique ID of this task. | 116 // The unique ID of this task. |
110 const int64 task_id_; | 117 const int64 task_id_; |
111 | 118 |
112 // The task's network usage in the current refresh cycle measured in bytes per | 119 // The task's network usage in the current refresh cycle measured in bytes per |
113 // second. A value of -1 means this task doesn't report network usage data. | 120 // second. A value of -1 means this task doesn't report network usage data. |
114 int64 network_usage_; | 121 int64 network_usage_; |
115 | 122 |
116 // The current network bytes received by this task during the current refresh | 123 // The current network bytes received by this task during the current refresh |
117 // cycle. A value of -1 means this task has never been notified of any network | 124 // cycle. A value of -1 means this task has never been notified of any network |
118 // usage. | 125 // usage. |
119 int64 current_byte_count_; | 126 int64 current_byte_count_; |
120 | 127 |
121 // The title of the task. | 128 // The title of the task. |
122 base::string16 title_; | 129 base::string16 title_; |
123 | 130 |
| 131 // The name of the sample representing this task when a Rappor sample needs to |
| 132 // be recorded for it. |
| 133 std::string rappor_sample_name_; |
| 134 |
124 // The favicon. | 135 // The favicon. |
125 gfx::ImageSkia icon_; | 136 gfx::ImageSkia icon_; |
126 | 137 |
127 // The handle of the process on which this task is running. | 138 // The handle of the process on which this task is running. |
128 const base::ProcessHandle process_handle_; | 139 const base::ProcessHandle process_handle_; |
129 | 140 |
130 // The PID of the process on which this task is running. | 141 // The PID of the process on which this task is running. |
131 const base::ProcessId process_id_; | 142 const base::ProcessId process_id_; |
132 | 143 |
133 DISALLOW_COPY_AND_ASSIGN(Task); | 144 DISALLOW_COPY_AND_ASSIGN(Task); |
134 }; | 145 }; |
135 | 146 |
136 } // namespace task_management | 147 } // namespace task_management |
137 | 148 |
138 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | 149 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
OLD | NEW |