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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 public base::RefCountedThreadSafe<TaskManagerModel> { | 190 public base::RefCountedThreadSafe<TaskManagerModel> { |
191 public: | 191 public: |
192 explicit TaskManagerModel(TaskManager* task_manager); | 192 explicit TaskManagerModel(TaskManager* task_manager); |
193 | 193 |
194 void AddObserver(TaskManagerModelObserver* observer); | 194 void AddObserver(TaskManagerModelObserver* observer); |
195 void RemoveObserver(TaskManagerModelObserver* observer); | 195 void RemoveObserver(TaskManagerModelObserver* observer); |
196 | 196 |
197 // Returns number of registered resources. | 197 // Returns number of registered resources. |
198 int ResourceCount() const; | 198 int ResourceCount() const; |
199 | 199 |
| 200 // Methods to return raw resource information. |
| 201 int64 GetNetworkUsage(int index) const; |
| 202 double GetCPUUsage(int index) const; |
| 203 int GetProcessId(int index) const; |
| 204 |
200 // Methods to return formatted resource information. | 205 // Methods to return formatted resource information. |
201 string16 GetResourceTitle(int index) const; | 206 string16 GetResourceTitle(int index) const; |
202 string16 GetResourceNetworkUsage(int index) const; | 207 string16 GetResourceNetworkUsage(int index) const; |
203 string16 GetResourceCPUUsage(int index) const; | 208 string16 GetResourceCPUUsage(int index) const; |
204 string16 GetResourcePrivateMemory(int index) const; | 209 string16 GetResourcePrivateMemory(int index) const; |
205 string16 GetResourceSharedMemory(int index) const; | 210 string16 GetResourceSharedMemory(int index) const; |
206 string16 GetResourcePhysicalMemory(int index) const; | 211 string16 GetResourcePhysicalMemory(int index) const; |
207 string16 GetResourceProcessId(int index) const; | 212 string16 GetResourceProcessId(int index) const; |
208 string16 GetResourceWebCoreImageCacheSize(int index) const; | 213 string16 GetResourceWebCoreImageCacheSize(int index) const; |
209 string16 GetResourceWebCoreScriptsCacheSize(int index) const; | 214 string16 GetResourceWebCoreScriptsCacheSize(int index) const; |
210 string16 GetResourceWebCoreCSSCacheSize(int index) const; | 215 string16 GetResourceWebCoreCSSCacheSize(int index) const; |
211 string16 GetResourceSqliteMemoryUsed(int index) const; | 216 string16 GetResourceSqliteMemoryUsed(int index) const; |
212 string16 GetResourceGoatsTeleported(int index) const; | 217 string16 GetResourceGoatsTeleported(int index) const; |
213 string16 GetResourceV8MemoryAllocatedSize(int index) const; | 218 string16 GetResourceV8MemoryAllocatedSize(int index) const; |
214 | 219 |
| 220 // Gets the private memory (in bytes) that should be displayed for the passed |
| 221 // resource index. Caches the result since this calculation can take time on |
| 222 // some platforms. |
| 223 bool GetPrivateMemory(int index, size_t* result) const; |
| 224 |
| 225 // Gets the shared memory (in bytes) that should be displayed for the passed |
| 226 // resource index. Caches the result since this calculation can take time on |
| 227 // some platforms. |
| 228 bool GetSharedMemory(int index, size_t* result) const; |
| 229 |
| 230 // Gets the physical memory (in bytes) that should be displayed for the passed |
| 231 // resource index. |
| 232 bool GetPhysicalMemory(int index, size_t* result) const; |
| 233 |
| 234 // Gets the amount of memory allocated for javascript. Returns false if the |
| 235 // resource for the given row isn't a renderer. |
| 236 bool GetV8Memory(int index, size_t* result) const; |
| 237 |
| 238 // See design doc at http://go/at-teleporter for more information. |
| 239 int GetGoatsTeleported(int index) const; |
| 240 |
215 // Returns true if the resource is first in its group (resources | 241 // Returns true if the resource is first in its group (resources |
216 // rendered by the same process are groupped together). | 242 // rendered by the same process are groupped together). |
217 bool IsResourceFirstInGroup(int index) const; | 243 bool IsResourceFirstInGroup(int index) const; |
218 | 244 |
219 // Returns icon to be used for resource (for example a favicon). | 245 // Returns icon to be used for resource (for example a favicon). |
220 SkBitmap GetResourceIcon(int index) const; | 246 SkBitmap GetResourceIcon(int index) const; |
221 | 247 |
222 // Returns a pair (start, length) of the group range of resource. | 248 // Returns a pair (start, length) of the group range of resource. |
223 std::pair<int, int> GetGroupRangeForResource(int index) const; | 249 std::pair<int, int> GetGroupRangeForResource(int index) const; |
224 | 250 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 base::ProcessId renderer_id, | 284 base::ProcessId renderer_id, |
259 const WebKit::WebCache::ResourceTypeStats& stats); | 285 const WebKit::WebCache::ResourceTypeStats& stats); |
260 | 286 |
261 void NotifyV8HeapStats(base::ProcessId renderer_id, | 287 void NotifyV8HeapStats(base::ProcessId renderer_id, |
262 size_t v8_memory_allocated, | 288 size_t v8_memory_allocated, |
263 size_t v8_memory_used); | 289 size_t v8_memory_used); |
264 | 290 |
265 private: | 291 private: |
266 friend class base::RefCountedThreadSafe<TaskManagerModel>; | 292 friend class base::RefCountedThreadSafe<TaskManagerModel>; |
267 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); | 293 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); |
| 294 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); |
268 | 295 |
269 ~TaskManagerModel(); | 296 ~TaskManagerModel(); |
270 | 297 |
271 enum UpdateState { | 298 enum UpdateState { |
272 IDLE = 0, // Currently not updating. | 299 IDLE = 0, // Currently not updating. |
273 TASK_PENDING, // An update task is pending. | 300 TASK_PENDING, // An update task is pending. |
274 STOPPING // A update task is pending and it should stop the update. | 301 STOPPING // A update task is pending and it should stop the update. |
275 }; | 302 }; |
276 | 303 |
277 // This struct is used to exchange information between the io and ui threads. | 304 // This struct is used to exchange information between the io and ui threads. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 352 |
326 // Returns the network usage (in byte per second) that should be displayed for | 353 // Returns the network usage (in byte per second) that should be displayed for |
327 // the passed |resource|. -1 means the information is not available for that | 354 // the passed |resource|. -1 means the information is not available for that |
328 // resource. | 355 // resource. |
329 int64 GetNetworkUsage(TaskManager::Resource* resource) const; | 356 int64 GetNetworkUsage(TaskManager::Resource* resource) const; |
330 | 357 |
331 // Returns the CPU usage (in %) that should be displayed for the passed | 358 // Returns the CPU usage (in %) that should be displayed for the passed |
332 // |resource|. | 359 // |resource|. |
333 double GetCPUUsage(TaskManager::Resource* resource) const; | 360 double GetCPUUsage(TaskManager::Resource* resource) const; |
334 | 361 |
335 // Gets the private memory (in bytes) that should be displayed for the passed | |
336 // resource index. Caches the result since this calculation can take time on | |
337 // some platforms. | |
338 bool GetPrivateMemory(int index, size_t* result) const; | |
339 | |
340 // Gets the shared memory (in bytes) that should be displayed for the passed | |
341 // resource index. Caches the result since this calculation can take time on | |
342 // some platforms. | |
343 bool GetSharedMemory(int index, size_t* result) const; | |
344 | |
345 // Gets the physical memory (in bytes) that should be displayed for the passed | |
346 // resource index. | |
347 bool GetPhysicalMemory(int index, size_t* result) const; | |
348 | |
349 // Gets the amount of memory allocated for javascript. Returns false if the | |
350 // resource for the given row isn't a renderer. | |
351 bool GetV8Memory(int index, size_t* result) const; | |
352 | |
353 // See design doc at http://go/at-teleporter for more information. | |
354 int GetGoatsTeleported(int index) const; | |
355 | |
356 // Retrieves the ProcessMetrics for the resources at the specified row. | 362 // Retrieves the ProcessMetrics for the resources at the specified row. |
357 // Returns true if there was a ProcessMetrics available. | 363 // Returns true if there was a ProcessMetrics available. |
358 bool GetProcessMetricsForRow(int row, | 364 bool GetProcessMetricsForRow(int row, |
359 base::ProcessMetrics** proc_metrics) const; | 365 base::ProcessMetrics** proc_metrics) const; |
360 | 366 |
361 // Given a number, this function returns the formatted string that should be | 367 // Given a number, this function returns the formatted string that should be |
362 // displayed in the task manager's memory cell. | 368 // displayed in the task manager's memory cell. |
363 string16 GetMemCellText(int64 number) const; | 369 string16 GetMemCellText(int64 number) const; |
364 | 370 |
365 // Looks up the data for |handle| and puts it in the mutable cache | 371 // Looks up the data for |handle| and puts it in the mutable cache |
(...skipping 30 matching lines...) Expand all Loading... |
396 CPUUsageMap cpu_usage_map_; | 402 CPUUsageMap cpu_usage_map_; |
397 | 403 |
398 // A map that contains the private/shared memory usage of the process. We | 404 // A map that contains the private/shared memory usage of the process. We |
399 // cache this because the same APIs are called on linux and windows, and | 405 // cache this because the same APIs are called on linux and windows, and |
400 // because the linux call takes >10ms to complete. This cache is cleared on | 406 // because the linux call takes >10ms to complete. This cache is cleared on |
401 // every Refresh(). | 407 // every Refresh(). |
402 mutable MemoryUsageMap memory_usage_map_; | 408 mutable MemoryUsageMap memory_usage_map_; |
403 | 409 |
404 ObserverList<TaskManagerModelObserver> observer_list_; | 410 ObserverList<TaskManagerModelObserver> observer_list_; |
405 | 411 |
| 412 // How many calls to StartUpdating have been made without matching calls to |
| 413 // StopUpdating. |
| 414 int update_requests_; |
| 415 |
406 // Whether we are currently in the process of updating. | 416 // Whether we are currently in the process of updating. |
407 UpdateState update_state_; | 417 UpdateState update_state_; |
408 | 418 |
409 // A salt lick for the goats. | 419 // A salt lick for the goats. |
410 int goat_salt_; | 420 int goat_salt_; |
411 | 421 |
412 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 422 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
413 }; | 423 }; |
414 | 424 |
415 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 425 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
OLD | NEW |