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

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

Issue 7714018: Give plug-in processes an executable heap and disable PIE/ASLR for Native (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 | Annotate | Revision Log
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>
8 #include <string>
7 #include <vector> 9 #include <vector>
8 #include <set>
9 10
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/process_util.h" 12 #include "base/process_util.h"
12 #include "base/time.h" 13 #include "base/time.h"
13 #include "chrome/common/chrome_constants.h" 14 #include "chrome/common/chrome_constants.h"
14 #include "chrome/test/base/test_switches.h" 15 #include "chrome/test/base/test_switches.h"
15 #include "content/common/result_codes.h" 16 #include "content/common/result_codes.h"
16 17
17 using base::TimeDelta; 18 using base::TimeDelta;
18 using base::TimeTicks; 19 using base::TimeTicks;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DISALLOW_COPY_AND_ASSIGN(ChildProcessFilter); 53 DISALLOW_COPY_AND_ASSIGN(ChildProcessFilter);
53 }; 54 };
54 55
55 const FilePath::CharType* GetRunningBrowserExecutableName() { 56 const FilePath::CharType* GetRunningBrowserExecutableName() {
56 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 57 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
57 if (cmd_line->HasSwitch(switches::kEnableChromiumBranding)) 58 if (cmd_line->HasSwitch(switches::kEnableChromiumBranding))
58 return chrome::kBrowserProcessExecutableNameChromium; 59 return chrome::kBrowserProcessExecutableNameChromium;
59 return chrome::kBrowserProcessExecutableName; 60 return chrome::kBrowserProcessExecutableName;
60 } 61 }
61 62
62 const FilePath::CharType* GetRunningHelperExecutableName() { 63 std::vector<FilePath::StringType> GetRunningHelperExecutableNames() {
64 FilePath::StringType name;
63 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 65 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
64 if (cmd_line->HasSwitch(switches::kEnableChromiumBranding)) 66 if (cmd_line->HasSwitch(switches::kEnableChromiumBranding)) {
65 return chrome::kHelperProcessExecutableNameChromium; 67 name = chrome::kHelperProcessExecutableNameChromium;
66 return chrome::kHelperProcessExecutableName; 68 } else {
69 name = chrome::kHelperProcessExecutableName;
70 }
71
72 std::vector<FilePath::StringType> names;
73 names.push_back(name);
74
75 #if defined(OS_MACOSX)
76 // The helper might show up as these different flavors depending on the
77 // executable flags required.
78 for (const char* const* suffix = chrome::kHelperFlavorSuffixes;
79 *suffix;
80 ++suffix) {
81 std::string flavor_name(name);
82 flavor_name.append(1, ' ');
83 flavor_name.append(*suffix);
84 names.push_back(flavor_name);
85 }
86 #endif
87
88 return names;
67 } 89 }
68 90
69 ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) { 91 ChromeProcessList GetRunningChromeProcesses(base::ProcessId browser_pid) {
70 const FilePath::CharType* executable_name = GetRunningBrowserExecutableName(); 92 const FilePath::CharType* executable_name = GetRunningBrowserExecutableName();
71 ChromeProcessList result; 93 ChromeProcessList result;
72 if (browser_pid == static_cast<base::ProcessId>(-1)) 94 if (browser_pid == static_cast<base::ProcessId>(-1))
73 return result; 95 return result;
74 96
75 ChildProcessFilter filter(browser_pid); 97 ChildProcessFilter filter(browser_pid);
76 base::NamedProcessIterator it(executable_name, &filter); 98 base::NamedProcessIterator it(executable_name, &filter);
(...skipping 11 matching lines...) Expand all
88 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) 110 while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
89 result.push_back(process_entry->pid()); 111 result.push_back(process_entry->pid());
90 } 112 }
91 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) 113 #endif // defined(OS_POSIX) && !defined(OS_MACOSX)
92 114
93 #if defined(OS_POSIX) 115 #if defined(OS_POSIX)
94 // On Mac OS X we run the subprocesses with a different bundle, and 116 // On Mac OS X we run the subprocesses with a different bundle, and
95 // on Linux via /proc/self/exe, so they end up with a different 117 // on Linux via /proc/self/exe, so they end up with a different
96 // name. We must collect them in a second pass. 118 // name. We must collect them in a second pass.
97 { 119 {
98 ChildProcessFilter filter(browser_pid); 120 std::vector<FilePath::StringType> names = GetRunningHelperExecutableNames();
99 base::NamedProcessIterator it(GetRunningHelperExecutableName(), &filter); 121 for (size_t i = 0; i < names.size(); ++i) {
100 while (const base::ProcessEntry* process_entry = it.NextProcessEntry()) 122 FilePath::StringType name = names[i];
101 result.push_back(process_entry->pid()); 123 ChildProcessFilter filter(browser_pid);
124 base::NamedProcessIterator it(name, &filter);
125 while (const base::ProcessEntry* process_entry = it.NextProcessEntry())
126 result.push_back(process_entry->pid());
127 }
102 } 128 }
103 #endif // defined(OS_MACOSX) 129 #endif // defined(OS_POSIX)
104 130
105 result.push_back(browser_pid); 131 result.push_back(browser_pid);
106 132
107 return result; 133 return result;
108 } 134 }
109 135
110 #if !defined(OS_MACOSX) 136 #if !defined(OS_MACOSX)
111 137
112 size_t ChromeTestProcessMetrics::GetPagefileUsage() { 138 size_t ChromeTestProcessMetrics::GetPagefileUsage() {
113 return process_metrics_->GetPagefileUsage(); 139 return process_metrics_->GetPagefileUsage();
(...skipping 11 matching lines...) Expand all
125 base::ProcessHandle process) { 151 base::ProcessHandle process) {
126 #if !defined(OS_MACOSX) 152 #if !defined(OS_MACOSX)
127 process_metrics_.reset( 153 process_metrics_.reset(
128 base::ProcessMetrics::CreateProcessMetrics(process)); 154 base::ProcessMetrics::CreateProcessMetrics(process));
129 #else 155 #else
130 process_metrics_.reset( 156 process_metrics_.reset(
131 base::ProcessMetrics::CreateProcessMetrics(process, NULL)); 157 base::ProcessMetrics::CreateProcessMetrics(process, NULL));
132 #endif 158 #endif
133 process_handle_ = process; 159 process_handle_ = process;
134 } 160 }
OLDNEW
« no previous file with comments | « chrome/service/service_utility_process_host.cc ('k') | chrome/tools/build/mac/make_locale_dirs.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698