OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/process/process_handle.h" | |
10 #include "base/strings/string16.h" | |
11 #include "base/time/time.h" | |
12 #include "third_party/WebKit/public/web/WebCache.h" | |
13 #include "ui/gfx/image/image_skia.h" | |
14 | |
15 namespace task_management { | |
16 | |
17 // 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 | |
19 // same process, in which case they're grouped together in the task manager | |
20 // table. See |task_management::TaskGroup| which represents a process possibly | |
21 // shared by multiple tasks. | |
22 class Task { | |
23 public: | |
24 enum Type { | |
25 UNKNOWN = 0, | |
26 BROWSER, /* The main browser process. */ | |
27 RENDERER, /* A normal WebContents renderer process. */ | |
28 EXTENSION, /* An extension or app process. */ | |
29 NOTIFICATION, /* A notification process. */ | |
30 GUEST, /* A browser plugin guest process. */ | |
31 PLUGIN, /* A plugin process. */ | |
32 WORKER, /* A web worker process. */ | |
33 NACL, /* A NativeClient loader or broker process. */ | |
34 UTILITY, /* A browser utility process. */ | |
35 ZYGOTE, /* A Linux zygote process. */ | |
36 SANDBOX_HELPER, /* A sandbox helper process. */ | |
37 GPU, /* A graphics process. */ | |
38 }; | |
39 | |
40 Task(const base::string16& title, | |
41 const gfx::ImageSkia& icon, | |
42 base::ProcessHandle handle); | |
43 virtual ~Task(); | |
44 | |
45 // Returns the task type. | |
46 virtual Type GetType() const = 0; | |
47 | |
48 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It | |
49 // is not the PID nor the handle of the process. | |
50 virtual int GetChildProcessUniqueID() const = 0; | |
51 | |
52 virtual base::string16 GetProfileName() const; | |
53 | |
54 virtual int GetRoutingID() const; | |
55 | |
56 // Returns the Sqlite used memory (in bytes). Not all tasks reports Sqlite | |
57 // memory, in this case a default invalid value of -1U will be returned. | |
58 virtual size_t GetSqliteMemoryUsed() const; | |
59 | |
60 // Returns the allocated and used V8 memory (in bytes). Not all tasks reports | |
61 // V8 memory, in this case a default invalid value of -1U will be returned. | |
62 virtual size_t GetV8MemoryAllocated() const; | |
63 virtual size_t GetV8MemoryUsed() const; | |
64 | |
65 // Checking if the task reports Webkit resource cache statistics and getting | |
66 // them if it does. | |
67 virtual bool ReportsWebCacheStats() const; | |
68 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; | |
69 | |
70 // Will be called to let the task refresh itself between refresh cycles. | |
71 // |update_duration| is the time since the last task manager refresh. | |
72 virtual void Refresh(const base::TimeDelta& update_duration); | |
73 | |
74 // Will receive this notification through the task manager from | |
75 // |ChromeNetworkDelegate::OnRawBytesRead()|. The task will add to the | |
76 // |current_byte_count_| in this refresh cycle. | |
77 void OnBytesRead(int64 bytes_read); | |
78 | |
79 int64 network_usage() const { return network_usage_; } | |
80 int64 task_id() const { return task_id_; } | |
81 base::string16 title() const { return title_; } | |
82 gfx::ImageSkia icon() const { return icon_; } | |
83 base::ProcessHandle process_handle() const { return process_handle_; } | |
84 bool is_first_in_group() const { return is_first_in_group_; } | |
85 void set_is_first_in_group(bool val) { is_first_in_group_ = val; } | |
ncarter (slow)
2015/03/31 22:31:32
Representing "first in group" as a bool member of
afakhry
2015/03/31 23:44:14
Done.
| |
86 | |
87 private: | |
88 static int64 last_id_; | |
89 | |
90 // This is the unique ID of this task. | |
91 int64 task_id_; | |
92 int64 network_usage_; | |
93 int64 current_byte_count_; | |
94 base::string16 title_; | |
95 gfx::ImageSkia icon_; | |
96 base::ProcessHandle process_handle_; | |
97 bool is_first_in_group_; | |
98 | |
99 DISALLOW_COPY_AND_ASSIGN(Task); | |
100 }; | |
101 | |
102 } // namespace task_management | |
103 | |
104 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | |
OLD | NEW |