OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/test/chrome_process_util.h" | 5 #include "chrome/test/chrome_process_util.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 ChromeProcessList result; | 54 ChromeProcessList result; |
55 if (browser_pid == static_cast<base::ProcessId>(-1)) | 55 if (browser_pid == static_cast<base::ProcessId>(-1)) |
56 return result; | 56 return result; |
57 | 57 |
58 ChildProcessFilter filter(browser_pid); | 58 ChildProcessFilter filter(browser_pid); |
59 base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, &filter); | 59 base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, &filter); |
60 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) { | 60 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) { |
61 result.push_back(process_entry->pid()); | 61 result.push_back(process_entry->pid()); |
62 } | 62 } |
63 | 63 |
64 #if defined(OS_LINUX) | 64 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
65 // On Linux we might be running with a zygote process for the renderers. | 65 // On Unix we might be running with a zygote process for the renderers. |
66 // Because of that we sweep the list of processes again and pick those which | 66 // Because of that we sweep the list of processes again and pick those which |
67 // are children of one of the processes that we've already seen. | 67 // are children of one of the processes that we've already seen. |
68 { | 68 { |
69 ChildProcessFilter filter(result); | 69 ChildProcessFilter filter(result); |
70 base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, | 70 base::NamedProcessIterator it(chrome::kBrowserProcessExecutableName, |
71 &filter); | 71 &filter); |
72 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) | 72 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) |
73 result.push_back(process_entry->pid()); | 73 result.push_back(process_entry->pid()); |
74 } | 74 } |
75 #endif // defined(OS_LINUX) | 75 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) |
76 | 76 |
77 #if defined(OS_LINUX) || defined(OS_MACOSX) | 77 #if defined(OS_POSIX) |
78 // On Mac OS X we run the subprocesses with a different bundle, and | 78 // On Mac OS X we run the subprocesses with a different bundle, and |
79 // on Linux via /proc/self/exe, so they end up with a different | 79 // on Linux via /proc/self/exe, so they end up with a different |
80 // name. We must collect them in a second pass. | 80 // name. We must collect them in a second pass. |
81 { | 81 { |
82 ChildProcessFilter filter(browser_pid); | 82 ChildProcessFilter filter(browser_pid); |
83 base::NamedProcessIterator it(chrome::kHelperProcessExecutableName, | 83 base::NamedProcessIterator it(chrome::kHelperProcessExecutableName, |
84 &filter); | 84 &filter); |
85 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) | 85 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) |
86 result.push_back(process_entry->pid()); | 86 result.push_back(process_entry->pid()); |
87 } | 87 } |
(...skipping 22 matching lines...) Expand all Loading... |
110 base::ProcessHandle process) { | 110 base::ProcessHandle process) { |
111 #if !defined(OS_MACOSX) | 111 #if !defined(OS_MACOSX) |
112 process_metrics_.reset( | 112 process_metrics_.reset( |
113 base::ProcessMetrics::CreateProcessMetrics(process)); | 113 base::ProcessMetrics::CreateProcessMetrics(process)); |
114 #else | 114 #else |
115 process_metrics_.reset( | 115 process_metrics_.reset( |
116 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); | 116 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); |
117 #endif | 117 #endif |
118 process_handle_ = process; | 118 process_handle_ = process; |
119 } | 119 } |
OLD | NEW |