OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 6 #define CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 virtual void SetSupportNetworkUsage() = 0; | 95 virtual void SetSupportNetworkUsage() = 0; |
96 | 96 |
97 // The TaskManagerModel periodically refreshes its data and call this | 97 // The TaskManagerModel periodically refreshes its data and call this |
98 // on all live resources. | 98 // on all live resources. |
99 virtual void Refresh() {} | 99 virtual void Refresh() {} |
100 | 100 |
101 virtual void NotifyResourceTypeStats( | 101 virtual void NotifyResourceTypeStats( |
102 const WebKit::WebCache::ResourceTypeStats& stats) {} | 102 const WebKit::WebCache::ResourceTypeStats& stats) {} |
103 virtual void NotifyV8HeapStats(size_t v8_memory_allocated, | 103 virtual void NotifyV8HeapStats(size_t v8_memory_allocated, |
104 size_t v8_memory_used) {} | 104 size_t v8_memory_used) {} |
105 | |
106 // Whether this resource is visible to the user or whether it lives in the | |
107 // background (e.g. extension background page, background contents). | |
Evan Stade
2010/11/15 03:54:00
this comment confuses me. Can you replace "whether
Andrew T Wilson (Slow)
2010/11/15 08:20:57
Done.
| |
108 virtual bool IsBackground() const { return false; } | |
105 }; | 109 }; |
106 | 110 |
107 // ResourceProviders are responsible for adding/removing resources to the task | 111 // ResourceProviders are responsible for adding/removing resources to the task |
108 // manager. The task manager notifies the ResourceProvider that it is ready | 112 // manager. The task manager notifies the ResourceProvider that it is ready |
109 // to receive resource creation/termination notifications with a call to | 113 // to receive resource creation/termination notifications with a call to |
110 // StartUpdating(). At that point, the resource provider should call | 114 // StartUpdating(). At that point, the resource provider should call |
111 // AddResource with all the existing resources, and after that it should call | 115 // AddResource with all the existing resources, and after that it should call |
112 // AddResource/RemoveResource as resources are created/terminated. | 116 // AddResource/RemoveResource as resources are created/terminated. |
113 // The provider remains the owner of the resource objects and is responsible | 117 // The provider remains the owner of the resource objects and is responsible |
114 // for deleting them (when StopUpdating() is called). | 118 // for deleting them (when StopUpdating() is called). |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 | 153 |
150 // These methods are invoked by the resource providers to add/remove resources | 154 // These methods are invoked by the resource providers to add/remove resources |
151 // to the Task Manager. Note that the resources are owned by the | 155 // to the Task Manager. Note that the resources are owned by the |
152 // ResourceProviders and are not valid after StopUpdating() has been called | 156 // ResourceProviders and are not valid after StopUpdating() has been called |
153 // on the ResourceProviders. | 157 // on the ResourceProviders. |
154 void AddResource(Resource* resource); | 158 void AddResource(Resource* resource); |
155 void RemoveResource(Resource* resource); | 159 void RemoveResource(Resource* resource); |
156 | 160 |
157 void OnWindowClosed(); | 161 void OnWindowClosed(); |
158 | 162 |
163 // Invoked when a change to a resource has occurred that should cause any | |
164 // observers to completely refresh themselves (for example, the creation of | |
165 // a background resource in a process). Results in all observers receiving | |
166 // OnModelChanged() events. | |
167 void ModelChanged(); | |
168 | |
159 // Returns the singleton instance (and initializes it if necessary). | 169 // Returns the singleton instance (and initializes it if necessary). |
160 static TaskManager* GetInstance(); | 170 static TaskManager* GetInstance(); |
161 | 171 |
162 TaskManagerModel* model() const { return model_.get(); } | 172 TaskManagerModel* model() const { return model_.get(); } |
163 | 173 |
164 void OpenAboutMemory(); | 174 void OpenAboutMemory(); |
165 | 175 |
166 private: | 176 private: |
167 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, Basic); | 177 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, Basic); |
168 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, Resources); | 178 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, Resources); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
252 // resource for the given row isn't a renderer. | 262 // resource for the given row isn't a renderer. |
253 bool GetV8Memory(int index, size_t* result) const; | 263 bool GetV8Memory(int index, size_t* result) const; |
254 | 264 |
255 // See design doc at http://go/at-teleporter for more information. | 265 // See design doc at http://go/at-teleporter for more information. |
256 int GetGoatsTeleported(int index) const; | 266 int GetGoatsTeleported(int index) const; |
257 | 267 |
258 // Returns true if the resource is first in its group (resources | 268 // Returns true if the resource is first in its group (resources |
259 // rendered by the same process are groupped together). | 269 // rendered by the same process are groupped together). |
260 bool IsResourceFirstInGroup(int index) const; | 270 bool IsResourceFirstInGroup(int index) const; |
261 | 271 |
272 // Returns true if the resource runs in the background (not visible to the | |
273 // user, e.g. extension background pages and BackgroundContents). | |
274 bool IsBackgroundResource(int index) const; | |
275 | |
262 // Returns icon to be used for resource (for example a favicon). | 276 // Returns icon to be used for resource (for example a favicon). |
263 SkBitmap GetResourceIcon(int index) const; | 277 SkBitmap GetResourceIcon(int index) const; |
264 | 278 |
265 // Returns a pair (start, length) of the group range of resource. | 279 // Returns a pair (start, length) of the group range of resource. |
266 std::pair<int, int> GetGroupRangeForResource(int index) const; | 280 std::pair<int, int> GetGroupRangeForResource(int index) const; |
267 | 281 |
268 // Compares values in column |col_id| and rows |row1|, |row2|. | 282 // Compares values in column |col_id| and rows |row1|, |row2|. |
269 // Returns -1 if value in |row1| is less than value in |row2|, | 283 // Returns -1 if value in |row1| is less than value in |row2|, |
270 // 0 if they are equal, and 1 otherwise. | 284 // 0 if they are equal, and 1 otherwise. |
271 int CompareValues(int row1, int row2, int col_id) const; | 285 int CompareValues(int row1, int row2, int col_id) const; |
(...skipping 21 matching lines...) Expand all Loading... | |
293 void RemoveResourceProvider(TaskManager::ResourceProvider* provider); | 307 void RemoveResourceProvider(TaskManager::ResourceProvider* provider); |
294 | 308 |
295 void AddResource(TaskManager::Resource* resource); | 309 void AddResource(TaskManager::Resource* resource); |
296 void RemoveResource(TaskManager::Resource* resource); | 310 void RemoveResource(TaskManager::Resource* resource); |
297 | 311 |
298 void StartUpdating(); | 312 void StartUpdating(); |
299 void StopUpdating(); | 313 void StopUpdating(); |
300 | 314 |
301 void Clear(); // Removes all items. | 315 void Clear(); // Removes all items. |
302 | 316 |
317 // Sends OnModelChanged() to all observers to inform them of significant | |
318 // changes to the model. | |
319 void ModelChanged(); | |
320 | |
303 void NotifyResourceTypeStats( | 321 void NotifyResourceTypeStats( |
304 base::ProcessId renderer_id, | 322 base::ProcessId renderer_id, |
305 const WebKit::WebCache::ResourceTypeStats& stats); | 323 const WebKit::WebCache::ResourceTypeStats& stats); |
306 | 324 |
307 void NotifyV8HeapStats(base::ProcessId renderer_id, | 325 void NotifyV8HeapStats(base::ProcessId renderer_id, |
308 size_t v8_memory_allocated, | 326 size_t v8_memory_allocated, |
309 size_t v8_memory_used); | 327 size_t v8_memory_used); |
310 | 328 |
311 private: | 329 private: |
312 friend class base::RefCountedThreadSafe<TaskManagerModel>; | 330 friend class base::RefCountedThreadSafe<TaskManagerModel>; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 // Whether we are currently in the process of updating. | 454 // Whether we are currently in the process of updating. |
437 UpdateState update_state_; | 455 UpdateState update_state_; |
438 | 456 |
439 // A salt lick for the goats. | 457 // A salt lick for the goats. |
440 int goat_salt_; | 458 int goat_salt_; |
441 | 459 |
442 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 460 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
443 }; | 461 }; |
444 | 462 |
445 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 463 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
OLD | NEW |