OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/string16.h" | 18 #include "base/string16.h" |
19 #include "base/timer.h" | 19 #include "base/timer.h" |
20 #include "chrome/browser/renderer_host/web_cache_manager.h" | 20 #include "chrome/browser/renderer_host/web_cache_manager.h" |
| 21 #include "content/public/common/gpu_info.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCache.h" |
22 | 23 |
23 class TaskManagerModel; | 24 class TaskManagerModel; |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class ProcessMetrics; | 27 class ProcessMetrics; |
27 } | 28 } |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 class WebContents; | 31 class WebContents; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 string16 GetResourceProfileName(int index) const; | 306 string16 GetResourceProfileName(int index) const; |
306 string16 GetResourceNetworkUsage(int index) const; | 307 string16 GetResourceNetworkUsage(int index) const; |
307 string16 GetResourceCPUUsage(int index) const; | 308 string16 GetResourceCPUUsage(int index) const; |
308 string16 GetResourcePrivateMemory(int index) const; | 309 string16 GetResourcePrivateMemory(int index) const; |
309 string16 GetResourceSharedMemory(int index) const; | 310 string16 GetResourceSharedMemory(int index) const; |
310 string16 GetResourcePhysicalMemory(int index) const; | 311 string16 GetResourcePhysicalMemory(int index) const; |
311 string16 GetResourceProcessId(int index) const; | 312 string16 GetResourceProcessId(int index) const; |
312 string16 GetResourceWebCoreImageCacheSize(int index) const; | 313 string16 GetResourceWebCoreImageCacheSize(int index) const; |
313 string16 GetResourceWebCoreScriptsCacheSize(int index) const; | 314 string16 GetResourceWebCoreScriptsCacheSize(int index) const; |
314 string16 GetResourceWebCoreCSSCacheSize(int index) const; | 315 string16 GetResourceWebCoreCSSCacheSize(int index) const; |
| 316 string16 GetResourceVidmem(int index) const; |
315 string16 GetResourceFPS(int index) const; | 317 string16 GetResourceFPS(int index) const; |
316 string16 GetResourceSqliteMemoryUsed(int index) const; | 318 string16 GetResourceSqliteMemoryUsed(int index) const; |
317 string16 GetResourceGoatsTeleported(int index) const; | 319 string16 GetResourceGoatsTeleported(int index) const; |
318 string16 GetResourceV8MemoryAllocatedSize(int index) const; | 320 string16 GetResourceV8MemoryAllocatedSize(int index) const; |
319 | 321 |
320 // Gets the private memory (in bytes) that should be displayed for the passed | 322 // Gets the private memory (in bytes) that should be displayed for the passed |
321 // resource index. Caches the result since this calculation can take time on | 323 // resource index. Caches the result since this calculation can take time on |
322 // some platforms. | 324 // some platforms. |
323 bool GetPrivateMemory(int index, size_t* result) const; | 325 bool GetPrivateMemory(int index, size_t* result) const; |
324 | 326 |
325 // Gets the shared memory (in bytes) that should be displayed for the passed | 327 // Gets the shared memory (in bytes) that should be displayed for the passed |
326 // resource index. Caches the result since this calculation can take time on | 328 // resource index. Caches the result since this calculation can take time on |
327 // some platforms. | 329 // some platforms. |
328 bool GetSharedMemory(int index, size_t* result) const; | 330 bool GetSharedMemory(int index, size_t* result) const; |
329 | 331 |
330 // Gets the physical memory (in bytes) that should be displayed for the passed | 332 // Gets the physical memory (in bytes) that should be displayed for the passed |
331 // resource index. | 333 // resource index. |
332 bool GetPhysicalMemory(int index, size_t* result) const; | 334 bool GetPhysicalMemory(int index, size_t* result) const; |
333 | 335 |
334 // Gets the statuses of webkit. Return false if the resource for the given row | 336 // Gets the statuses of webkit. Return false if the resource for the given row |
335 // isn't a renderer. | 337 // isn't a renderer. |
336 bool GetWebCoreCacheStats(int index, | 338 bool GetWebCoreCacheStats(int index, |
337 WebKit::WebCache::ResourceTypeStats* result) const; | 339 WebKit::WebCache::ResourceTypeStats* result) const; |
338 | 340 |
| 341 // Gets the GPU memory allocated of the given page. |
| 342 bool GetVidmem(int index, size_t* vidmem, bool* has_duplicates) const; |
| 343 |
339 // Gets the fps of the given page. Return false if the resource for the given | 344 // Gets the fps of the given page. Return false if the resource for the given |
340 // row isn't a renderer. | 345 // row isn't a renderer. |
341 bool GetFPS(int index, float* result) const; | 346 bool GetFPS(int index, float* result) const; |
342 | 347 |
343 // Gets the sqlite memory (in byte). Return false if the resource for the | 348 // Gets the sqlite memory (in byte). Return false if the resource for the |
344 // given row doesn't report information. | 349 // given row doesn't report information. |
345 bool GetSqliteMemoryUsedBytes(int index, size_t* result) const; | 350 bool GetSqliteMemoryUsedBytes(int index, size_t* result) const; |
346 | 351 |
347 // Gets the amount of memory allocated for javascript. Returns false if the | 352 // Gets the amount of memory allocated for javascript. Returns false if the |
348 // resource for the given row isn't a renderer. | 353 // resource for the given row isn't a renderer. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 void ModelChanged(); | 435 void ModelChanged(); |
431 | 436 |
432 void NotifyResourceTypeStats( | 437 void NotifyResourceTypeStats( |
433 base::ProcessId renderer_id, | 438 base::ProcessId renderer_id, |
434 const WebKit::WebCache::ResourceTypeStats& stats); | 439 const WebKit::WebCache::ResourceTypeStats& stats); |
435 | 440 |
436 void NotifyFPS(base::ProcessId renderer_id, | 441 void NotifyFPS(base::ProcessId renderer_id, |
437 int routing_id, | 442 int routing_id, |
438 float fps); | 443 float fps); |
439 | 444 |
| 445 void NotifyVidmemUsageStats( |
| 446 const content::GPUVidmemUsageStats& vidmem_usage_stats); |
| 447 |
440 void NotifyV8HeapStats(base::ProcessId renderer_id, | 448 void NotifyV8HeapStats(base::ProcessId renderer_id, |
441 size_t v8_memory_allocated, | 449 size_t v8_memory_allocated, |
442 size_t v8_memory_used); | 450 size_t v8_memory_used); |
443 | 451 |
444 void NotifyBytesRead(const net::URLRequest& request, int bytes_read); | 452 void NotifyBytesRead(const net::URLRequest& request, int bytes_read); |
445 | 453 |
446 private: | 454 private: |
447 friend class base::RefCountedThreadSafe<TaskManagerModel>; | 455 friend class base::RefCountedThreadSafe<TaskManagerModel>; |
448 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); | 456 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); |
449 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); | 457 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 typedef std::map<base::ProcessHandle, base::ProcessMetrics*> MetricsMap; | 493 typedef std::map<base::ProcessHandle, base::ProcessMetrics*> MetricsMap; |
486 typedef std::map<base::ProcessHandle, double> CPUUsageMap; | 494 typedef std::map<base::ProcessHandle, double> CPUUsageMap; |
487 typedef std::map<TaskManager::Resource*, int64> ResourceValueMap; | 495 typedef std::map<TaskManager::Resource*, int64> ResourceValueMap; |
488 // Private memory in bytes, shared memory in bytes. | 496 // Private memory in bytes, shared memory in bytes. |
489 typedef std::pair<size_t, size_t> MemoryUsageEntry; | 497 typedef std::pair<size_t, size_t> MemoryUsageEntry; |
490 typedef std::map<base::ProcessHandle, MemoryUsageEntry> MemoryUsageMap; | 498 typedef std::map<base::ProcessHandle, MemoryUsageEntry> MemoryUsageMap; |
491 | 499 |
492 // Updates the values for all rows. | 500 // Updates the values for all rows. |
493 void Refresh(); | 501 void Refresh(); |
494 | 502 |
| 503 void RefreshVidmemUsageStats(); |
| 504 |
495 void AddItem(TaskManager::Resource* resource, bool notify_table); | 505 void AddItem(TaskManager::Resource* resource, bool notify_table); |
496 void RemoveItem(TaskManager::Resource* resource); | 506 void RemoveItem(TaskManager::Resource* resource); |
497 | 507 |
498 // Returns the network usage (in bytes per seconds) for the specified | 508 // Returns the network usage (in bytes per seconds) for the specified |
499 // resource. That's the value retrieved at the last timer's tick. | 509 // resource. That's the value retrieved at the last timer's tick. |
500 int64 GetNetworkUsageForResource(TaskManager::Resource* resource) const; | 510 int64 GetNetworkUsageForResource(TaskManager::Resource* resource) const; |
501 | 511 |
502 // Called on the UI thread when some bytes are read. | 512 // Called on the UI thread when some bytes are read. |
503 void BytesRead(BytesReadParam param); | 513 void BytesRead(BytesReadParam param); |
504 | 514 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 ResourceValueMap current_byte_count_map_; | 559 ResourceValueMap current_byte_count_map_; |
550 | 560 |
551 // A map that contains the network usage is displayed in the table, in bytes | 561 // A map that contains the network usage is displayed in the table, in bytes |
552 // per second. It is computed every time the timer ticks. The Resources are | 562 // per second. It is computed every time the timer ticks. The Resources are |
553 // owned by the ResourceProviders. | 563 // owned by the ResourceProviders. |
554 ResourceValueMap displayed_network_usage_map_; | 564 ResourceValueMap displayed_network_usage_map_; |
555 | 565 |
556 // A map that contains the CPU usage (in %) for a process since last refresh. | 566 // A map that contains the CPU usage (in %) for a process since last refresh. |
557 CPUUsageMap cpu_usage_map_; | 567 CPUUsageMap cpu_usage_map_; |
558 | 568 |
| 569 // A map that contains the video memory usage for a process |
| 570 content::GPUVidmemUsageStats vidmem_usage_stats_; |
| 571 bool pending_vidmem_usage_stats_update_; |
| 572 |
559 // A map that contains the private/shared memory usage of the process. We | 573 // A map that contains the private/shared memory usage of the process. We |
560 // cache this because the same APIs are called on linux and windows, and | 574 // cache this because the same APIs are called on linux and windows, and |
561 // because the linux call takes >10ms to complete. This cache is cleared on | 575 // because the linux call takes >10ms to complete. This cache is cleared on |
562 // every Refresh(). | 576 // every Refresh(). |
563 mutable MemoryUsageMap memory_usage_map_; | 577 mutable MemoryUsageMap memory_usage_map_; |
564 | 578 |
565 ObserverList<TaskManagerModelObserver> observer_list_; | 579 ObserverList<TaskManagerModelObserver> observer_list_; |
566 | 580 |
567 // How many calls to StartUpdating have been made without matching calls to | 581 // How many calls to StartUpdating have been made without matching calls to |
568 // StopUpdating. | 582 // StopUpdating. |
569 int update_requests_; | 583 int update_requests_; |
570 | 584 |
571 // How many calls to StartListening have been made without matching calls to | 585 // How many calls to StartListening have been made without matching calls to |
572 // StopListening. | 586 // StopListening. |
573 int listen_requests_; | 587 int listen_requests_; |
574 | 588 |
575 // Whether we are currently in the process of updating. | 589 // Whether we are currently in the process of updating. |
576 UpdateState update_state_; | 590 UpdateState update_state_; |
577 | 591 |
578 // A salt lick for the goats. | 592 // A salt lick for the goats. |
579 uint64 goat_salt_; | 593 uint64 goat_salt_; |
580 | 594 |
581 // Resource identifier that is unique within single session. | 595 // Resource identifier that is unique within single session. |
582 int last_unique_id_; | 596 int last_unique_id_; |
583 | 597 |
584 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 598 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
585 }; | 599 }; |
586 | 600 |
587 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 601 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
OLD | NEW |