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