| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 // Returns true if this resource is not visible to the user because it lives | 125 // Returns true if this resource is not visible to the user because it lives |
| 126 // in the background (e.g. extension background page, background contents). | 126 // in the background (e.g. extension background page, background contents). |
| 127 virtual bool IsBackground() const { return false; } | 127 virtual bool IsBackground() const { return false; } |
| 128 | 128 |
| 129 static const char* GetResourceTypeAsString(const Type type) { | 129 static const char* GetResourceTypeAsString(const Type type) { |
| 130 switch (type) { | 130 switch (type) { |
| 131 TASKMANAGER_RESOURCE_TYPE_LIST(TASKMANAGER_RESOURCE_TYPE_LIST_AS_STRING) | 131 TASKMANAGER_RESOURCE_TYPE_LIST(TASKMANAGER_RESOURCE_TYPE_LIST_AS_STRING) |
| 132 default: return "UNKNOWN"; | 132 default: return "UNKNOWN"; |
| 133 } | 133 } |
| 134 }; | 134 } |
| 135 |
| 136 // Returns resource identifier that is unique within single task manager |
| 137 // session (between StartUpdating and StopUpdating). |
| 138 int get_unique_id() { return unique_id_; } |
| 139 protected: |
| 140 Resource() : unique_id_(0) {} |
| 141 |
| 142 private: |
| 143 friend class TaskManagerModel; |
| 144 int unique_id_; |
| 135 }; | 145 }; |
| 136 | 146 |
| 137 // ResourceProviders are responsible for adding/removing resources to the task | 147 // ResourceProviders are responsible for adding/removing resources to the task |
| 138 // manager. The task manager notifies the ResourceProvider that it is ready | 148 // manager. The task manager notifies the ResourceProvider that it is ready |
| 139 // to receive resource creation/termination notifications with a call to | 149 // to receive resource creation/termination notifications with a call to |
| 140 // StartUpdating(). At that point, the resource provider should call | 150 // StartUpdating(). At that point, the resource provider should call |
| 141 // AddResource with all the existing resources, and after that it should call | 151 // AddResource with all the existing resources, and after that it should call |
| 142 // AddResource/RemoveResource as resources are created/terminated. | 152 // AddResource/RemoveResource as resources are created/terminated. |
| 143 // The provider remains the owner of the resource objects and is responsible | 153 // The provider remains the owner of the resource objects and is responsible |
| 144 // for deleting them (when StopUpdating() is called). | 154 // for deleting them (when StopUpdating() is called). |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 265 |
| 256 // Returns number of registered resources. | 266 // Returns number of registered resources. |
| 257 int ResourceCount() const; | 267 int ResourceCount() const; |
| 258 // Returns number of registered groups. | 268 // Returns number of registered groups. |
| 259 int GroupCount() const; | 269 int GroupCount() const; |
| 260 | 270 |
| 261 // Methods to return raw resource information. | 271 // Methods to return raw resource information. |
| 262 int64 GetNetworkUsage(int index) const; | 272 int64 GetNetworkUsage(int index) const; |
| 263 double GetCPUUsage(int index) const; | 273 double GetCPUUsage(int index) const; |
| 264 int GetProcessId(int index) const; | 274 int GetProcessId(int index) const; |
| 275 int GetResourceUniqueId(int index) const; |
| 265 | 276 |
| 266 // Methods to return formatted resource information. | 277 // Methods to return formatted resource information. |
| 267 string16 GetResourceTitle(int index) const; | 278 string16 GetResourceTitle(int index) const; |
| 268 string16 GetResourceProfileName(int index) const; | 279 string16 GetResourceProfileName(int index) const; |
| 269 string16 GetResourceNetworkUsage(int index) const; | 280 string16 GetResourceNetworkUsage(int index) const; |
| 270 string16 GetResourceCPUUsage(int index) const; | 281 string16 GetResourceCPUUsage(int index) const; |
| 271 string16 GetResourcePrivateMemory(int index) const; | 282 string16 GetResourcePrivateMemory(int index) const; |
| 272 string16 GetResourceSharedMemory(int index) const; | 283 string16 GetResourceSharedMemory(int index) const; |
| 273 string16 GetResourcePhysicalMemory(int index) const; | 284 string16 GetResourcePhysicalMemory(int index) const; |
| 274 string16 GetResourceProcessId(int index) const; | 285 string16 GetResourceProcessId(int index) const; |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 // How many calls to StartUpdating have been made without matching calls to | 519 // How many calls to StartUpdating have been made without matching calls to |
| 509 // StopUpdating. | 520 // StopUpdating. |
| 510 int update_requests_; | 521 int update_requests_; |
| 511 | 522 |
| 512 // Whether we are currently in the process of updating. | 523 // Whether we are currently in the process of updating. |
| 513 UpdateState update_state_; | 524 UpdateState update_state_; |
| 514 | 525 |
| 515 // A salt lick for the goats. | 526 // A salt lick for the goats. |
| 516 int goat_salt_; | 527 int goat_salt_; |
| 517 | 528 |
| 529 // Resource identifier that is unique within single session. |
| 530 int last_unique_id_; |
| 531 |
| 518 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 532 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
| 519 }; | 533 }; |
| 520 | 534 |
| 521 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 535 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
| OLD | NEW |