Remove all npapi plugins from windows metro chrome
[chromium-blink-merge.git] / base / process.h
blob7869b886455a9826f968e7a189bcbd27bf020d96
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_PROCESS_H_
6 #define BASE_PROCESS_H_
7 #pragma once
9 #include "base/base_export.h"
10 #include "base/basictypes.h"
11 #include "build/build_config.h"
13 #include <sys/types.h>
14 #if defined(OS_WIN)
15 #include <windows.h>
16 #endif
18 namespace base {
20 // ProcessHandle is a platform specific type which represents the underlying OS
21 // handle to a process.
22 // ProcessId is a number which identifies the process in the OS.
23 #if defined(OS_WIN)
24 typedef HANDLE ProcessHandle;
25 typedef DWORD ProcessId;
26 typedef HANDLE UserTokenHandle;
27 const ProcessHandle kNullProcessHandle = NULL;
28 const ProcessId kNullProcessId = 0;
29 #elif defined(OS_POSIX)
30 // On POSIX, our ProcessHandle will just be the PID.
31 typedef pid_t ProcessHandle;
32 typedef pid_t ProcessId;
33 const ProcessHandle kNullProcessHandle = 0;
34 const ProcessId kNullProcessId = 0;
35 #endif // defined(OS_WIN)
37 class BASE_EXPORT Process {
38 public:
39 Process() : process_(kNullProcessHandle) {
42 explicit Process(ProcessHandle handle) : process_(handle) {
45 // A handle to the current process.
46 static Process Current();
48 static bool CanBackgroundProcesses();
50 // Get/Set the handle for this process. The handle will be 0 if the process
51 // is no longer running.
52 ProcessHandle handle() const { return process_; }
53 void set_handle(ProcessHandle handle) {
54 process_ = handle;
57 // Get the PID for this process.
58 ProcessId pid() const;
60 // Is the this process the current process.
61 bool is_current() const;
63 // Close the process handle. This will not terminate the process.
64 void Close();
66 // Terminates the process with extreme prejudice. The given result code will
67 // be the exit code of the process. If the process has already exited, this
68 // will do nothing.
69 void Terminate(int result_code);
71 // A process is backgrounded when it's priority is lower than normal.
72 // Return true if this process is backgrounded, false otherwise.
73 bool IsProcessBackgrounded() const;
75 // Set a process as backgrounded. If value is true, the priority
76 // of the process will be lowered. If value is false, the priority
77 // of the process will be made "normal" - equivalent to default
78 // process priority.
79 // Returns true if the priority was changed, false otherwise.
80 bool SetProcessBackgrounded(bool value);
82 // Returns an integer representing the priority of a process. The meaning
83 // of this value is OS dependent.
84 int GetPriority() const;
86 private:
87 ProcessHandle process_;
90 } // namespace base
92 #endif // BASE_PROCESS_H_