Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Side by Side Diff: chrome/browser/task_management/providers/task.h

Issue 1038033002: New Task Manager - Phase 1.1: Implement Browser Process Task Providing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Converting size_t's to int64's Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 GUEST, /* A browser plugin guest process. */
30 PLUGIN, /* A plugin process. */
31 WORKER, /* A web worker process. */
32 NACL, /* A NativeClient loader or broker process. */
33 UTILITY, /* A browser utility process. */
34 ZYGOTE, /* A Linux zygote process. */
35 SANDBOX_HELPER, /* A sandbox helper process. */
36 GPU, /* A graphics process. */
37 };
38
39 // Create a task with the given |title| and the given Fav |icon|. This task
40 // runs on a process whose handle is |handle|.
41 Task(const base::string16& title,
42 const gfx::ImageSkia& icon,
43 base::ProcessHandle handle);
44 virtual ~Task();
45
46 // Will be called to let the task refresh itself between refresh cycles.
47 // |update_interval| is the time since the last task manager refresh.
48 virtual void Refresh(const base::TimeDelta& update_interval);
49
50 // Will receive this notification through the task manager from
51 // |ChromeNetworkDelegate::OnRawBytesRead()|. The task will add to the
52 // |current_byte_count_| in this refresh cycle.
53 void OnNetworkBytesRead(int64 bytes_read);
54
55 // Returns the task type.
56 virtual Type GetType() const = 0;
57
58 // This is the unique ID of the BrowserChildProcessHost/RenderProcessHost. It
59 // is not the PID nor the handle of the process.
60 // For a task that represents the browser process, the return value is 0. For
61 // other tasks that represent renderers and other child processes, the return
62 // value is whatever unique IDs of their hosts in the browser process.
63 virtual int GetChildProcessUniqueID() const = 0;
64
65 // The name of the profile associated with the browser context of the render
66 // view host that this task represents (if this task represents a renderer).
67 virtual base::string16 GetProfileName() const;
68
69 // If this task represents a renderer process, this would the return the
70 // routing ID of the RenderViewHost, otherwise it will return 0.
71 virtual int GetRoutingID() const;
72
73 // Getting the Sqlite used memory (in bytes). Not all tasks reports Sqlite
74 // memory, in this case a default invalid value of -1 will be returned.
75 // Check for whether the task reports it or not first.
76 bool ReportsSqliteMemory() const;
77 virtual int64 GetSqliteMemoryUsed() const;
78
79 // Getting the allocated and used V8 memory (in bytes). Not all tasks reports
80 // V8 memory, in this case a default invalid value of -1 will be returned.
81 // Check for whether the task reports it or not first.
82 bool ReportsV8Memory() const;
83 virtual int64 GetV8MemoryAllocated() const;
84 virtual int64 GetV8MemoryUsed() const;
85
86 // Checking if the task reports Webkit resource cache statistics and getting
87 // them if it does.
88 virtual bool ReportsWebCacheStats() const;
89 virtual blink::WebCache::ResourceTypeStats GetWebCacheStats() const;
90
91 // Checking whether the task reports network usage.
92 bool ReportsNetworkUsage() const;
93
94 int64 task_id() const { return task_id_; }
95 int64 network_usage() const { return network_usage_; }
96 const base::string16& title() const { return title_; }
97 const gfx::ImageSkia& icon() const { return icon_; }
98 const base::ProcessHandle& process_handle() const { return process_handle_; }
99
100 private:
101 // The unique ID of this task.
102 const int64 task_id_;
103
104 // The task's network usage in the current refresh cycle measured in bytes per
105 // second. A value of -1 means this task doesn't report network usage data.
106 int64 network_usage_;
107
108 // The current network bytes received by this task during the current refresh
109 // cycle. A value of -1 means this task has never been notified of any network
110 // usage.
111 int64 current_byte_count_;
112
113 // The title of the task.
114 base::string16 title_;
115
116 // The Fav icon.
117 gfx::ImageSkia icon_;
118
119 // The handle of the process on which this task is running.
120 const base::ProcessHandle process_handle_;
121
122 DISALLOW_COPY_AND_ASSIGN(Task);
123 };
124
125 } // namespace task_management
126
127 #endif // CHROME_BROWSER_TASK_MANAGEMENT_PROVIDERS_TASK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698