| 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/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 values.profile_name = GetResource(index)->GetProfileName(); | 396 values.profile_name = GetResource(index)->GetProfileName(); |
| 397 } | 397 } |
| 398 return values.profile_name; | 398 return values.profile_name; |
| 399 } | 399 } |
| 400 | 400 |
| 401 base::string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { | 401 base::string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { |
| 402 int64 net_usage = GetNetworkUsage(index); | 402 int64 net_usage = GetNetworkUsage(index); |
| 403 if (net_usage == -1) | 403 if (net_usage == -1) |
| 404 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 404 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
| 405 if (net_usage == 0) | 405 if (net_usage == 0) |
| 406 return ASCIIToUTF16("0"); | 406 return base::ASCIIToUTF16("0"); |
| 407 base::string16 net_byte = ui::FormatSpeed(net_usage); | 407 base::string16 net_byte = ui::FormatSpeed(net_usage); |
| 408 // Force number string to have LTR directionality. | 408 // Force number string to have LTR directionality. |
| 409 return base::i18n::GetDisplayStringInLTRDirectionality(net_byte); | 409 return base::i18n::GetDisplayStringInLTRDirectionality(net_byte); |
| 410 } | 410 } |
| 411 | 411 |
| 412 base::string16 TaskManagerModel::GetResourceCPUUsage(int index) const { | 412 base::string16 TaskManagerModel::GetResourceCPUUsage(int index) const { |
| 413 return UTF8ToUTF16(base::StringPrintf( | 413 return base::UTF8ToUTF16(base::StringPrintf( |
| 414 #if defined(OS_MACOSX) | 414 #if defined(OS_MACOSX) |
| 415 // Activity Monitor shows %cpu with one decimal digit -- be | 415 // Activity Monitor shows %cpu with one decimal digit -- be |
| 416 // consistent with that. | 416 // consistent with that. |
| 417 "%.1f", | 417 "%.1f", |
| 418 #else | 418 #else |
| 419 "%.0f", | 419 "%.0f", |
| 420 #endif | 420 #endif |
| 421 GetCPUUsage(GetResource(index)))); | 421 GetCPUUsage(GetResource(index)))); |
| 422 } | 422 } |
| 423 | 423 |
| 424 base::string16 TaskManagerModel::GetResourcePrivateMemory(int index) const { | 424 base::string16 TaskManagerModel::GetResourcePrivateMemory(int index) const { |
| 425 size_t private_mem; | 425 size_t private_mem; |
| 426 if (!GetPrivateMemory(index, &private_mem)) | 426 if (!GetPrivateMemory(index, &private_mem)) |
| 427 return ASCIIToUTF16("N/A"); | 427 return base::ASCIIToUTF16("N/A"); |
| 428 return GetMemCellText(private_mem); | 428 return GetMemCellText(private_mem); |
| 429 } | 429 } |
| 430 | 430 |
| 431 base::string16 TaskManagerModel::GetResourceSharedMemory(int index) const { | 431 base::string16 TaskManagerModel::GetResourceSharedMemory(int index) const { |
| 432 size_t shared_mem; | 432 size_t shared_mem; |
| 433 if (!GetSharedMemory(index, &shared_mem)) | 433 if (!GetSharedMemory(index, &shared_mem)) |
| 434 return ASCIIToUTF16("N/A"); | 434 return base::ASCIIToUTF16("N/A"); |
| 435 return GetMemCellText(shared_mem); | 435 return GetMemCellText(shared_mem); |
| 436 } | 436 } |
| 437 | 437 |
| 438 base::string16 TaskManagerModel::GetResourcePhysicalMemory(int index) const { | 438 base::string16 TaskManagerModel::GetResourcePhysicalMemory(int index) const { |
| 439 size_t phys_mem; | 439 size_t phys_mem; |
| 440 GetPhysicalMemory(index, &phys_mem); | 440 GetPhysicalMemory(index, &phys_mem); |
| 441 return GetMemCellText(phys_mem); | 441 return GetMemCellText(phys_mem); |
| 442 } | 442 } |
| 443 | 443 |
| 444 base::string16 TaskManagerModel::GetResourceProcessId(int index) const { | 444 base::string16 TaskManagerModel::GetResourceProcessId(int index) const { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 if (!CacheWebCoreStats(index)) | 478 if (!CacheWebCoreStats(index)) |
| 479 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 479 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
| 480 return FormatStatsSize( | 480 return FormatStatsSize( |
| 481 GetPerResourceValues(index).webcore_stats.cssStyleSheets); | 481 GetPerResourceValues(index).webcore_stats.cssStyleSheets); |
| 482 } | 482 } |
| 483 | 483 |
| 484 base::string16 TaskManagerModel::GetResourceVideoMemory(int index) const { | 484 base::string16 TaskManagerModel::GetResourceVideoMemory(int index) const { |
| 485 size_t video_memory; | 485 size_t video_memory; |
| 486 bool has_duplicates; | 486 bool has_duplicates; |
| 487 if (!GetVideoMemory(index, &video_memory, &has_duplicates) || !video_memory) | 487 if (!GetVideoMemory(index, &video_memory, &has_duplicates) || !video_memory) |
| 488 return ASCIIToUTF16("N/A"); | 488 return base::ASCIIToUTF16("N/A"); |
| 489 if (has_duplicates) { | 489 if (has_duplicates) { |
| 490 return GetMemCellText(video_memory) + ASCIIToUTF16("*"); | 490 return GetMemCellText(video_memory) + base::ASCIIToUTF16("*"); |
| 491 } | 491 } |
| 492 return GetMemCellText(video_memory); | 492 return GetMemCellText(video_memory); |
| 493 } | 493 } |
| 494 | 494 |
| 495 base::string16 TaskManagerModel::GetResourceFPS( | 495 base::string16 TaskManagerModel::GetResourceFPS( |
| 496 int index) const { | 496 int index) const { |
| 497 float fps = 0; | 497 float fps = 0; |
| 498 if (!GetFPS(index, &fps)) | 498 if (!GetFPS(index, &fps)) |
| 499 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 499 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
| 500 return UTF8ToUTF16(base::StringPrintf("%.0f", fps)); | 500 return base::UTF8ToUTF16(base::StringPrintf("%.0f", fps)); |
| 501 } | 501 } |
| 502 | 502 |
| 503 base::string16 TaskManagerModel::GetResourceSqliteMemoryUsed(int index) const { | 503 base::string16 TaskManagerModel::GetResourceSqliteMemoryUsed(int index) const { |
| 504 size_t bytes = 0; | 504 size_t bytes = 0; |
| 505 if (!GetSqliteMemoryUsedBytes(index, &bytes)) | 505 if (!GetSqliteMemoryUsedBytes(index, &bytes)) |
| 506 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 506 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
| 507 return GetMemCellText(bytes); | 507 return GetMemCellText(bytes); |
| 508 } | 508 } |
| 509 | 509 |
| 510 base::string16 TaskManagerModel::GetResourceGoatsTeleported(int index) const { | 510 base::string16 TaskManagerModel::GetResourceGoatsTeleported(int index) const { |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 params.host_desktop_type = desktop_type; | 1541 params.host_desktop_type = desktop_type; |
| 1542 chrome::Navigate(¶ms); | 1542 chrome::Navigate(¶ms); |
| 1543 } | 1543 } |
| 1544 | 1544 |
| 1545 TaskManager::TaskManager() | 1545 TaskManager::TaskManager() |
| 1546 : model_(new TaskManagerModel(this)) { | 1546 : model_(new TaskManagerModel(this)) { |
| 1547 } | 1547 } |
| 1548 | 1548 |
| 1549 TaskManager::~TaskManager() { | 1549 TaskManager::~TaskManager() { |
| 1550 } | 1550 } |
| OLD | NEW |