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

Side by Side Diff: base/process/process.h

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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 | « base/process/kill_posix.cc ('k') | base/process/process_mac.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) 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"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // be the exit code of the process. If |wait| is true, this method will wait 95 // be the exit code of the process. If |wait| is true, this method will wait
96 // for up to one minute for the process to actually terminate. 96 // for up to one minute for the process to actually terminate.
97 // Returns true if the process terminates within the allowed time. 97 // Returns true if the process terminates within the allowed time.
98 // NOTE: On POSIX |exit_code| is ignored. 98 // NOTE: On POSIX |exit_code| is ignored.
99 bool Terminate(int exit_code, bool wait) const; 99 bool Terminate(int exit_code, bool wait) const;
100 100
101 // Waits for the process to exit. Returns true on success. 101 // Waits for the process to exit. Returns true on success.
102 // On POSIX, if the process has been signaled then |exit_code| is set to -1. 102 // On POSIX, if the process has been signaled then |exit_code| is set to -1.
103 // On Linux this must be a child process, however on Mac and Windows it can be 103 // On Linux this must be a child process, however on Mac and Windows it can be
104 // any process. 104 // any process.
105 // NOTE: |exit_code| is optional, nullptr can be passed if the exit code is
106 // not required.
105 bool WaitForExit(int* exit_code); 107 bool WaitForExit(int* exit_code);
106 108
107 // Same as WaitForExit() but only waits for up to |timeout|. 109 // Same as WaitForExit() but only waits for up to |timeout|.
110 // NOTE: |exit_code| is optional, nullptr can be passed if the exit code
111 // is not required.
108 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code); 112 bool WaitForExitWithTimeout(TimeDelta timeout, int* exit_code);
109 113
114 #if defined(OS_MACOSX)
115 // The Mac needs a Mach port in order to manipulate a process's priority,
116 // and there's no good way to get that from base given the pid. These Mac
117 // variants of the IsProcessBackgrounded and SetProcessBackgrounded API take
118 // the Mach port for this reason. See crbug.com/460102
119 //
120 // A process is backgrounded when its priority is lower than normal.
121 // Return true if the process with mach port |task_port| is backgrounded,
122 // false otherwise.
123 bool IsProcessBackgrounded(mach_port_t task_port) const;
124
125 // Set the process with the specified mach port as backgrounded. If value is
126 // true, the priority of the process will be lowered. If value is false, the
127 // priority of the process will be made "normal" - equivalent to default
128 // process priority. Returns true if the priority was changed, false
129 // otherwise.
130 bool SetProcessBackgrounded(mach_port_t task_port, bool value);
131 #else
110 // A process is backgrounded when it's priority is lower than normal. 132 // A process is backgrounded when it's priority is lower than normal.
111 // Return true if this process is backgrounded, false otherwise. 133 // Return true if this process is backgrounded, false otherwise.
112 bool IsProcessBackgrounded() const; 134 bool IsProcessBackgrounded() const;
113 135
114 // Set a process as backgrounded. If value is true, the priority of the 136 // Set a process as backgrounded. If value is true, the priority of the
115 // process will be lowered. If value is false, the priority of the process 137 // process will be lowered. If value is false, the priority of the process
116 // will be made "normal" - equivalent to default process priority. 138 // will be made "normal" - equivalent to default process priority.
117 // Returns true if the priority was changed, false otherwise. 139 // Returns true if the priority was changed, false otherwise.
118 bool SetProcessBackgrounded(bool value); 140 bool SetProcessBackgrounded(bool value);
119 141 #endif // defined(OS_MACOSX)
120 // Returns an integer representing the priority of a process. The meaning 142 // Returns an integer representing the priority of a process. The meaning
121 // of this value is OS dependent. 143 // of this value is OS dependent.
122 int GetPriority() const; 144 int GetPriority() const;
123 145
124 private: 146 private:
125 #if defined(OS_WIN) 147 #if defined(OS_WIN)
126 bool is_current_process_; 148 bool is_current_process_;
127 win::ScopedHandle process_; 149 win::ScopedHandle process_;
128 #else 150 #else
129 ProcessHandle process_; 151 ProcessHandle process_;
130 #endif 152 #endif
131 }; 153 };
132 154
133 } // namespace base 155 } // namespace base
134 156
135 #endif // BASE_PROCESS_PROCESS_H_ 157 #endif // BASE_PROCESS_PROCESS_H_
OLDNEW
« no previous file with comments | « base/process/kill_posix.cc ('k') | base/process/process_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698