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" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "third_party/WebKit/public/web/WebCache.h" | 12 #include "third_party/WebKit/public/web/WebCache.h" |
13 #include "ui/gfx/image/image_skia.h" | 13 #include "ui/gfx/image/image_skia.h" |
14 | 14 |
| 15 class Profile; |
| 16 |
15 namespace task_management { | 17 namespace task_management { |
16 | 18 |
17 // Defines a task that corresponds to a tab, an app, an extension, ... etc. It | 19 // Defines a task that corresponds to a tab, an app, an extension, ... etc. It |
18 // represents one row in the task manager table. Multiple tasks can share the | 20 // represents one row in the task manager table. Multiple tasks can share the |
19 // same process, in which case they're grouped together in the task manager | 21 // same process, in which case they're grouped together in the task manager |
20 // table. See |task_management::TaskGroup| which represents a process possibly | 22 // table. See |task_management::TaskGroup| which represents a process possibly |
21 // shared by multiple tasks. | 23 // shared by multiple tasks. |
22 class Task { | 24 class Task { |
23 public: | 25 public: |
24 enum Type { | 26 enum Type { |
(...skipping 11 matching lines...) Expand all Loading... |
36 GPU, /* A graphics process. */ | 38 GPU, /* A graphics process. */ |
37 }; | 39 }; |
38 | 40 |
39 // Create a task with the given |title| and the given favicon |icon|. This | 41 // Create a task with the given |title| and the given favicon |icon|. This |
40 // task runs on a process whose handle is |handle|. | 42 // task runs on a process whose handle is |handle|. |
41 Task(const base::string16& title, | 43 Task(const base::string16& title, |
42 const gfx::ImageSkia* icon, | 44 const gfx::ImageSkia* icon, |
43 base::ProcessHandle handle); | 45 base::ProcessHandle handle); |
44 virtual ~Task(); | 46 virtual ~Task(); |
45 | 47 |
| 48 // Gets the name of the given |profile| from the ProfileInfoCache. |
| 49 static base::string16 GetProfileNameFromProfile(Profile* profile); |
| 50 |
46 // Activates this TaskManager's task by bringing its container to the front | 51 // Activates this TaskManager's task by bringing its container to the front |
47 // (if possible). | 52 // (if possible). |
48 virtual void Activate(); | 53 virtual void Activate(); |
49 | 54 |
50 // Will be called to let the task refresh itself between refresh cycles. | 55 // Will be called to let the task refresh itself between refresh cycles. |
51 // |update_interval| is the time since the last task manager refresh. | 56 // |update_interval| is the time since the last task manager refresh. |
52 // the |refresh_flags| indicate which resources should be calculated on each | 57 // the |refresh_flags| indicate which resources should be calculated on each |
53 // refresh. | 58 // refresh. |
54 virtual void Refresh(const base::TimeDelta& update_interval, | 59 virtual void Refresh(const base::TimeDelta& update_interval, |
55 int64 refresh_flags); | 60 int64 refresh_flags); |
56 | 61 |
57 // Will receive this notification through the task manager from | 62 // Will receive this notification through the task manager from |
58 // |ChromeNetworkDelegate::OnNetworkBytesReceived()|. The task will add to the | 63 // |ChromeNetworkDelegate::OnNetworkBytesReceived()|. The task will add to the |
59 // |current_byte_count_| in this refresh cycle. | 64 // |current_byte_count_| in this refresh cycle. |
60 void OnNetworkBytesRead(int64 bytes_read); | 65 void OnNetworkBytesRead(int64 bytes_read); |
61 | 66 |
62 // Returns the task type. | 67 // Returns the task type. |
63 virtual Type GetType() const = 0; | 68 virtual Type GetType() const = 0; |
64 | 69 |
65 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It | 70 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It |
66 // is not the PID nor the handle of the process. | 71 // is not the PID nor the handle of the process. |
67 // For a task that represents the browser process, the return value is 0. For | 72 // For a task that represents the browser process, the return value is 0. For |
68 // other tasks that represent renderers and other child processes, the return | 73 // other tasks that represent renderers and other child processes, the return |
69 // value is whatever unique IDs of their hosts in the browser process. | 74 // value is whatever unique IDs of their hosts in the browser process. |
70 virtual int GetChildProcessUniqueID() const = 0; | 75 virtual int GetChildProcessUniqueID() const = 0; |
71 | 76 |
72 // The name of the profile associated with the browser context of the render | 77 // The name of the profile owning this task. |
73 // view host that this task represents (if this task represents a renderer). | |
74 virtual base::string16 GetProfileName() const; | 78 virtual base::string16 GetProfileName() const; |
75 | 79 |
76 // Getting the Sqlite used memory (in bytes). Not all tasks reports Sqlite | 80 // Getting the Sqlite used memory (in bytes). Not all tasks reports Sqlite |
77 // memory, in this case a default invalid value of -1 will be returned. | 81 // memory, in this case a default invalid value of -1 will be returned. |
78 // Check for whether the task reports it or not first. | 82 // Check for whether the task reports it or not first. |
79 bool ReportsSqliteMemory() const; | 83 bool ReportsSqliteMemory() const; |
80 virtual int64 GetSqliteMemoryUsed() const; | 84 virtual int64 GetSqliteMemoryUsed() const; |
81 | 85 |
82 // Getting the allocated and used V8 memory (in bytes). Not all tasks reports | 86 // Getting the allocated and used V8 memory (in bytes). Not all tasks reports |
83 // V8 memory, in this case a default invalid value of -1 will be returned. | 87 // V8 memory, in this case a default invalid value of -1 will be returned. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 133 |
130 // The PID of the process on which this task is running. | 134 // The PID of the process on which this task is running. |
131 const base::ProcessId process_id_; | 135 const base::ProcessId process_id_; |
132 | 136 |
133 DISALLOW_COPY_AND_ASSIGN(Task); | 137 DISALLOW_COPY_AND_ASSIGN(Task); |
134 }; | 138 }; |
135 | 139 |
136 } // namespace task_management | 140 } // namespace task_management |
137 | 141 |
138 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | 142 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ |
OLD | NEW |