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

Side by Side Diff: chrome/browser/task_manager/resource_provider.h

Issue 2197483003: Move the Mac Task Manager to the new backend code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mark Created 4 years, 4 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 2013 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_MANAGER_RESOURCE_PROVIDER_H_
6 #define CHROME_BROWSER_TASK_MANAGER_RESOURCE_PROVIDER_H_
7
8 #include <stddef.h>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/process/process_handle.h"
13 #include "base/strings/string16.h"
14 #include "third_party/WebKit/public/web/WebCache.h"
15
16 class PrefRegistrySimple;
17 class TaskManagerModel;
18
19 namespace content {
20 class WebContents;
21 }
22
23 namespace extensions {
24 class Extension;
25 }
26
27 namespace gfx {
28 class ImageSkia;
29 }
30
31 namespace task_manager {
32
33 #define TASKMANAGER_RESOURCE_TYPE_LIST(def) \
34 def(BROWSER) /* The main browser process. */ \
35 def(RENDERER) /* A normal WebContents renderer process. */ \
36 def(EXTENSION) /* An extension or app process. */ \
37 def(NOTIFICATION) /* A notification process. */ \
38 def(GUEST) /* A browser plugin guest process. */ \
39 def(PLUGIN) /* A plugin process. */ \
40 def(WORKER) /* A web worker process. */ \
41 def(NACL) /* A NativeClient loader or broker process. */ \
42 def(UTILITY) /* A browser utility process. */ \
43 def(ZYGOTE) /* A Linux zygote process. */ \
44 def(SANDBOX_HELPER) /* A sandbox helper process. */ \
45 def(GPU) /* A graphics process. */
46
47 #define TASKMANAGER_RESOURCE_TYPE_LIST_ENUM(a) a,
48 #define TASKMANAGER_RESOURCE_TYPE_LIST_AS_STRING(a) case a: return #a;
49
50 // A resource represents one row in the task manager.
51 // Resources from similar processes are grouped together by the task manager.
52 class Resource {
53 public:
54 virtual ~Resource() {}
55
56 enum Type {
57 UNKNOWN = 0,
58 TASKMANAGER_RESOURCE_TYPE_LIST(TASKMANAGER_RESOURCE_TYPE_LIST_ENUM)
59 };
60
61 virtual base::string16 GetTitle() const = 0;
62 virtual base::string16 GetProfileName() const = 0;
63 virtual gfx::ImageSkia GetIcon() const = 0;
64 virtual base::ProcessHandle GetProcess() const = 0;
65 virtual int GetUniqueChildProcessId() const = 0;
66 virtual Type GetType() const = 0;
67 virtual int GetRoutingID() const;
68
69 virtual bool ReportsCacheStats() const;
70 virtual blink::WebCache::ResourceTypeStats GetWebCoreCacheStats() const;
71
72 virtual bool ReportsSqliteMemoryUsed() const;
73 virtual size_t SqliteMemoryUsedBytes() const;
74
75 virtual bool ReportsV8MemoryStats() const;
76 virtual size_t GetV8MemoryAllocated() const;
77 virtual size_t GetV8MemoryUsed() const;
78
79 // A helper function for ActivateProcess when selected resource refers
80 // to a Tab or other window containing web contents. Returns NULL by
81 // default because not all resources have an associated web contents.
82 virtual content::WebContents* GetWebContents() const;
83
84 // Whether this resource does report the network usage accurately.
85 // This controls whether 0 or N/A is displayed when no bytes have been
86 // reported as being read. This is because some plugins do not report the
87 // bytes read and we don't want to display a misleading 0 value in that
88 // case.
89 virtual bool SupportNetworkUsage() const = 0;
90
91 // Called when some bytes have been read and support_network_usage returns
92 // false (meaning we do have network usage support).
93 virtual void SetSupportNetworkUsage() = 0;
94
95 // The TaskManagerModel periodically refreshes its data and call this
96 // on all live resources.
97 virtual void Refresh() {}
98
99 static const char* GetResourceTypeAsString(const Type type) {
100 switch (type) {
101 TASKMANAGER_RESOURCE_TYPE_LIST(TASKMANAGER_RESOURCE_TYPE_LIST_AS_STRING)
102 default: return "UNKNOWN";
103 }
104 }
105
106 protected:
107 Resource() {}
108
109 private:
110 DISALLOW_COPY_AND_ASSIGN(Resource);
111 };
112
113 #undef TASKMANAGER_RESOURCE_TYPE_LIST
114 #undef TASKMANAGER_RESOURCE_TYPE_LIST_ENUM
115 #undef TASKMANAGER_RESOURCE_TYPE_LIST_AS_STRING
116
117 // ResourceProviders are responsible for adding/removing resources to the task
118 // manager. The task manager notifies the ResourceProvider that it is ready
119 // to receive resource creation/termination notifications with a call to
120 // StartUpdating(). At that point, the resource provider should call
121 // AddResource with all the existing resources, and after that it should call
122 // AddResource/RemoveResource as resources are created/terminated.
123 // The provider remains the owner of the resource objects and is responsible
124 // for deleting them (when StopUpdating() is called).
125 // After StopUpdating() is called the provider should also stop reporting
126 // notifications to the task manager.
127 // Note: ResourceProviders have to be ref counted as they are used in
128 // MessageLoop::InvokeLater().
129 class ResourceProvider : public base::RefCountedThreadSafe<ResourceProvider> {
130 public:
131 // Should return the resource associated to the specified ids, or NULL if
132 // the resource does not belong to this provider.
133 virtual Resource* GetResource(int origin_pid,
134 int child_id,
135 int route_id) = 0;
136 virtual void StartUpdating() = 0;
137 virtual void StopUpdating() = 0;
138
139 protected:
140 friend class base::RefCountedThreadSafe<ResourceProvider>;
141
142 virtual ~ResourceProvider() {}
143 };
144
145 } // namespace task_manager
146
147 #endif // CHROME_BROWSER_TASK_MANAGER_RESOURCE_PROVIDER_H_
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/renderer_resource.cc ('k') | chrome/browser/task_manager/resource_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698