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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 using content::ResourceRequestInfo; | 70 using content::ResourceRequestInfo; |
71 using content::WebContents; | 71 using content::WebContents; |
72 using task_manager::Resource; | 72 using task_manager::Resource; |
73 using task_manager::ResourceProvider; | 73 using task_manager::ResourceProvider; |
74 using task_manager::WebContentsInformation; | 74 using task_manager::WebContentsInformation; |
75 | 75 |
76 class Profile; | 76 class Profile; |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
| 80 const char kUnknownValueText[] = "-"; |
| 81 |
80 template <class T> | 82 template <class T> |
81 int ValueCompare(T value1, T value2) { | 83 int ValueCompare(T value1, T value2) { |
82 if (value1 < value2) | 84 if (value1 < value2) |
83 return -1; | 85 return -1; |
84 if (value1 == value2) | 86 if (value1 == value2) |
85 return 0; | 87 return 0; |
86 return 1; | 88 return 1; |
87 } | 89 } |
88 | 90 |
89 // Used when one or both of the results to compare are unavailable. | 91 // Used when one or both of the results to compare are unavailable. |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 values.profile_name = GetResource(index)->GetProfileName(); | 427 values.profile_name = GetResource(index)->GetProfileName(); |
426 } | 428 } |
427 return values.profile_name; | 429 return values.profile_name; |
428 } | 430 } |
429 | 431 |
430 base::string16 TaskManagerModel::GetResourceNaClDebugStubPort(int index) const { | 432 base::string16 TaskManagerModel::GetResourceNaClDebugStubPort(int index) const { |
431 int port = GetNaClDebugStubPort(index); | 433 int port = GetNaClDebugStubPort(index); |
432 if (port == nacl::kGdbDebugStubPortUnknown) { | 434 if (port == nacl::kGdbDebugStubPortUnknown) { |
433 return base::ASCIIToUTF16("Unknown"); | 435 return base::ASCIIToUTF16("Unknown"); |
434 } else if (port == nacl::kGdbDebugStubPortUnused) { | 436 } else if (port == nacl::kGdbDebugStubPortUnused) { |
435 return base::ASCIIToUTF16("N/A"); | 437 return base::ASCIIToUTF16(kUnknownValueText); |
436 } else { | 438 } else { |
437 return base::IntToString16(port); | 439 return base::IntToString16(port); |
438 } | 440 } |
439 } | 441 } |
440 | 442 |
441 base::string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { | 443 base::string16 TaskManagerModel::GetResourceNetworkUsage(int index) const { |
442 int64_t net_usage = GetNetworkUsage(index); | 444 int64_t net_usage = GetNetworkUsage(index); |
443 if (net_usage == -1) | 445 if (net_usage == -1) |
444 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 446 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
445 if (net_usage == 0) | 447 if (net_usage == 0) |
(...skipping 11 matching lines...) Expand all Loading... |
457 "%.1f", | 459 "%.1f", |
458 #else | 460 #else |
459 "%.0f", | 461 "%.0f", |
460 #endif | 462 #endif |
461 GetCPUUsage(GetResource(index)))); | 463 GetCPUUsage(GetResource(index)))); |
462 } | 464 } |
463 | 465 |
464 base::string16 TaskManagerModel::GetResourcePrivateMemory(int index) const { | 466 base::string16 TaskManagerModel::GetResourcePrivateMemory(int index) const { |
465 size_t private_mem; | 467 size_t private_mem; |
466 if (!GetPrivateMemory(index, &private_mem)) | 468 if (!GetPrivateMemory(index, &private_mem)) |
467 return base::ASCIIToUTF16("N/A"); | 469 return base::ASCIIToUTF16(kUnknownValueText); |
468 return GetMemCellText(private_mem); | 470 return GetMemCellText(private_mem); |
469 } | 471 } |
470 | 472 |
471 base::string16 TaskManagerModel::GetResourceSharedMemory(int index) const { | 473 base::string16 TaskManagerModel::GetResourceSharedMemory(int index) const { |
472 size_t shared_mem; | 474 size_t shared_mem; |
473 if (!GetSharedMemory(index, &shared_mem)) | 475 if (!GetSharedMemory(index, &shared_mem)) |
474 return base::ASCIIToUTF16("N/A"); | 476 return base::ASCIIToUTF16(kUnknownValueText); |
475 return GetMemCellText(shared_mem); | 477 return GetMemCellText(shared_mem); |
476 } | 478 } |
477 | 479 |
478 base::string16 TaskManagerModel::GetResourcePhysicalMemory(int index) const { | 480 base::string16 TaskManagerModel::GetResourcePhysicalMemory(int index) const { |
479 size_t phys_mem; | 481 size_t phys_mem; |
480 GetPhysicalMemory(index, &phys_mem); | 482 GetPhysicalMemory(index, &phys_mem); |
481 return GetMemCellText(phys_mem); | 483 return GetMemCellText(phys_mem); |
482 } | 484 } |
483 | 485 |
484 base::string16 TaskManagerModel::GetResourceProcessId(int index) const { | 486 base::string16 TaskManagerModel::GetResourceProcessId(int index) const { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 if (!CacheWebCoreStats(index)) | 520 if (!CacheWebCoreStats(index)) |
519 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 521 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
520 return FormatStatsSize( | 522 return FormatStatsSize( |
521 GetPerResourceValues(index).webcore_stats.cssStyleSheets); | 523 GetPerResourceValues(index).webcore_stats.cssStyleSheets); |
522 } | 524 } |
523 | 525 |
524 base::string16 TaskManagerModel::GetResourceVideoMemory(int index) const { | 526 base::string16 TaskManagerModel::GetResourceVideoMemory(int index) const { |
525 size_t video_memory; | 527 size_t video_memory; |
526 bool has_duplicates; | 528 bool has_duplicates; |
527 if (!GetVideoMemory(index, &video_memory, &has_duplicates) || !video_memory) | 529 if (!GetVideoMemory(index, &video_memory, &has_duplicates) || !video_memory) |
528 return base::ASCIIToUTF16("N/A"); | 530 return base::ASCIIToUTF16(kUnknownValueText); |
529 if (has_duplicates) { | 531 if (has_duplicates) { |
530 return GetMemCellText(video_memory) + base::ASCIIToUTF16("*"); | 532 return GetMemCellText(video_memory) + base::ASCIIToUTF16("*"); |
531 } | 533 } |
532 return GetMemCellText(video_memory); | 534 return GetMemCellText(video_memory); |
533 } | 535 } |
534 | 536 |
535 base::string16 TaskManagerModel::GetResourceSqliteMemoryUsed(int index) const { | 537 base::string16 TaskManagerModel::GetResourceSqliteMemoryUsed(int index) const { |
536 size_t bytes = 0; | 538 size_t bytes = 0; |
537 if (!GetSqliteMemoryUsedBytes(index, &bytes)) | 539 if (!GetSqliteMemoryUsedBytes(index, &bytes)) |
538 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); | 540 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT); |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 CHECK(!task_management::TaskManagerInterface::IsNewTaskManagerEnabled()); | 1559 CHECK(!task_management::TaskManagerInterface::IsNewTaskManagerEnabled()); |
1558 return base::Singleton<TaskManager>::get(); | 1560 return base::Singleton<TaskManager>::get(); |
1559 } | 1561 } |
1560 | 1562 |
1561 TaskManager::TaskManager() | 1563 TaskManager::TaskManager() |
1562 : model_(new TaskManagerModel(this)) { | 1564 : model_(new TaskManagerModel(this)) { |
1563 } | 1565 } |
1564 | 1566 |
1565 TaskManager::~TaskManager() { | 1567 TaskManager::~TaskManager() { |
1566 } | 1568 } |
OLD | NEW |