| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "chrome/common/extensions/extension.h" | 40 #include "chrome/common/extensions/extension.h" |
| 41 #include "chrome/common/render_messages.h" | 41 #include "chrome/common/render_messages.h" |
| 42 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
| 43 #include "content/browser/browser_child_process_host.h" | 43 #include "content/browser/browser_child_process_host.h" |
| 44 #include "content/browser/renderer_host/render_message_filter.h" | 44 #include "content/browser/renderer_host/render_message_filter.h" |
| 45 #include "content/browser/renderer_host/render_view_host.h" | 45 #include "content/browser/renderer_host/render_view_host.h" |
| 46 #include "content/browser/tab_contents/tab_contents.h" | 46 #include "content/browser/tab_contents/tab_contents.h" |
| 47 #include "content/public/browser/browser_thread.h" | 47 #include "content/public/browser/browser_thread.h" |
| 48 #include "content/public/browser/notification_service.h" | 48 #include "content/public/browser/notification_service.h" |
| 49 #include "content/public/browser/render_process_host.h" | 49 #include "content/public/browser/render_process_host.h" |
| 50 #include "content/public/common/process_type.h" |
| 50 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
| 51 #include "grit/theme_resources.h" | 52 #include "grit/theme_resources.h" |
| 52 #include "grit/theme_resources_standard.h" | 53 #include "grit/theme_resources_standard.h" |
| 53 #include "third_party/sqlite/sqlite3.h" | 54 #include "third_party/sqlite/sqlite3.h" |
| 54 #include "ui/base/l10n/l10n_util.h" | 55 #include "ui/base/l10n/l10n_util.h" |
| 55 #include "ui/base/resource/resource_bundle.h" | 56 #include "ui/base/resource/resource_bundle.h" |
| 56 #include "v8/include/v8.h" | 57 #include "v8/include/v8.h" |
| 57 | 58 |
| 58 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
| 59 #include "skia/ext/skia_utils_mac.h" | 60 #include "skia/ext/skia_utils_mac.h" |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 } | 780 } |
| 780 | 781 |
| 781 base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const { | 782 base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const { |
| 782 return child_process_.handle(); | 783 return child_process_.handle(); |
| 783 } | 784 } |
| 784 | 785 |
| 785 TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const { | 786 TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const { |
| 786 // Translate types to TaskManager::ResourceType, since ChildProcessInfo's type | 787 // Translate types to TaskManager::ResourceType, since ChildProcessInfo's type |
| 787 // is not available for all TaskManager resources. | 788 // is not available for all TaskManager resources. |
| 788 switch (child_process_.type()) { | 789 switch (child_process_.type()) { |
| 789 case ChildProcessInfo::PLUGIN_PROCESS: | 790 case content::PROCESS_TYPE_PLUGIN: |
| 790 case ChildProcessInfo::PPAPI_PLUGIN_PROCESS: | 791 case content::PROCESS_TYPE_PPAPI_PLUGIN: |
| 791 case ChildProcessInfo::PPAPI_BROKER_PROCESS: | 792 case content::PROCESS_TYPE_PPAPI_BROKER: |
| 792 return TaskManager::Resource::PLUGIN; | 793 return TaskManager::Resource::PLUGIN; |
| 793 case ChildProcessInfo::NACL_LOADER_PROCESS: | 794 case content::PROCESS_TYPE_NACL_LOADER: |
| 794 case ChildProcessInfo::NACL_BROKER_PROCESS: | 795 case content::PROCESS_TYPE_NACL_BROKER: |
| 795 return TaskManager::Resource::NACL; | 796 return TaskManager::Resource::NACL; |
| 796 case ChildProcessInfo::UTILITY_PROCESS: | 797 case content::PROCESS_TYPE_UTILITY: |
| 797 return TaskManager::Resource::UTILITY; | 798 return TaskManager::Resource::UTILITY; |
| 798 case ChildProcessInfo::PROFILE_IMPORT_PROCESS: | 799 case content::PROCESS_TYPE_PROFILE_IMPORT: |
| 799 return TaskManager::Resource::PROFILE_IMPORT; | 800 return TaskManager::Resource::PROFILE_IMPORT; |
| 800 case ChildProcessInfo::ZYGOTE_PROCESS: | 801 case content::PROCESS_TYPE_ZYGOTE: |
| 801 return TaskManager::Resource::ZYGOTE; | 802 return TaskManager::Resource::ZYGOTE; |
| 802 case ChildProcessInfo::SANDBOX_HELPER_PROCESS: | 803 case content::PROCESS_TYPE_SANDBOX_HELPER: |
| 803 return TaskManager::Resource::SANDBOX_HELPER; | 804 return TaskManager::Resource::SANDBOX_HELPER; |
| 804 case ChildProcessInfo::GPU_PROCESS: | 805 case content::PROCESS_TYPE_GPU: |
| 805 return TaskManager::Resource::GPU; | 806 return TaskManager::Resource::GPU; |
| 806 default: | 807 default: |
| 807 return TaskManager::Resource::UNKNOWN; | 808 return TaskManager::Resource::UNKNOWN; |
| 808 } | 809 } |
| 809 } | 810 } |
| 810 | 811 |
| 811 bool TaskManagerChildProcessResource::SupportNetworkUsage() const { | 812 bool TaskManagerChildProcessResource::SupportNetworkUsage() const { |
| 812 return network_usage_support_; | 813 return network_usage_support_; |
| 813 } | 814 } |
| 814 | 815 |
| 815 void TaskManagerChildProcessResource::SetSupportNetworkUsage() { | 816 void TaskManagerChildProcessResource::SetSupportNetworkUsage() { |
| 816 network_usage_support_ = true; | 817 network_usage_support_ = true; |
| 817 } | 818 } |
| 818 | 819 |
| 819 string16 TaskManagerChildProcessResource::GetLocalizedTitle() const { | 820 string16 TaskManagerChildProcessResource::GetLocalizedTitle() const { |
| 820 string16 title = child_process_.name(); | 821 string16 title = child_process_.name(); |
| 821 if (title.empty()) { | 822 if (title.empty()) { |
| 822 switch (child_process_.type()) { | 823 switch (child_process_.type()) { |
| 823 case ChildProcessInfo::PLUGIN_PROCESS: | 824 case content::PROCESS_TYPE_PLUGIN: |
| 824 case ChildProcessInfo::PPAPI_PLUGIN_PROCESS: | 825 case content::PROCESS_TYPE_PPAPI_PLUGIN: |
| 825 case ChildProcessInfo::PPAPI_BROKER_PROCESS: | 826 case content::PROCESS_TYPE_PPAPI_BROKER: |
| 826 title = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME); | 827 title = l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UNKNOWN_PLUGIN_NAME); |
| 827 break; | 828 break; |
| 828 default: | 829 default: |
| 829 // Nothing to do for non-plugin processes. | 830 // Nothing to do for non-plugin processes. |
| 830 break; | 831 break; |
| 831 } | 832 } |
| 832 } | 833 } |
| 833 | 834 |
| 834 // Explicitly mark name as LTR if there is no strong RTL character, | 835 // Explicitly mark name as LTR if there is no strong RTL character, |
| 835 // to avoid the wrong concatenation result similar to "!Yahoo Mail: the | 836 // to avoid the wrong concatenation result similar to "!Yahoo Mail: the |
| 836 // best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew | 837 // best web-based Email: NIGULP", in which "NIGULP" stands for the Hebrew |
| 837 // or Arabic word for "plugin". | 838 // or Arabic word for "plugin". |
| 838 base::i18n::AdjustStringForLocaleDirection(&title); | 839 base::i18n::AdjustStringForLocaleDirection(&title); |
| 839 | 840 |
| 840 switch (child_process_.type()) { | 841 switch (child_process_.type()) { |
| 841 case ChildProcessInfo::UTILITY_PROCESS: | 842 case content::PROCESS_TYPE_UTILITY: |
| 842 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX); | 843 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX); |
| 843 | 844 |
| 844 case ChildProcessInfo::PROFILE_IMPORT_PROCESS: | 845 case content::PROCESS_TYPE_PROFILE_IMPORT: |
| 845 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX); | 846 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_UTILITY_PREFIX); |
| 846 | 847 |
| 847 case ChildProcessInfo::GPU_PROCESS: | 848 case content::PROCESS_TYPE_GPU: |
| 848 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_GPU_PREFIX); | 849 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_GPU_PREFIX); |
| 849 | 850 |
| 850 case ChildProcessInfo::NACL_BROKER_PROCESS: | 851 case content::PROCESS_TYPE_NACL_BROKER: |
| 851 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NACL_BROKER_PREFIX); | 852 return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NACL_BROKER_PREFIX); |
| 852 | 853 |
| 853 case ChildProcessInfo::PLUGIN_PROCESS: | 854 case content::PROCESS_TYPE_PLUGIN: |
| 854 case ChildProcessInfo::PPAPI_PLUGIN_PROCESS: | 855 case content::PROCESS_TYPE_PPAPI_PLUGIN: |
| 855 return l10n_util::GetStringFUTF16( | 856 return l10n_util::GetStringFUTF16( |
| 856 IDS_TASK_MANAGER_PLUGIN_PREFIX, title, child_process_.version()); | 857 IDS_TASK_MANAGER_PLUGIN_PREFIX, title, child_process_.version()); |
| 857 | 858 |
| 858 case ChildProcessInfo::PPAPI_BROKER_PROCESS: | 859 case content::PROCESS_TYPE_PPAPI_BROKER: |
| 859 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PLUGIN_BROKER_PREFIX, | 860 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_PLUGIN_BROKER_PREFIX, |
| 860 title, child_process_.version()); | 861 title, child_process_.version()); |
| 861 | 862 |
| 862 case ChildProcessInfo::NACL_LOADER_PROCESS: | 863 case content::PROCESS_TYPE_NACL_LOADER: |
| 863 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NACL_PREFIX, title); | 864 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NACL_PREFIX, title); |
| 864 | 865 |
| 865 // These types don't need display names or get them from elsewhere. | 866 // These types don't need display names or get them from elsewhere. |
| 866 case ChildProcessInfo::BROWSER_PROCESS: | 867 case content::PROCESS_TYPE_BROWSER: |
| 867 case ChildProcessInfo::RENDER_PROCESS: | 868 case content::PROCESS_TYPE_RENDERER: |
| 868 case ChildProcessInfo::ZYGOTE_PROCESS: | 869 case content::PROCESS_TYPE_ZYGOTE: |
| 869 case ChildProcessInfo::SANDBOX_HELPER_PROCESS: | 870 case content::PROCESS_TYPE_SANDBOX_HELPER: |
| 870 case ChildProcessInfo::MAX_PROCESS: | 871 case content::PROCESS_TYPE_MAX: |
| 871 NOTREACHED(); | 872 NOTREACHED(); |
| 872 break; | 873 break; |
| 873 | 874 |
| 874 case ChildProcessInfo::WORKER_PROCESS: | 875 case content::PROCESS_TYPE_WORKER: |
| 875 NOTREACHED() << "Workers are not handled by this provider."; | 876 NOTREACHED() << "Workers are not handled by this provider."; |
| 876 break; | 877 break; |
| 877 | 878 |
| 878 case ChildProcessInfo::UNKNOWN_PROCESS: | 879 case content::PROCESS_TYPE_UNKNOWN: |
| 879 NOTREACHED() << "Need localized name for child process type."; | 880 NOTREACHED() << "Need localized name for child process type."; |
| 880 } | 881 } |
| 881 | 882 |
| 882 return title; | 883 return title; |
| 883 } | 884 } |
| 884 | 885 |
| 885 //////////////////////////////////////////////////////////////////////////////// | 886 //////////////////////////////////////////////////////////////////////////////// |
| 886 // TaskManagerChildProcessResourceProvider class | 887 // TaskManagerChildProcessResourceProvider class |
| 887 //////////////////////////////////////////////////////////////////////////////// | 888 //////////////////////////////////////////////////////////////////////////////// |
| 888 | 889 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 NOTREACHED() << "Unexpected notification."; | 963 NOTREACHED() << "Unexpected notification."; |
| 963 return; | 964 return; |
| 964 } | 965 } |
| 965 } | 966 } |
| 966 | 967 |
| 967 void TaskManagerChildProcessResourceProvider::Add( | 968 void TaskManagerChildProcessResourceProvider::Add( |
| 968 const ChildProcessInfo& child_process_info) { | 969 const ChildProcessInfo& child_process_info) { |
| 969 if (!updating_) | 970 if (!updating_) |
| 970 return; | 971 return; |
| 971 // Workers are handled by TaskManagerWorkerResourceProvider. | 972 // Workers are handled by TaskManagerWorkerResourceProvider. |
| 972 if (child_process_info.type() == ChildProcessInfo::WORKER_PROCESS) | 973 if (child_process_info.type() == content::PROCESS_TYPE_WORKER) |
| 973 return; | 974 return; |
| 974 std::map<ChildProcessInfo, TaskManagerChildProcessResource*>:: | 975 std::map<ChildProcessInfo, TaskManagerChildProcessResource*>:: |
| 975 const_iterator iter = resources_.find(child_process_info); | 976 const_iterator iter = resources_.find(child_process_info); |
| 976 if (iter != resources_.end()) { | 977 if (iter != resources_.end()) { |
| 977 // The case may happen that we have added a child_process_info as part of | 978 // The case may happen that we have added a child_process_info as part of |
| 978 // the iteration performed during StartUpdating() call but the notification | 979 // the iteration performed during StartUpdating() call but the notification |
| 979 // that it has connected was not fired yet. So when the notification | 980 // that it has connected was not fired yet. So when the notification |
| 980 // happens, we already know about this plugin and just ignore it. | 981 // happens, we already know about this plugin and just ignore it. |
| 981 return; | 982 return; |
| 982 } | 983 } |
| 983 AddToTaskManager(child_process_info); | 984 AddToTaskManager(child_process_info); |
| 984 } | 985 } |
| 985 | 986 |
| 986 void TaskManagerChildProcessResourceProvider::Remove( | 987 void TaskManagerChildProcessResourceProvider::Remove( |
| 987 const ChildProcessInfo& child_process_info) { | 988 const ChildProcessInfo& child_process_info) { |
| 988 if (!updating_) | 989 if (!updating_) |
| 989 return; | 990 return; |
| 990 if (child_process_info.type() == ChildProcessInfo::WORKER_PROCESS) | 991 if (child_process_info.type() == content::PROCESS_TYPE_WORKER) |
| 991 return; | 992 return; |
| 992 std::map<ChildProcessInfo, TaskManagerChildProcessResource*> | 993 std::map<ChildProcessInfo, TaskManagerChildProcessResource*> |
| 993 ::iterator iter = resources_.find(child_process_info); | 994 ::iterator iter = resources_.find(child_process_info); |
| 994 if (iter == resources_.end()) { | 995 if (iter == resources_.end()) { |
| 995 // ChildProcessInfo disconnection notifications are asynchronous, so we | 996 // ChildProcessInfo disconnection notifications are asynchronous, so we |
| 996 // might be notified for a plugin we don't know anything about (if it was | 997 // might be notified for a plugin we don't know anything about (if it was |
| 997 // closed before the task manager was shown and destroyed after that). | 998 // closed before the task manager was shown and destroyed after that). |
| 998 return; | 999 return; |
| 999 } | 1000 } |
| 1000 // Remove the resource from the Task Manager. | 1001 // Remove the resource from the Task Manager. |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 | 1392 |
| 1392 return &resource_; | 1393 return &resource_; |
| 1393 } | 1394 } |
| 1394 | 1395 |
| 1395 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1396 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
| 1396 task_manager_->AddResource(&resource_); | 1397 task_manager_->AddResource(&resource_); |
| 1397 } | 1398 } |
| 1398 | 1399 |
| 1399 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1400 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
| 1400 } | 1401 } |
| OLD | NEW |