| 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 |
| 11 #include <sys/types.h> | 11 #include <sys/types.h> |
| 12 #ifdef OS_WIN | 12 #ifdef OS_WIN |
| 13 #include <windows.h> | 13 #include <windows.h> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 | 17 |
| 18 // ProcessHandle is a platform specific type which represents the underlying OS | 18 // ProcessHandle is a platform specific type which represents the underlying OS |
| 19 // handle to a process. | 19 // handle to a process. |
| 20 // ProcessId is a number which identifies the process in the OS. | 20 // ProcessId is a number which identifies the process in the OS. |
| 21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 22 typedef HANDLE ProcessHandle; | 22 typedef HANDLE ProcessHandle; |
| 23 typedef DWORD ProcessId; | 23 typedef DWORD ProcessId; |
| 24 const ProcessHandle kNullProcessHandle = NULL; |
| 24 #elif defined(OS_POSIX) | 25 #elif defined(OS_POSIX) |
| 25 // On POSIX, our ProcessHandle will just be the PID. | 26 // On POSIX, our ProcessHandle will just be the PID. |
| 26 typedef pid_t ProcessHandle; | 27 typedef pid_t ProcessHandle; |
| 27 typedef pid_t ProcessId; | 28 typedef pid_t ProcessId; |
| 29 const ProcessHandle kNullProcessHandle = 0; |
| 28 #endif | 30 #endif |
| 29 | 31 |
| 30 class Process { | 32 class Process { |
| 31 public: | 33 public: |
| 32 Process() : process_(0), last_working_set_size_(0) {} | 34 Process() : process_(kNullProcessHandle), last_working_set_size_(0) {} |
| 33 explicit Process(ProcessHandle handle) : | 35 explicit Process(ProcessHandle handle) : |
| 34 process_(handle), last_working_set_size_(0) {} | 36 process_(handle), last_working_set_size_(0) {} |
| 35 | 37 |
| 36 // A handle to the current process. | 38 // A handle to the current process. |
| 37 static Process Current(); | 39 static Process Current(); |
| 38 | 40 |
| 39 // Get/Set the handle for this process. The handle will be 0 if the process | 41 // Get/Set the handle for this process. The handle will be 0 if the process |
| 40 // is no longer running. | 42 // is no longer running. |
| 41 ProcessHandle handle() const { return process_; } | 43 ProcessHandle handle() const { return process_; } |
| 42 void set_handle(ProcessHandle handle) { process_ = handle; } | 44 void set_handle(ProcessHandle handle) { process_ = handle; } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 67 bool SetProcessBackgrounded(bool value); | 69 bool SetProcessBackgrounded(bool value); |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 ProcessHandle process_; | 72 ProcessHandle process_; |
| 71 size_t last_working_set_size_; | 73 size_t last_working_set_size_; |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 } // namespace base | 76 } // namespace base |
| 75 | 77 |
| 76 #endif // BASE_PROCESS_H_ | 78 #endif // BASE_PROCESS_H_ |
| OLD | NEW |