Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: chrome/test/base/chrome_process_util.cc

Issue 1354703002: Delete dead code related to the removed helper apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove verify_no_objc.sh as well Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/test/base/chrome_process_util.h" 5 #include "chrome/test/base/chrome_process_util.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/process/process.h" 12 #include "base/process/process.h"
13 #include "base/process/process_iterator.h" 13 #include "base/process/process_iterator.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "chrome/common/chrome_constants.h" 15 #include "chrome/common/chrome_constants.h"
16 #include "chrome/test/base/test_switches.h" 16 #include "chrome/test/base/test_switches.h"
17 #include "content/public/common/result_codes.h" 17 #include "content/public/common/result_codes.h"
18 18
19 using base::TimeDelta; 19 using base::TimeDelta;
20 using base::TimeTicks; 20 using base::TimeTicks;
21 21
22 namespace {
23
24 #if defined(OS_POSIX)
25 // Returns the executable name of the current Chrome helper process.
26 std::vector<base::FilePath::StringType> GetRunningHelperExecutableNames() {
27 base::FilePath::StringType name = chrome::kHelperProcessExecutableName;
28
29 std::vector<base::FilePath::StringType> names;
30 names.push_back(name);
31
32 #if defined(OS_MACOSX)
33 // The helper might show up as these different flavors depending on the
34 // executable flags required.
35 for (const char* const* suffix = chrome::kHelperFlavorSuffixes;
36 *suffix;
37 ++suffix) {
38 std::string flavor_name(name);
39 flavor_name.append(1, ' ');
40 flavor_name.append(*suffix);
41 names.push_back(flavor_name);
42 }
43 #endif
44
45 return names;
46 }
47 #endif // defined(OS_POSIX)
48
49 } // namespace
50
51 void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) { 22 void TerminateAllChromeProcesses(const ChromeProcessList& process_pids) {
52 ChromeProcessList::const_iterator it; 23 ChromeProcessList::const_iterator it;
53 for (it = process_pids.begin(); it != process_pids.end(); ++it) { 24 for (it = process_pids.begin(); it != process_pids.end(); ++it) {
54 base::Process process = base::Process::Open(*it); 25 base::Process process = base::Process::Open(*it);
55 if (process.IsValid()) { 26 if (process.IsValid()) {
56 // Ignore processes for which we can't open the handle. We don't 27 // Ignore processes for which we can't open the handle. We don't
57 // guarantee that all processes will terminate, only try to do so. 28 // guarantee that all processes will terminate, only try to do so.
58 process.Terminate(content::RESULT_CODE_KILLED, true); 29 process.Terminate(content::RESULT_CODE_KILLED, true);
59 } 30 }
60 } 31 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) 72 while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
102 result.push_back(process_entry->pid()); 73 result.push_back(process_entry->pid());
103 } 74 }
104 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 75 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
105 76
106 #if defined(OS_POSIX) 77 #if defined(OS_POSIX)
107 // 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
108 // 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
109 // name. We must collect them in a second pass. 80 // name. We must collect them in a second pass.
110 { 81 {
111 std::vector<base::FilePath::StringType> names = 82 base::FilePath::StringType name = chrome::kHelperProcessExecutableName;
112 GetRunningHelperExecutableNames(); 83 ChildProcessFilter filter(browser_pid);
113 for (size_t i = 0; i < names.size(); ++i) { 84 base::NamedProcessIterator it(name, &filter);
114 base::FilePath::StringType name = names[i]; 85 while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
115 ChildProcessFilter filter(browser_pid); 86 result.push_back(process_entry->pid());
116 base::NamedProcessIterator it(name, &filter);
117 while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
118 result.push_back(process_entry->pid());
119 }
120 } 87 }
121 #endif // defined(OS_POSIX) 88 #endif // defined(OS_POSIX)
122 89
123 result.push_back(browser_pid); 90 result.push_back(browser_pid);
124 91
125 return result; 92 return result;
126 } 93 }
127 94
128 #if !defined(OS_MACOSX) 95 #if !defined(OS_MACOSX)
129 96
(...skipping 13 matching lines...) Expand all
143 base::ProcessHandle process) { 110 base::ProcessHandle process) {
144 #if !defined(OS_MACOSX) 111 #if !defined(OS_MACOSX)
145 process_metrics_.reset( 112 process_metrics_.reset(
146 base::ProcessMetrics::CreateProcessMetrics(process)); 113 base::ProcessMetrics::CreateProcessMetrics(process));
147 #else 114 #else
148 process_metrics_.reset( 115 process_metrics_.reset(
149 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); 116 base::ProcessMetrics::CreateProcessMetrics(process, NULL));
150 #endif 117 #endif
151 process_handle_ = process; 118 process_handle_ = process;
152 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698