| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef BASE_PROCESS_H_ | 5 #ifndef BASE_PROCESS_H_ |
| 6 #define BASE_PROCESS_H_ | 6 #define BASE_PROCESS_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 typedef HANDLE ProcessHandle; | 22 typedef HANDLE ProcessHandle; |
| 23 typedef DWORD ProcessId; | 23 typedef DWORD ProcessId; |
| 24 const ProcessHandle kNullProcessHandle = NULL; | 24 const ProcessHandle kNullProcessHandle = NULL; |
| 25 #elif defined(OS_POSIX) | 25 #elif defined(OS_POSIX) |
| 26 // On POSIX, our ProcessHandle will just be the PID. | 26 // On POSIX, our ProcessHandle will just be the PID. |
| 27 typedef pid_t ProcessHandle; | 27 typedef pid_t ProcessHandle; |
| 28 typedef pid_t ProcessId; | 28 typedef pid_t ProcessId; |
| 29 const ProcessHandle kNullProcessHandle = 0; | 29 const ProcessHandle kNullProcessHandle = 0; |
| 30 #endif | 30 #endif |
| 31 | 31 |
| 32 #if defined(OS_LINUX) | 32 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 33 // saved_priority_ will be set to this to indicate that it's not holding | 33 // saved_priority_ will be set to this to indicate that it's not holding |
| 34 // a valid value. -20 to 19 are valid process priorities. | 34 // a valid value. -20 to 19 are valid process priorities. |
| 35 const int kUnsetProcessPriority = 256; | 35 const int kUnsetProcessPriority = 256; |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 class Process { | 38 class Process { |
| 39 public: | 39 public: |
| 40 Process() : process_(kNullProcessHandle) { | 40 Process() : process_(kNullProcessHandle) { |
| 41 #if defined(OS_LINUX) | 41 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 42 saved_priority_ = kUnsetProcessPriority; | 42 saved_priority_ = kUnsetProcessPriority; |
| 43 #endif | 43 #endif |
| 44 } | 44 } |
| 45 | 45 |
| 46 explicit Process(ProcessHandle handle) : process_(handle) { | 46 explicit Process(ProcessHandle handle) : process_(handle) { |
| 47 #if defined(OS_LINUX) | 47 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 48 saved_priority_ = kUnsetProcessPriority; | 48 saved_priority_ = kUnsetProcessPriority; |
| 49 #endif | 49 #endif |
| 50 } | 50 } |
| 51 | 51 |
| 52 // A handle to the current process. | 52 // A handle to the current process. |
| 53 static Process Current(); | 53 static Process Current(); |
| 54 | 54 |
| 55 // Get/Set the handle for this process. The handle will be 0 if the process | 55 // Get/Set the handle for this process. The handle will be 0 if the process |
| 56 // is no longer running. | 56 // is no longer running. |
| 57 ProcessHandle handle() const { return process_; } | 57 ProcessHandle handle() const { return process_; } |
| 58 void set_handle(ProcessHandle handle) { | 58 void set_handle(ProcessHandle handle) { |
| 59 process_ = handle; | 59 process_ = handle; |
| 60 #if defined(OS_LINUX) | 60 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 61 saved_priority_ = kUnsetProcessPriority; | 61 saved_priority_ = kUnsetProcessPriority; |
| 62 #endif | 62 #endif |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Get the PID for this process. | 65 // Get the PID for this process. |
| 66 ProcessId pid() const; | 66 ProcessId pid() const; |
| 67 | 67 |
| 68 // Is the this process the current process. | 68 // Is the this process the current process. |
| 69 bool is_current() const; | 69 bool is_current() const; |
| 70 | 70 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 86 // process priority. | 86 // process priority. |
| 87 // Returns true if the priority was changed, false otherwise. | 87 // Returns true if the priority was changed, false otherwise. |
| 88 bool SetProcessBackgrounded(bool value); | 88 bool SetProcessBackgrounded(bool value); |
| 89 | 89 |
| 90 // Returns an integer representing the priority of a process. The meaning | 90 // Returns an integer representing the priority of a process. The meaning |
| 91 // of this value is OS dependent. | 91 // of this value is OS dependent. |
| 92 int GetPriority() const; | 92 int GetPriority() const; |
| 93 | 93 |
| 94 private: | 94 private: |
| 95 ProcessHandle process_; | 95 ProcessHandle process_; |
| 96 #if defined(OS_LINUX) | 96 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 97 // Holds the priority that the process was set to when it was backgrounded. | 97 // Holds the priority that the process was set to when it was backgrounded. |
| 98 // If the process wasn't backgrounded it will be kUnsetProcessPriority. | 98 // If the process wasn't backgrounded it will be kUnsetProcessPriority. |
| 99 int saved_priority_; | 99 int saved_priority_; |
| 100 #endif | 100 #endif |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 } // namespace base | 103 } // namespace base |
| 104 | 104 |
| 105 #endif // BASE_PROCESS_H_ | 105 #endif // BASE_PROCESS_H_ |
| OLD | NEW |