| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef BASE_PROCESS_PROCESS_H_ | 5 #ifndef BASE_PROCESS_PROCESS_H_ |
| 6 #define BASE_PROCESS_PROCESS_H_ | 6 #define BASE_PROCESS_PROCESS_H_ |
| 7 | 7 |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/move.h" | 10 #include "base/move.h" |
| 11 #include "base/process/process_handle.h" | 11 #include "base/process/process_handle.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 | 14 |
| 15 #if defined(OS_WIN) | |
| 16 #include "base/win/scoped_handle.h" | |
| 17 #endif | |
| 18 | |
| 19 namespace base { | 15 namespace base { |
| 20 | 16 |
| 21 // Provides a move-only encapsulation of a process. | 17 // Provides a move-only encapsulation of a process. |
| 22 // | 18 // |
| 23 // This object is not tied to the lifetime of the underlying process: the | 19 // This object is not tied to the lifetime of the underlying process: the |
| 24 // process may be killed and this object may still around, and it will still | 20 // process may be killed and this object may still around, and it will still |
| 25 // claim to be valid. The actual behavior in that case is OS dependent like so: | 21 // claim to be valid. The actual behavior in that case is OS dependent like so: |
| 26 // | 22 // |
| 27 // Windows: The underlying ProcessHandle will be valid after the process dies | 23 // Windows: The underlying ProcessHandle will be valid after the process dies |
| 28 // and can be used to gather some information about that process, but most | 24 // and can be used to gather some information about that process, but most |
| (...skipping 21 matching lines...) Expand all Loading... |
| 50 static Process Current(); | 46 static Process Current(); |
| 51 | 47 |
| 52 // Returns a Process for the given |pid|. | 48 // Returns a Process for the given |pid|. |
| 53 static Process Open(ProcessId pid); | 49 static Process Open(ProcessId pid); |
| 54 | 50 |
| 55 // Returns a Process for the given |pid|. On Windows the handle is opened | 51 // Returns a Process for the given |pid|. On Windows the handle is opened |
| 56 // with more access rights and must only be used by trusted code (can read the | 52 // with more access rights and must only be used by trusted code (can read the |
| 57 // address space and duplicate handles). | 53 // address space and duplicate handles). |
| 58 static Process OpenWithExtraPrivileges(ProcessId pid); | 54 static Process OpenWithExtraPrivileges(ProcessId pid); |
| 59 | 55 |
| 60 #if defined(OS_WIN) | |
| 61 // Returns a Process for the given |pid|, using some |desired_access|. | |
| 62 // See ::OpenProcess documentation for valid |desired_access|. | |
| 63 static Process OpenWithAccess(ProcessId pid, DWORD desired_access); | |
| 64 #endif | |
| 65 | |
| 66 // Creates an object from a |handle| owned by someone else. | 56 // Creates an object from a |handle| owned by someone else. |
| 67 // Don't use this for new code. It is only intended to ease the migration to | 57 // Don't use this for new code. It is only intended to ease the migration to |
| 68 // a strict ownership model. | 58 // a strict ownership model. |
| 69 // TODO(rvargas) crbug.com/417532: Remove this code. | 59 // TODO(rvargas) crbug.com/417532: Remove this code. |
| 70 static Process DeprecatedGetProcessFromHandle(ProcessHandle handle); | 60 static Process DeprecatedGetProcessFromHandle(ProcessHandle handle); |
| 71 | 61 |
| 72 // Returns true if processes can be backgrounded. | 62 // Returns true if processes can be backgrounded. |
| 73 static bool CanBackgroundProcesses(); | 63 static bool CanBackgroundProcesses(); |
| 74 | 64 |
| 75 // Returns true if this objects represents a valid process. | 65 // Returns true if this objects represents a valid process. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // process will be lowered. If value is false, the priority of the process | 127 // process will be lowered. If value is false, the priority of the process |
| 138 // will be made "normal" - equivalent to default process priority. | 128 // will be made "normal" - equivalent to default process priority. |
| 139 // Returns true if the priority was changed, false otherwise. | 129 // Returns true if the priority was changed, false otherwise. |
| 140 bool SetProcessBackgrounded(bool value); | 130 bool SetProcessBackgrounded(bool value); |
| 141 #endif // defined(OS_MACOSX) | 131 #endif // defined(OS_MACOSX) |
| 142 // Returns an integer representing the priority of a process. The meaning | 132 // Returns an integer representing the priority of a process. The meaning |
| 143 // of this value is OS dependent. | 133 // of this value is OS dependent. |
| 144 int GetPriority() const; | 134 int GetPriority() const; |
| 145 | 135 |
| 146 private: | 136 private: |
| 147 #if defined(OS_WIN) | |
| 148 bool is_current_process_; | |
| 149 win::ScopedHandle process_; | |
| 150 #else | |
| 151 ProcessHandle process_; | 137 ProcessHandle process_; |
| 152 #endif | |
| 153 }; | 138 }; |
| 154 | 139 |
| 155 } // namespace base | 140 } // namespace base |
| 156 | 141 |
| 157 #endif // BASE_PROCESS_PROCESS_H_ | 142 #endif // BASE_PROCESS_PROCESS_H_ |
| OLD | NEW |