| 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 <stddef.h> |
| 8 #include <stdint.h> | 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include <map> | 11 #include <map> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/basictypes.h" | |
| 14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
| 15 #include "base/gtest_prod_util.h" | 15 #include "base/gtest_prod_util.h" |
| 16 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
| 18 #include "base/observer_list.h" | 19 #include "base/observer_list.h" |
| 19 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
| 21 #include "build/build_config.h" |
| 20 #include "chrome/browser/task_manager/resource_provider.h" | 22 #include "chrome/browser/task_manager/resource_provider.h" |
| 21 #include "chrome/browser/ui/host_desktop.h" | 23 #include "chrome/browser/ui/host_desktop.h" |
| 22 #include "content/public/common/gpu_memory_stats.h" | 24 #include "content/public/common/gpu_memory_stats.h" |
| 23 #include "third_party/WebKit/public/web/WebCache.h" | 25 #include "third_party/WebKit/public/web/WebCache.h" |
| 24 | 26 |
| 25 class PrefRegistrySimple; | 27 class PrefRegistrySimple; |
| 26 class PrivateWorkingSetSnapshot; | 28 class PrivateWorkingSetSnapshot; |
| 27 class TaskManagerModel; | 29 class TaskManagerModel; |
| 28 class TaskManagerModelGpuDataManagerObserver; | 30 class TaskManagerModelGpuDataManagerObserver; |
| 29 | 31 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void AddObserver(TaskManagerModelObserver* observer); | 154 void AddObserver(TaskManagerModelObserver* observer); |
| 153 void RemoveObserver(TaskManagerModelObserver* observer); | 155 void RemoveObserver(TaskManagerModelObserver* observer); |
| 154 | 156 |
| 155 // Returns number of registered resources. | 157 // Returns number of registered resources. |
| 156 int ResourceCount() const; | 158 int ResourceCount() const; |
| 157 // Returns number of registered groups. | 159 // Returns number of registered groups. |
| 158 int GroupCount() const; | 160 int GroupCount() const; |
| 159 | 161 |
| 160 // Methods to return raw resource information. | 162 // Methods to return raw resource information. |
| 161 int GetNaClDebugStubPort(int index) const; | 163 int GetNaClDebugStubPort(int index) const; |
| 162 int64 GetNetworkUsage(int index) const; | 164 int64_t GetNetworkUsage(int index) const; |
| 163 double GetCPUUsage(int index) const; | 165 double GetCPUUsage(int index) const; |
| 164 int GetIdleWakeupsPerSecond(int index) const; | 166 int GetIdleWakeupsPerSecond(int index) const; |
| 165 base::ProcessId GetProcessId(int index) const; | 167 base::ProcessId GetProcessId(int index) const; |
| 166 base::ProcessHandle GetProcess(int index) const; | 168 base::ProcessHandle GetProcess(int index) const; |
| 167 | 169 |
| 168 // Catchall method that calls off to the appropriate GetResourceXXX method | 170 // Catchall method that calls off to the appropriate GetResourceXXX method |
| 169 // based on |col_id|. |col_id| is an IDS_ value used to identify the column. | 171 // based on |col_id|. |col_id| is an IDS_ value used to identify the column. |
| 170 base::string16 GetResourceById(int index, int col_id) const; | 172 base::string16 GetResourceById(int index, int col_id) const; |
| 171 | 173 |
| 172 // Methods to return formatted resource information. | 174 // Methods to return formatted resource information. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 PerResourceValues(); | 334 PerResourceValues(); |
| 333 ~PerResourceValues(); | 335 ~PerResourceValues(); |
| 334 | 336 |
| 335 bool is_title_valid; | 337 bool is_title_valid; |
| 336 base::string16 title; | 338 base::string16 title; |
| 337 | 339 |
| 338 bool is_profile_name_valid; | 340 bool is_profile_name_valid; |
| 339 base::string16 profile_name; | 341 base::string16 profile_name; |
| 340 | 342 |
| 341 // No is_network_usage since default (0) is fine. | 343 // No is_network_usage since default (0) is fine. |
| 342 int64 network_usage; | 344 int64_t network_usage; |
| 343 | 345 |
| 344 bool is_process_id_valid; | 346 bool is_process_id_valid; |
| 345 base::ProcessId process_id; | 347 base::ProcessId process_id; |
| 346 | 348 |
| 347 bool is_webcore_stats_valid; | 349 bool is_webcore_stats_valid; |
| 348 blink::WebCache::ResourceTypeStats webcore_stats; | 350 blink::WebCache::ResourceTypeStats webcore_stats; |
| 349 | 351 |
| 350 bool is_sqlite_memory_bytes_valid; | 352 bool is_sqlite_memory_bytes_valid; |
| 351 size_t sqlite_memory_bytes; | 353 size_t sqlite_memory_bytes; |
| 352 | 354 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 390 |
| 389 bool is_nacl_debug_stub_port_valid; | 391 bool is_nacl_debug_stub_port_valid; |
| 390 int nacl_debug_stub_port; | 392 int nacl_debug_stub_port; |
| 391 }; | 393 }; |
| 392 | 394 |
| 393 typedef std::vector<task_manager::Resource*> ResourceList; | 395 typedef std::vector<task_manager::Resource*> ResourceList; |
| 394 typedef std::vector<scoped_refptr<task_manager::ResourceProvider> > | 396 typedef std::vector<scoped_refptr<task_manager::ResourceProvider> > |
| 395 ResourceProviderList; | 397 ResourceProviderList; |
| 396 typedef std::map<base::ProcessHandle, ResourceList> GroupMap; | 398 typedef std::map<base::ProcessHandle, ResourceList> GroupMap; |
| 397 typedef std::map<base::ProcessHandle, base::ProcessMetrics*> MetricsMap; | 399 typedef std::map<base::ProcessHandle, base::ProcessMetrics*> MetricsMap; |
| 398 typedef std::map<task_manager::Resource*, int64> ResourceValueMap; | 400 typedef std::map<task_manager::Resource*, int64_t> ResourceValueMap; |
| 399 typedef std::map<task_manager::Resource*, | 401 typedef std::map<task_manager::Resource*, |
| 400 PerResourceValues> PerResourceCache; | 402 PerResourceValues> PerResourceCache; |
| 401 typedef std::map<base::ProcessHandle, PerProcessValues> PerProcessCache; | 403 typedef std::map<base::ProcessHandle, PerProcessValues> PerProcessCache; |
| 402 | 404 |
| 403 // This struct is used to exchange information between the io and ui threads. | 405 // This struct is used to exchange information between the io and ui threads. |
| 404 struct BytesReadParam { | 406 struct BytesReadParam { |
| 405 BytesReadParam(int origin_pid, | 407 BytesReadParam(int origin_pid, |
| 406 int child_id, | 408 int child_id, |
| 407 int route_id, | 409 int route_id, |
| 408 int64_t byte_count) | 410 int64_t byte_count) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 424 | 426 |
| 425 ~TaskManagerModel(); | 427 ~TaskManagerModel(); |
| 426 | 428 |
| 427 // Callback from the timer to refresh. Invokes Refresh() as appropriate. | 429 // Callback from the timer to refresh. Invokes Refresh() as appropriate. |
| 428 void RefreshCallback(); | 430 void RefreshCallback(); |
| 429 | 431 |
| 430 void RefreshVideoMemoryUsageStats(); | 432 void RefreshVideoMemoryUsageStats(); |
| 431 | 433 |
| 432 // Returns the network usage (in bytes per seconds) for the specified | 434 // Returns the network usage (in bytes per seconds) for the specified |
| 433 // resource. That's the value retrieved at the last timer's tick. | 435 // resource. That's the value retrieved at the last timer's tick. |
| 434 int64 GetNetworkUsageForResource(task_manager::Resource* resource) const; | 436 int64_t GetNetworkUsageForResource(task_manager::Resource* resource) const; |
| 435 | 437 |
| 436 // Called on the UI thread when some bytes are read. | 438 // Called on the UI thread when some bytes are read. |
| 437 void BytesRead(BytesReadParam param); | 439 void BytesRead(BytesReadParam param); |
| 438 | 440 |
| 439 void MultipleBytesRead(const std::vector<BytesReadParam>* params); | 441 void MultipleBytesRead(const std::vector<BytesReadParam>* params); |
| 440 | 442 |
| 441 // Notifies the UI thread about all the bytes read. Allows for coalescing | 443 // Notifies the UI thread about all the bytes read. Allows for coalescing |
| 442 // multiple bytes read into a single task for the UI thread. This is important | 444 // multiple bytes read into a single task for the UI thread. This is important |
| 443 // for when downloading a lot of data on the IO thread, since posting a Task | 445 // for when downloading a lot of data on the IO thread, since posting a Task |
| 444 // for each one is expensive. | 446 // for each one is expensive. |
| 445 void NotifyMultipleBytesRead(); | 447 void NotifyMultipleBytesRead(); |
| 446 | 448 |
| 447 // Called on the IO thread to start/stop updating byte counts. | 449 // Called on the IO thread to start/stop updating byte counts. |
| 448 void SetUpdatingByteCount(bool is_updating); | 450 void SetUpdatingByteCount(bool is_updating); |
| 449 | 451 |
| 450 // Returns the network usage (in byte per second) that should be displayed for | 452 // Returns the network usage (in byte per second) that should be displayed for |
| 451 // the passed |resource|. -1 means the information is not available for that | 453 // the passed |resource|. -1 means the information is not available for that |
| 452 // resource. | 454 // resource. |
| 453 int64 GetNetworkUsage(task_manager::Resource* resource) const; | 455 int64_t GetNetworkUsage(task_manager::Resource* resource) const; |
| 454 | 456 |
| 455 // Returns the CPU usage (in %) that should be displayed for the passed | 457 // Returns the CPU usage (in %) that should be displayed for the passed |
| 456 // |resource|. | 458 // |resource|. |
| 457 double GetCPUUsage(task_manager::Resource* resource) const; | 459 double GetCPUUsage(task_manager::Resource* resource) const; |
| 458 | 460 |
| 459 // Returns the idle wakeups that should be displayed for the passed | 461 // Returns the idle wakeups that should be displayed for the passed |
| 460 // |resource|. | 462 // |resource|. |
| 461 int GetIdleWakeupsPerSecond(task_manager::Resource* resource) const; | 463 int GetIdleWakeupsPerSecond(task_manager::Resource* resource) const; |
| 462 | 464 |
| 463 // Given a number, this function returns the formatted string that should be | 465 // Given a number, this function returns the formatted string that should be |
| 464 // displayed in the task manager's memory cell. | 466 // displayed in the task manager's memory cell. |
| 465 base::string16 GetMemCellText(int64 number) const; | 467 base::string16 GetMemCellText(int64_t number) const; |
| 466 | 468 |
| 467 // Verifies the private and shared memory for |handle| is valid in | 469 // Verifies the private and shared memory for |handle| is valid in |
| 468 // |per_process_cache_|. Returns true if the data in |per_process_cache_| is | 470 // |per_process_cache_|. Returns true if the data in |per_process_cache_| is |
| 469 // valid. | 471 // valid. |
| 470 bool CachePrivateAndSharedMemory(base::ProcessHandle handle) const; | 472 bool CachePrivateAndSharedMemory(base::ProcessHandle handle) const; |
| 471 | 473 |
| 472 // Verifies |webcore_stats| in |per_resource_cache_|, returning true on | 474 // Verifies |webcore_stats| in |per_resource_cache_|, returning true on |
| 473 // success. | 475 // success. |
| 474 bool CacheWebCoreStats(int index) const; | 476 bool CacheWebCoreStats(int index) const; |
| 475 | 477 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 // All per-Resource values are stored here. | 549 // All per-Resource values are stored here. |
| 548 mutable PerResourceCache per_resource_cache_; | 550 mutable PerResourceCache per_resource_cache_; |
| 549 | 551 |
| 550 // All per-Process values are stored here. | 552 // All per-Process values are stored here. |
| 551 mutable PerProcessCache per_process_cache_; | 553 mutable PerProcessCache per_process_cache_; |
| 552 | 554 |
| 553 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); | 555 DISALLOW_COPY_AND_ASSIGN(TaskManagerModel); |
| 554 }; | 556 }; |
| 555 | 557 |
| 556 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ | 558 #endif // CHROME_BROWSER_TASK_MANAGER_TASK_MANAGER_H_ |
| OLD | NEW |