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

Side by Side Diff: base/process_util.h

Issue 10914279: Cleanup: Add a const variable for /proc/self/exe. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « base/base_paths_posix.cc ('k') | base/process_util_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // This file/namespace contains utility functions for enumerating, ending and 5 // This file/namespace contains utility functions for enumerating, ending and
6 // computing statistics of processes. 6 // computing statistics of processes.
7 7
8 #ifndef BASE_PROCESS_UTIL_H_ 8 #ifndef BASE_PROCESS_UTIL_H_
9 #define BASE_PROCESS_UTIL_H_ 9 #define BASE_PROCESS_UTIL_H_
10 10
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 const int kMaxOomScore = 1000; 198 const int kMaxOomScore = 1000;
199 199
200 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will 200 // This adjusts /proc/<pid>/oom_score_adj so the Linux OOM killer will
201 // prefer to kill certain process types over others. The range for the 201 // prefer to kill certain process types over others. The range for the
202 // adjustment is [-1000, 1000], with [0, 1000] being user accessible. 202 // adjustment is [-1000, 1000], with [0, 1000] being user accessible.
203 // If the Linux system doesn't support the newer oom_score_adj range 203 // If the Linux system doesn't support the newer oom_score_adj range
204 // of [0, 1000], then we revert to using the older oom_adj, and 204 // of [0, 1000], then we revert to using the older oom_adj, and
205 // translate the given value into [0, 15]. Some aliasing of values 205 // translate the given value into [0, 15]. Some aliasing of values
206 // may occur in that case, of course. 206 // may occur in that case, of course.
207 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score); 207 BASE_EXPORT bool AdjustOOMScore(ProcessId process, int score);
208
209 // /proc/self/exe refers to the current executable.
210 BASE_EXPORT extern const char kProcSelfExe[];
208 #endif // defined(OS_LINUX) || defined(OS_ANDROID) 211 #endif // defined(OS_LINUX) || defined(OS_ANDROID)
209 212
210 #if defined(OS_POSIX) 213 #if defined(OS_POSIX)
211 // Returns the ID for the parent of the given process. 214 // Returns the ID for the parent of the given process.
212 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process); 215 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process);
213 216
214 // Close all file descriptors, except those which are a destination in the 217 // Close all file descriptors, except those which are a destination in the
215 // given multimap. Only call this function in a child process where you know 218 // given multimap. Only call this function in a child process where you know
216 // that there aren't any other threads. 219 // that there aren't any other threads.
217 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map); 220 BASE_EXPORT void CloseSuperfluousFds(const InjectiveMultimap& saved_map);
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 public: 702 public:
700 ~ProcessMetrics(); 703 ~ProcessMetrics();
701 704
702 // Creates a ProcessMetrics for the specified process. 705 // Creates a ProcessMetrics for the specified process.
703 // The caller owns the returned object. 706 // The caller owns the returned object.
704 #if !defined(OS_MACOSX) || defined(OS_IOS) 707 #if !defined(OS_MACOSX) || defined(OS_IOS)
705 static ProcessMetrics* CreateProcessMetrics(ProcessHandle process); 708 static ProcessMetrics* CreateProcessMetrics(ProcessHandle process);
706 #else 709 #else
707 class PortProvider { 710 class PortProvider {
708 public: 711 public:
712 virtual ~PortProvider() {}
713
709 // Should return the mach task for |process| if possible, or else 714 // Should return the mach task for |process| if possible, or else
710 // |MACH_PORT_NULL|. Only processes that this returns tasks for will have 715 // |MACH_PORT_NULL|. Only processes that this returns tasks for will have
711 // metrics on OS X (except for the current process, which always gets 716 // metrics on OS X (except for the current process, which always gets
712 // metrics). 717 // metrics).
713 virtual mach_port_t TaskForPid(ProcessHandle process) const = 0; 718 virtual mach_port_t TaskForPid(ProcessHandle process) const = 0;
714 }; 719 };
715 720
716 // The port provider needs to outlive the ProcessMetrics object returned by 721 // The port provider needs to outlive the ProcessMetrics object returned by
717 // this function. If NULL is passed as provider, the returned object 722 // this function. If NULL is passed as provider, the returned object
718 // only returns valid metrics if |process| is the current process. 723 // only returns valid metrics if |process| is the current process.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 // instance running inside the parent. The parent's Breakpad instance should 863 // instance running inside the parent. The parent's Breakpad instance should
859 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler 864 // not handle the child's exceptions. Calling RestoreDefaultExceptionHandler
860 // in the child after forking will restore the standard exception handler. 865 // in the child after forking will restore the standard exception handler.
861 // See http://crbug.com/20371/ for more details. 866 // See http://crbug.com/20371/ for more details.
862 void RestoreDefaultExceptionHandler(); 867 void RestoreDefaultExceptionHandler();
863 #endif // defined(OS_MACOSX) 868 #endif // defined(OS_MACOSX)
864 869
865 } // namespace base 870 } // namespace base
866 871
867 #endif // BASE_PROCESS_UTIL_H_ 872 #endif // BASE_PROCESS_UTIL_H_
OLDNEW
« no previous file with comments | « base/base_paths_posix.cc ('k') | base/process_util_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698