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 #include "chrome/browser/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
13 #include "base/process/process_metrics.h" | 13 #include "base/process/process_metrics.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
20 #include "base/thread_task_runner_handle.h" | 20 #include "base/thread_task_runner_handle.h" |
| 21 #include "build/build_config.h" |
21 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/private_working_set_snapshot.h" | 23 #include "chrome/browser/private_working_set_snapshot.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/profiles/profile_window.h" | 25 #include "chrome/browser/profiles/profile_window.h" |
25 #include "chrome/browser/task_manager/background_information.h" | 26 #include "chrome/browser/task_manager/background_information.h" |
26 #include "chrome/browser/task_manager/browser_process_resource_provider.h" | 27 #include "chrome/browser/task_manager/browser_process_resource_provider.h" |
27 #include "chrome/browser/task_manager/child_process_resource_provider.h" | 28 #include "chrome/browser/task_manager/child_process_resource_provider.h" |
28 #include "chrome/browser/task_manager/extension_information.h" | 29 #include "chrome/browser/task_manager/extension_information.h" |
29 #include "chrome/browser/task_manager/guest_information.h" | 30 #include "chrome/browser/task_manager/guest_information.h" |
30 #include "chrome/browser/task_manager/panel_information.h" | 31 #include "chrome/browser/task_manager/panel_information.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 302 |
302 int TaskManagerModel::GetNaClDebugStubPort(int index) const { | 303 int TaskManagerModel::GetNaClDebugStubPort(int index) const { |
303 base::ProcessHandle handle = GetResource(index)->GetProcess(); | 304 base::ProcessHandle handle = GetResource(index)->GetProcess(); |
304 PerProcessValues& values(per_process_cache_[handle]); | 305 PerProcessValues& values(per_process_cache_[handle]); |
305 if (!values.is_nacl_debug_stub_port_valid) { | 306 if (!values.is_nacl_debug_stub_port_valid) { |
306 return nacl::kGdbDebugStubPortUnknown; | 307 return nacl::kGdbDebugStubPortUnknown; |
307 } | 308 } |
308 return values.nacl_debug_stub_port; | 309 return values.nacl_debug_stub_port; |
309 } | 310 } |
310 | 311 |
311 int64 TaskManagerModel::GetNetworkUsage(int index) const { | 312 int64_t TaskManagerModel::GetNetworkUsage(int index) const { |
312 return GetNetworkUsage(GetResource(index)); | 313 return GetNetworkUsage(GetResource(index)); |
313 } | 314 } |
314 | 315 |
315 double TaskManagerModel::GetCPUUsage(int index) const { | 316 double TaskManagerModel::GetCPUUsage(int index) const { |
316 return GetCPUUsage(GetResource(index)); | 317 return GetCPUUsage(GetResource(index)); |
317 } | 318 } |
318 | 319 |
319 int TaskManagerModel::GetIdleWakeupsPerSecond(int index) const { | 320 int TaskManagerModel::GetIdleWakeupsPerSecond(int index) const { |
320 return GetIdleWakeupsPerSecond(GetResource(index)); | 321 return GetIdleWakeupsPerSecond(GetResource(index)); |
321 } | 322 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 if (port == nacl::kGdbDebugStubPortUnknown) { | 426 if (port == nacl::kGdbDebugStubPortUnknown) { |
426 return base::ASCIIToUTF16("Unknown"); | 427 return base::ASCIIToUTF16("Unknown"); |
427 } else if (port == nacl::kGdbDebugStubPortUnused) { | 428 } else if (port == nacl::kGdbDebugStubPortUnused) { |
428 return base::ASCIIToUTF16("N/A"); | 429 return base::ASCIIToUTF16("N/A"); |
429 } else { | 430 } else { |
430 return base::IntToString16(port); | 431 return base::IntToString16(port); |
431 } | 432 } |
432 } | 433 } |
433 | 434 |
434 base::string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { | 435 base::string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { |
435 int64 net_usage = GetNetworkUsage(index); | 436 int64_t net_usage = GetNetworkUsage(index); |
436 if (net_usage == -1) | 437 if (net_usage == -1) |
437 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 438 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
438 if (net_usage == 0) | 439 if (net_usage == 0) |
439 return base::ASCIIToUTF16("0"); | 440 return base::ASCIIToUTF16("0"); |
440 base::string16 net_byte = ui::FormatSpeed(net_usage); | 441 base::string16 net_byte = ui::FormatSpeed(net_usage); |
441 // Force number string to have LTR directionality. | 442 // Force number string to have LTR directionality. |
442 return base::i18n::GetDisplayStringInLTRDirectionality(net_byte); | 443 return base::i18n::GetDisplayStringInLTRDirectionality(net_byte); |
443 } | 444 } |
444 | 445 |
445 base::string16 TaskManagerModel::GetResourceCPUUsage(int index) const { | 446 base::string16 TaskManagerModel::GetResourceCPUUsage(int index) const { |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 return; | 1325 return; |
1325 | 1326 |
1326 if (!video_memory_usage_stats_observer_.get()) { | 1327 if (!video_memory_usage_stats_observer_.get()) { |
1327 video_memory_usage_stats_observer_.reset( | 1328 video_memory_usage_stats_observer_.reset( |
1328 new TaskManagerModelGpuDataManagerObserver()); | 1329 new TaskManagerModelGpuDataManagerObserver()); |
1329 } | 1330 } |
1330 pending_video_memory_usage_stats_update_ = true; | 1331 pending_video_memory_usage_stats_update_ = true; |
1331 content::GpuDataManager::GetInstance()->RequestVideoMemoryUsageStatsUpdate(); | 1332 content::GpuDataManager::GetInstance()->RequestVideoMemoryUsageStatsUpdate(); |
1332 } | 1333 } |
1333 | 1334 |
1334 int64 TaskManagerModel::GetNetworkUsageForResource(Resource* resource) const { | 1335 int64_t TaskManagerModel::GetNetworkUsageForResource(Resource* resource) const { |
1335 // Returns default of 0 if no network usage. | 1336 // Returns default of 0 if no network usage. |
1336 return per_resource_cache_[resource].network_usage; | 1337 return per_resource_cache_[resource].network_usage; |
1337 } | 1338 } |
1338 | 1339 |
1339 void TaskManagerModel::BytesRead(BytesReadParam param) { | 1340 void TaskManagerModel::BytesRead(BytesReadParam param) { |
1340 if (update_state_ != TASK_PENDING || listen_requests_ == 0) { | 1341 if (update_state_ != TASK_PENDING || listen_requests_ == 0) { |
1341 // A notification sneaked in while we were stopping the updating, just | 1342 // A notification sneaked in while we were stopping the updating, just |
1342 // ignore it. | 1343 // ignore it. |
1343 return; | 1344 return; |
1344 } | 1345 } |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 BrowserThread::UI, FROM_HERE, | 1401 BrowserThread::UI, FROM_HERE, |
1401 base::Bind(&TaskManagerModel::MultipleBytesRead, this, | 1402 base::Bind(&TaskManagerModel::MultipleBytesRead, this, |
1402 base::Owned(bytes_read_buffer))); | 1403 base::Owned(bytes_read_buffer))); |
1403 } | 1404 } |
1404 | 1405 |
1405 void TaskManagerModel::SetUpdatingByteCount(bool is_updating) { | 1406 void TaskManagerModel::SetUpdatingByteCount(bool is_updating) { |
1406 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1407 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1407 is_updating_byte_count_ = is_updating; | 1408 is_updating_byte_count_ = is_updating; |
1408 } | 1409 } |
1409 | 1410 |
1410 int64 TaskManagerModel::GetNetworkUsage(Resource* resource) const { | 1411 int64_t TaskManagerModel::GetNetworkUsage(Resource* resource) const { |
1411 int64 net_usage = GetNetworkUsageForResource(resource); | 1412 int64_t net_usage = GetNetworkUsageForResource(resource); |
1412 if (net_usage == 0 && !resource->SupportNetworkUsage()) | 1413 if (net_usage == 0 && !resource->SupportNetworkUsage()) |
1413 return -1; | 1414 return -1; |
1414 return net_usage; | 1415 return net_usage; |
1415 } | 1416 } |
1416 | 1417 |
1417 double TaskManagerModel::GetCPUUsage(Resource* resource) const { | 1418 double TaskManagerModel::GetCPUUsage(Resource* resource) const { |
1418 const PerProcessValues& values(per_process_cache_[resource->GetProcess()]); | 1419 const PerProcessValues& values(per_process_cache_[resource->GetProcess()]); |
1419 // Returns 0 if not valid, which is fine. | 1420 // Returns 0 if not valid, which is fine. |
1420 return values.cpu_usage; | 1421 return values.cpu_usage; |
1421 } | 1422 } |
1422 | 1423 |
1423 int TaskManagerModel::GetIdleWakeupsPerSecond(Resource* resource) const { | 1424 int TaskManagerModel::GetIdleWakeupsPerSecond(Resource* resource) const { |
1424 const PerProcessValues& values(per_process_cache_[resource->GetProcess()]); | 1425 const PerProcessValues& values(per_process_cache_[resource->GetProcess()]); |
1425 // Returns 0 if not valid, which is fine. | 1426 // Returns 0 if not valid, which is fine. |
1426 return values.idle_wakeups; | 1427 return values.idle_wakeups; |
1427 } | 1428 } |
1428 | 1429 |
1429 base::string16 TaskManagerModel::GetMemCellText(int64 number) const { | 1430 base::string16 TaskManagerModel::GetMemCellText(int64_t number) const { |
1430 #if !defined(OS_MACOSX) | 1431 #if !defined(OS_MACOSX) |
1431 base::string16 str = base::FormatNumber(number / 1024); | 1432 base::string16 str = base::FormatNumber(number / 1024); |
1432 | 1433 |
1433 // Adjust number string if necessary. | 1434 // Adjust number string if necessary. |
1434 base::i18n::AdjustStringForLocaleDirection(&str); | 1435 base::i18n::AdjustStringForLocaleDirection(&str); |
1435 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_MEM_CELL_TEXT, str); | 1436 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_MEM_CELL_TEXT, str); |
1436 #else | 1437 #else |
1437 // System expectation is to show "100 kB", "200 MB", etc. | 1438 // System expectation is to show "100 kB", "200 MB", etc. |
1438 // TODO(thakis): Switch to metric units (as opposed to powers of two). | 1439 // TODO(thakis): Switch to metric units (as opposed to powers of two). |
1439 return ui::FormatBytes(number); | 1440 return ui::FormatBytes(number); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 params.host_desktop_type = desktop_type; | 1570 params.host_desktop_type = desktop_type; |
1570 chrome::Navigate(¶ms); | 1571 chrome::Navigate(¶ms); |
1571 } | 1572 } |
1572 | 1573 |
1573 TaskManager::TaskManager() | 1574 TaskManager::TaskManager() |
1574 : model_(new TaskManagerModel(this)) { | 1575 : model_(new TaskManagerModel(this)) { |
1575 } | 1576 } |
1576 | 1577 |
1577 TaskManager::~TaskManager() { | 1578 TaskManager::~TaskManager() { |
1578 } | 1579 } |
OLD | NEW |