| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/child_process_info.h" | 5 #include "chrome/common/child_process_info.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 | 15 |
| 16 std::wstring ChildProcessInfo::GetTypeNameInEnglish( | 16 std::wstring ChildProcessInfo::GetTypeNameInEnglish( |
| 17 ChildProcessInfo::ProcessType type) { | 17 ChildProcessInfo::ProcessType type) { |
| 18 switch (type) { | 18 switch (type) { |
| 19 case BROWSER_PROCESS: | 19 case BROWSER_PROCESS: |
| 20 return L"Browser"; | 20 return L"Browser"; |
| 21 case RENDER_PROCESS: | 21 case RENDER_PROCESS: |
| 22 return L"Tab"; | 22 return L"Tab"; |
| 23 case PLUGIN_PROCESS: | 23 case PLUGIN_PROCESS: |
| 24 return L"Plug-in"; | 24 return L"Plug-in"; |
| 25 case WORKER_PROCESS: | 25 case WORKER_PROCESS: |
| 26 return L"Web Worker"; | 26 return L"Web Worker"; |
| 27 case UTILITY_PROCESS: | 27 case UTILITY_PROCESS: |
| 28 return L"Utility"; | 28 return L"Utility"; |
| 29 case ZYGOTE_PROCESS: |
| 30 return L"Zygote"; |
| 31 case SANDBOX_HELPER_PROCESS: |
| 32 return L"Sandbox helper"; |
| 29 case UNKNOWN_PROCESS: | 33 case UNKNOWN_PROCESS: |
| 30 default: | 34 default: |
| 31 DCHECK(false) << "Unknown child process type!"; | 35 DCHECK(false) << "Unknown child process type!"; |
| 32 return L"Unknown"; | 36 return L"Unknown"; |
| 33 } | 37 } |
| 34 } | 38 } |
| 35 | 39 |
| 36 std::wstring ChildProcessInfo::GetLocalizedTitle() const { | 40 std::wstring ChildProcessInfo::GetLocalizedTitle() const { |
| 37 std::wstring title = name_; | 41 std::wstring title = name_; |
| 38 if (type_ == ChildProcessInfo::PLUGIN_PROCESS && title.empty()) | 42 if (type_ == ChildProcessInfo::PLUGIN_PROCESS && title.empty()) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // Note: the string must start with the current process id, this is how | 77 // Note: the string must start with the current process id, this is how |
| 74 // child processes determine the pid of the parent. | 78 // child processes determine the pid of the parent. |
| 75 // Build the channel ID. This is composed of a unique identifier for the | 79 // Build the channel ID. This is composed of a unique identifier for the |
| 76 // parent browser process, an identifier for the child instance, and a random | 80 // parent browser process, an identifier for the child instance, and a random |
| 77 // component. We use a random component so that a hacked child process can't | 81 // component. We use a random component so that a hacked child process can't |
| 78 // cause denial of service by causing future named pipe creation to fail. | 82 // cause denial of service by causing future named pipe creation to fail. |
| 79 return StringPrintf("%d.%x.%d", | 83 return StringPrintf("%d.%x.%d", |
| 80 base::GetCurrentProcId(), instance, | 84 base::GetCurrentProcId(), instance, |
| 81 base::RandInt(0, std::numeric_limits<int>::max())); | 85 base::RandInt(0, std::numeric_limits<int>::max())); |
| 82 } | 86 } |
| OLD | NEW |