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_PRIVATE_TASKS_PROVIDERS_TASK_H_ | |
6 #define CHROME_BROWSER_TASK_MANAGEMENT_PRIVATE_TASKS_PROVIDERS_TASK_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/macros.h" | |
10 #include "base/memory/ref_counted.h" | |
11 #include "base/process/process_handle.h" | |
12 #include "base/strings/string16.h" | |
13 #include "base/time/time.h" | |
14 #include "third_party/WebKit/public/web/WebCache.h" | |
15 #include "ui/gfx/image/image_skia.h" | |
16 | |
17 namespace task_management { | |
18 | |
19 // Defines a task that corresponds to a tab, an app, an extension, ... etc. It | |
20 // represents one row in the task manager table. multiple tasks can share the | |
ncarter (slow)
2015/03/27 18:16:21
multiple -> Multiple
afakhry
2015/03/31 00:19:20
Done.
| |
21 // same process, in which case they're grouped together in the task manager | |
22 // table. See |task_management::TaskGroup| which represents a process possibly | |
ncarter (slow)
2015/03/27 18:16:22
TaskGroup doesn't exist right now.
afakhry
2015/03/31 00:19:20
I know but it will. Do you want me to remove that
| |
23 // shared by multiple tasks. | |
24 // | |
25 // A Task is RefCountedThreadSafe and hence refrences have to be scoped_refptr. | |
ncarter (slow)
2015/03/27 18:16:22
"refrences" typo
afakhry
2015/03/31 00:19:20
Done.
| |
26 class Task : public base::RefCountedThreadSafe<Task> { | |
ncarter (slow)
2015/03/27 18:16:21
What lifetime problem does reference counting solv
afakhry
2015/03/31 00:19:20
Removed as agreed.
| |
27 public: | |
28 enum Type { | |
29 UNKNOWN = 0, | |
30 BROWSER, /* The main browser process. */ | |
31 RENDERER, /* A normal WebContents renderer process. */ | |
32 EXTENSION, /* An extension or app process. */ | |
33 NOTIFICATION, /* A notification process. */ | |
34 GUEST, /* A browser plugin guest process. */ | |
35 PLUGIN, /* A plugin process. */ | |
36 WORKER, /* A web worker process. */ | |
37 NACL, /* A NativeClient loader or broker process. */ | |
38 UTILITY, /* A browser utility process. */ | |
39 ZYGOTE, /* A Linux zygote process. */ | |
40 SANDBOX_HELPER, /* A sandbox helper process. */ | |
41 GPU, /* A graphics process. */ | |
42 }; | |
43 | |
44 virtual Type GetType() const = 0; | |
45 | |
46 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It | |
47 // is not the PID nor the handle of the process. | |
48 virtual int GetChildProcessUniqueID() const = 0; | |
49 | |
50 virtual base::string16 GetProfileName() const; | |
51 | |
52 virtual int GetRoutingID() const; | |
53 | |
54 // Returns the Sqlite used memory (in bytes). Not all tasks reports Sqlite | |
55 // memory, in this case a default invalid value of -1U will be returned. | |
56 virtual size_t GetSqliteMemoryUsed() const; | |
57 | |
58 // Returns the allocated and used V8 memory (in bytes). Not all tasks reports | |
59 // V8 memory, in this case a default invalid value of -1U will be returned. | |
60 virtual size_t GetV8MemoryAllocated() const; | |
61 virtual size_t GetV8MemoryUsed() const; | |
62 | |
63 virtual bool ReportsWebCacheStats() const; | |
64 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const; | |
ncarter (slow)
2015/03/27 18:16:22
These merit a comment.
afakhry
2015/03/31 00:19:20
Done.
| |
65 | |
66 // Will be called to let the task refresh itself between refresh cycles. | |
67 // |update_time| is the time since the last task manager refresh. | |
68 virtual void Refresh(const base::TimeDelta& update_time); | |
69 | |
70 // Will receive this notification through the task manager from | |
71 // |ChromeNetworkDelegate::OnRawBytesRead()|. The task will add to the | |
72 // |current_byte_count_| in this refresh cycle. | |
73 void OnBytesRead(int64 bytes_read); | |
74 | |
75 int64 network_usage() const { return network_usage_; } | |
76 size_t task_id() const { return task_id_; } | |
77 base::string16 title() const { return title_; } | |
78 gfx::ImageSkia icon() const { return icon_; } | |
79 base::ProcessHandle process_handle() const { return process_handle_; } | |
80 bool is_first_in_group() const { return is_first_in_group_; } | |
81 void set_is_first_in_group(bool val) { is_first_in_group_ = val; } | |
82 | |
83 protected: | |
ncarter (slow)
2015/03/27 18:16:21
public:, protected: and private: declarations get
afakhry
2015/03/31 00:19:20
Yes I know that. I'm not sure why they weren't for
| |
84 friend class base::RefCountedThreadSafe<Task>; | |
85 | |
86 Task(const base::string16& title, | |
87 const gfx::ImageSkia& icon, | |
88 base::ProcessHandle handle); | |
89 virtual ~Task(); | |
90 | |
91 // ---------------------------------------------------------------------- | |
92 // Fields: | |
93 // ---------------------------------------------------------------------- | |
ncarter (slow)
2015/03/27 18:16:22
Not needed.
| |
94 int64 network_usage_; | |
95 int64 current_byte_count_; | |
96 size_t task_id_; | |
ncarter (slow)
2015/03/27 18:16:21
It is encouraged (but not required) to comment you
| |
97 base::string16 title_; | |
98 gfx::ImageSkia icon_; | |
99 base::ProcessHandle process_handle_; | |
100 bool is_first_in_group_; | |
ncarter (slow)
2015/03/27 18:16:21
These data members should all be private. Derived
afakhry
2015/03/31 00:19:20
Done.
| |
101 | |
102 private: | |
103 static size_t last_id_; | |
ncarter (slow)
2015/03/27 18:16:22
This approach (a static ID) means that tasks can o
| |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(Task); | |
106 }; | |
107 | |
108 } // namespace task_management | |
109 | |
110 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PRIVATE_TASKS_PROVIDERS_TASK_H_ | |
OLD | NEW |