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. */ | |
Lei Zhang
2015/04/01 22:47:51
Is this a thing? I'm just curious what it is.
afakhry
2015/04/03 01:51:01
I think ncarter@ can answer this question better t
ncarter (slow)
2015/04/03 03:32:00
We can remove this. jam@ deleted the balloon notif
afakhry
2015/04/03 16:04:26
Done.
| |
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, | |
Lei Zhang
2015/04/01 22:47:51
Document parameters.
afakhry
2015/04/03 01:51:01
Done.
| |
41 const gfx::ImageSkia& icon, | |
Lei Zhang
2015/04/01 22:47:50
nit: indentation.
afakhry
2015/04/03 01:51:01
Done.
| |
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 | |
Lei Zhang
2015/04/01 22:47:51
What does this provide over process_handle() ?
afakhry
2015/04/03 01:51:01
It's totally different. As the comment says it's n
Lei Zhang
2015/04/03 02:39:37
Is the process host to not a 1:1 mapping with the
afakhry
2015/04/03 16:04:26
It is here for convenience indeed, we'll need this
| |
49 // is not the PID nor the handle of the process. | |
50 virtual int GetChildProcessUniqueID() const = 0; | |
Lei Zhang
2015/04/01 22:47:51
Is the browser a "child" process? Are all return v
afakhry
2015/04/03 01:51:01
In the case of the browser process, the return val
Lei Zhang
2015/04/03 02:39:37
Can you document this in the comments? What is the
afakhry
2015/04/03 16:04:26
Done.
| |
51 | |
52 virtual base::string16 GetProfileName() const; | |
Lei Zhang
2015/04/01 22:47:50
By making this and the following virtual methods c
Lei Zhang
2015/04/01 22:47:51
Can you clarify what "profile" means in this case?
afakhry
2015/04/03 01:51:01
I understand, in this case however this will only
afakhry
2015/04/03 01:51:01
Done.
| |
53 | |
54 virtual int GetRoutingID() const; | |
Lei Zhang
2015/04/01 22:47:51
What is the "routing id" exactly? There are severa
afakhry
2015/04/03 01:51:01
It's the routing ID of the render view host if thi
| |
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. | |
Lei Zhang
2015/04/01 22:47:51
Why can't the invalid value just be 0?
afakhry
2015/04/03 01:51:01
0 is a valid value for memory usage.
| |
58 virtual size_t GetSqliteMemoryUsed() const; | |
Lei Zhang
2015/04/01 22:47:51
Why do you have ReportsWebCacheStats(), but no Rep
afakhry
2015/04/03 01:51:01
In SqliteMemory we augmented this check in the ret
Lei Zhang
2015/04/03 02:39:37
So why not do ReportsFoo() / GetFoo() for all type
afakhry
2015/04/03 16:04:26
Done.
| |
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. | |
Lei Zhang
2015/04/01 22:47:51
Can you put Refresh() and OnBytesRead() on top? Ri
afakhry
2015/04/03 01:51:01
Done.
| |
71 // |update_interval| is the time since the last task manager refresh. | |
72 virtual void Refresh(const base::TimeDelta& update_interval); | |
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); | |
Lei Zhang
2015/04/01 22:47:50
Maybe OnNetworkBytesRead() ?
afakhry
2015/04/03 01:51:01
Done.
| |
78 | |
79 int64 network_usage() const { return network_usage_; } | |
Lei Zhang
2015/04/01 22:47:50
You should document these too. For example, is thi
afakhry
2015/04/03 01:51:00
I added comments to the fields which they get.
| |
80 int64 task_id() const { return task_id_; } | |
81 base::string16 title() const { return title_; } | |
Lei Zhang
2015/04/01 22:47:50
You can return a const base::string16& for the non
afakhry
2015/04/03 01:51:01
Done.
Lei Zhang
2015/04/03 02:39:37
Same goes for icon() and process_handle().
afakhry
2015/04/03 16:04:26
Done.
| |
82 gfx::ImageSkia icon() const { return icon_; } | |
83 base::ProcessHandle process_handle() const { return process_handle_; } | |
84 | |
85 private: | |
86 static int64 last_id_; | |
Lei Zhang
2015/04/01 22:47:51
Just put this in an anonymous namespace in the .cc
afakhry
2015/04/03 01:51:01
Done.
| |
87 | |
88 // This is the unique ID of this task. | |
89 int64 task_id_; | |
90 int64 network_usage_; | |
91 int64 current_byte_count_; | |
92 base::string16 title_; | |
Lei Zhang
2015/04/01 22:47:51
These never change, make them const?
afakhry
2015/04/03 01:51:01
Done.
Lei Zhang
2015/04/03 02:39:37
Can |title_| and |icon_| ever change?
ncarter (slow)
2015/04/03 04:09:03
Probably. A page can change its title (or favicon)
| |
93 gfx::ImageSkia icon_; | |
94 base::ProcessHandle process_handle_; | |
95 | |
96 DISALLOW_COPY_AND_ASSIGN(Task); | |
97 }; | |
98 | |
99 } // namespace task_management | |
100 | |
101 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_ | |
OLD | NEW |