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

Side by Side Diff: base/process.h

Issue 57062: Use portable typedef for PIDs (process IDs). (Closed)
Patch Set: speculative fix for win Created 11 years, 8 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
« no previous file with comments | « no previous file | base/process_posix.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) 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 9
10 #include <sys/types.h>
10 #ifdef OS_WIN 11 #ifdef OS_WIN
11 #include <windows.h> 12 #include <windows.h>
12 #endif 13 #endif
13 14
14 namespace base { 15 namespace base {
15 16
16 // ProcessHandle is a platform specific type which represents the underlying OS 17 // ProcessHandle is a platform specific type which represents the underlying OS
17 // handle to a process. 18 // handle to a process.
19 // ProcessId is a number which identifies the process in the OS.
18 #if defined(OS_WIN) 20 #if defined(OS_WIN)
19 typedef HANDLE ProcessHandle; 21 typedef HANDLE ProcessHandle;
22 typedef DWORD ProcessId;
20 #elif defined(OS_POSIX) 23 #elif defined(OS_POSIX)
21 // On POSIX, our ProcessHandle will just be the PID. 24 // On POSIX, our ProcessHandle will just be the PID.
22 typedef int ProcessHandle; 25 typedef pid_t ProcessHandle;
26 typedef pid_t ProcessId;
23 #endif 27 #endif
24 28
25 class Process { 29 class Process {
26 public: 30 public:
27 Process() : process_(0), last_working_set_size_(0) {} 31 Process() : process_(0), last_working_set_size_(0) {}
28 explicit Process(ProcessHandle handle) : 32 explicit Process(ProcessHandle handle) :
29 process_(handle), last_working_set_size_(0) {} 33 process_(handle), last_working_set_size_(0) {}
30 34
31 // A handle to the current process. 35 // A handle to the current process.
32 static Process Current(); 36 static Process Current();
33 37
34 // Get/Set the handle for this process. The handle will be 0 if the process 38 // Get/Set the handle for this process. The handle will be 0 if the process
35 // is no longer running. 39 // is no longer running.
36 ProcessHandle handle() const { return process_; } 40 ProcessHandle handle() const { return process_; }
37 void set_handle(ProcessHandle handle) { process_ = handle; } 41 void set_handle(ProcessHandle handle) { process_ = handle; }
38 42
39 // Get the PID for this process. 43 // Get the PID for this process.
40 int32 pid() const; 44 ProcessId pid() const;
41 45
42 // Is the this process the current process. 46 // Is the this process the current process.
43 bool is_current() const; 47 bool is_current() const;
44 48
45 // Close the process handle. This will not terminate the process. 49 // Close the process handle. This will not terminate the process.
46 void Close(); 50 void Close();
47 51
48 // Terminates the process with extreme prejudice. The given result code will 52 // Terminates the process with extreme prejudice. The given result code will
49 // be the exit code of the process. If the process has already exited, this 53 // be the exit code of the process. If the process has already exited, this
50 // will do nothing. 54 // will do nothing.
(...skipping 29 matching lines...) Expand all
80 bool EmptyWorkingSet(); 84 bool EmptyWorkingSet();
81 85
82 private: 86 private:
83 ProcessHandle process_; 87 ProcessHandle process_;
84 size_t last_working_set_size_; 88 size_t last_working_set_size_;
85 }; 89 };
86 90
87 } // namespace base 91 } // namespace base
88 92
89 #endif // BASE_PROCESS_H_ 93 #endif // BASE_PROCESS_H_
OLDNEW
« no previous file with comments | « no previous file | base/process_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698