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_memory_stats.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 GetResourceVideoMemory(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 GetVideoMemory(int index, |
| 343 size_t* video_memory, |
| 344 bool* has_duplicates) const; |
| 345 |
339 // Gets the fps of the given page. Return false if the resource for the given | 346 // Gets the fps of the given page. Return false if the resource for the given |
340 // row isn't a renderer. | 347 // row isn't a renderer. |
341 bool GetFPS(int index, float* result) const; | 348 bool GetFPS(int index, float* result) const; |
342 | 349 |
343 // Gets the sqlite memory (in byte). Return false if the resource for the | 350 // Gets the sqlite memory (in byte). Return false if the resource for the |
344 // given row doesn't report information. | 351 // given row doesn't report information. |
345 bool GetSqliteMemoryUsedBytes(int index, size_t* result) const; | 352 bool GetSqliteMemoryUsedBytes(int index, size_t* result) const; |
346 | 353 |
347 // Gets the amount of memory allocated for javascript. Returns false if the | 354 // Gets the amount of memory allocated for javascript. Returns false if the |
348 // resource for the given row isn't a renderer. | 355 // 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(); | 437 void ModelChanged(); |
431 | 438 |
432 void NotifyResourceTypeStats( | 439 void NotifyResourceTypeStats( |
433 base::ProcessId renderer_id, | 440 base::ProcessId renderer_id, |
434 const WebKit::WebCache::ResourceTypeStats& stats); | 441 const WebKit::WebCache::ResourceTypeStats& stats); |
435 | 442 |
436 void NotifyFPS(base::ProcessId renderer_id, | 443 void NotifyFPS(base::ProcessId renderer_id, |
437 int routing_id, | 444 int routing_id, |
438 float fps); | 445 float fps); |
439 | 446 |
| 447 void NotifyVideoMemoryUsageStats( |
| 448 const content::GPUVideoMemoryUsageStats& video_memory_usage_stats); |
| 449 |
440 void NotifyV8HeapStats(base::ProcessId renderer_id, | 450 void NotifyV8HeapStats(base::ProcessId renderer_id, |
441 size_t v8_memory_allocated, | 451 size_t v8_memory_allocated, |
442 size_t v8_memory_used); | 452 size_t v8_memory_used); |
443 | 453 |
444 void NotifyBytesRead(const net::URLRequest& request, int bytes_read); | 454 void NotifyBytesRead(const net::URLRequest& request, int bytes_read); |
445 | 455 |
446 private: | 456 private: |
447 friend class base::RefCountedThreadSafe<TaskManagerModel>; | 457 friend class base::RefCountedThreadSafe<TaskManagerModel>; |
448 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); | 458 FRIEND_TEST_ALL_PREFIXES(TaskManagerTest, RefreshCalled); |
449 FRIEND_TEST_ALL_PREFIXES(ExtensionApiTest, ProcessesVsTaskManager); | 459 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; | 495 typedef std::map<base::ProcessHandle, base::ProcessMetrics*> MetricsMap; |
486 typedef std::map<base::ProcessHandle, double> CPUUsageMap; | 496 typedef std::map<base::ProcessHandle, double> CPUUsageMap; |
487 typedef std::map<TaskManager::Resource*, int64> ResourceValueMap; | 497 typedef std::map<TaskManager::Resource*, int64> ResourceValueMap; |
488 // Private memory in bytes, shared memory in bytes. | 498 // Private memory in bytes, shared memory in bytes. |
489 typedef std::pair<size_t, size_t> MemoryUsageEntry; | 499 typedef std::pair<size_t, size_t> MemoryUsageEntry; |
490 typedef std::map<base::ProcessHandle, MemoryUsageEntry> MemoryUsageMap; | 500 typedef std::map<base::ProcessHandle, MemoryUsageEntry> MemoryUsageMap; |
491 | 501 |
492 // Updates the values for all rows. | 502 // Updates the values for all rows. |
493 void Refresh(); | 503 void Refresh(); |
494 | 504 |
| 505 void RefreshVideoMemoryUsageStats(); |
| 506 |
495 void AddItem(TaskManager::Resource* resource, bool notify_table); | 507 void AddItem(TaskManager::Resource* resource, bool notify_table); |
496 void RemoveItem(TaskManager::Resource* resource); | 508 void RemoveItem(TaskManager::Resource* resource); |
497 | 509 |
498 // Returns the network usage (in bytes per seconds) for the specified | 510 // Returns the network usage (in bytes per seconds) for the specified |
499 // resource. That's the value retrieved at the last timer's tick. | 511 // resource. That's the value retrieved at the last timer's tick. |
500 int64 GetNetworkUsageForResource(TaskManager::Resource* resource) const; | 512 int64 GetNetworkUsageForResource(TaskManager::Resource* resource) const; |
501 | 513 |
502 // Called on the UI thread when some bytes are read. | 514 // Called on the UI thread when some bytes are read. |
503 void BytesRead(BytesReadParam param); | 515 void BytesRead(BytesReadParam param); |
504 | 516 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 ResourceValueMap current_byte_count_map_; | 561 ResourceValueMap current_byte_count_map_; |
550 | 562 |
551 // A map that contains the network usage is displayed in the table, in bytes | 563 // 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 | 564 // per second. It is computed every time the timer ticks. The Resources are |
553 // owned by the ResourceProviders. | 565 // owned by the ResourceProviders. |
554 ResourceValueMap displayed_network_usage_map_; | 566 ResourceValueMap displayed_network_usage_map_; |
555 | 567 |
556 // A map that contains the CPU usage (in %) for a process since last refresh. | 568 // A map that contains the CPU usage (in %) for a process since last refresh. |
557 CPUUsageMap cpu_usage_map_; | 569 CPUUsageMap cpu_usage_map_; |
558 | 570 |
| 571 // A map that contains the video memory usage for a process |
| 572 content::GPUVideoMemoryUsageStats video_memory_usage_stats_; |
| 573 bool pending_video_memory_usage_stats_update_; |
| 574 |
559 // A map that contains the private/shared memory usage of the process. We | 575 // 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 | 576 // 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 | 577 // because the linux call takes >10ms to complete. This cache is cleared on |
562 // every Refresh(). | 578 // every Refresh(). |
563 mutable MemoryUsageMap memory_usage_map_; | 579 mutable MemoryUsageMap memory_usage_map_; |
564 | 580 |
565 ObserverList<TaskManagerModelObserver> observer_list_; | 581 ObserverList<TaskManagerModelObserver> observer_list_; |
566 | 582 |
567 // How many calls to StartUpdating have been made without matching calls to | 583 // How many calls to StartUpdating have been made without matching calls to |
568 // StopUpdating. | 584 // StopUpdating. |
569 int update_requests_; | 585 int update_requests_; |
570 | 586 |
571 // How many calls to StartListening have been made without matching calls to | 587 // How many calls to StartListening have been made without matching calls to |
572 // StopListening. | 588 // StopListening. |
573 int listen_requests_; | 589 int listen_requests_; |
574 | 590 |
575 // Whether we are currently in the process of updating. | 591 // Whether we are currently in the process of updating. |
576 UpdateState update_state_; | 592 UpdateState update_state_; |
577 | 593 |
578 // A salt lick for the goats. | 594 // A salt lick for the goats. |
579 uint64 goat_salt_; | 595 uint64 goat_salt_; |
580 | 596 |
581 // Resource identifier that is unique within single session. | 597 // Resource identifier that is unique within single session. |
582 int last_unique_id_; | 598 int last_unique_id_; |
583 | 599 |
584 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 600 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
585 }; | 601 }; |
586 | 602 |
587 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 603 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
OLD | NEW |