ipc/chromium/src/base/process.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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
     3 // found in the LICENSE file.
     5 #ifndef BASE_PROCESS_H_
     6 #define BASE_PROCESS_H_
     8 #include "base/basictypes.h"
    10 #include <sys/types.h>
    11 #ifdef OS_WIN
    12 #include <windows.h>
    13 #endif
    15 namespace base {
    17 // ProcessHandle is a platform specific type which represents the underlying OS
    18 // handle to a process.
    19 // ProcessId is a number which identifies the process in the OS.
    20 #if defined(OS_WIN)
    21 typedef HANDLE ProcessHandle;
    22 typedef DWORD ProcessId;
    23 #elif defined(OS_POSIX)
    24 // On POSIX, our ProcessHandle will just be the PID.
    25 typedef pid_t ProcessHandle;
    26 typedef pid_t ProcessId;
    27 #endif
    29 class Process {
    30  public:
    31   Process() : process_(0), last_working_set_size_(0) {}
    32   explicit Process(ProcessHandle handle) :
    33     process_(handle), last_working_set_size_(0) {}
    35   // A handle to the current process.
    36   static Process Current();
    38   // Get/Set the handle for this process. The handle will be 0 if the process
    39   // is no longer running.
    40   ProcessHandle handle() const { return process_; }
    41   void set_handle(ProcessHandle handle) { process_ = handle; }
    43   // Get the PID for this process.
    44   ProcessId pid() const;
    46   // Is the this process the current process.
    47   bool is_current() const;
    49   // Close the process handle. This will not terminate the process.
    50   void Close();
    52   // Terminates the process with extreme prejudice. The given result code will
    53   // be the exit code of the process. If the process has already exited, this
    54   // will do nothing.
    55   void Terminate(int result_code);
    57   // A process is backgrounded when it's priority is lower than normal.
    58   // Return true if this process is backgrounded, false otherwise.
    59   bool IsProcessBackgrounded() const;
    61   // Set a prcess as backgrounded.  If value is true, the priority
    62   // of the process will be lowered.  If value is false, the priority
    63   // of the process will be made "normal" - equivalent to default
    64   // process priority.
    65   // Returns true if the priority was changed, false otherwise.
    66   bool SetProcessBackgrounded(bool value);
    68   // Releases as much of the working set back to the OS as possible.
    69   // Returns true if successful, false otherwise.
    70   bool EmptyWorkingSet();
    72  private:
    73   ProcessHandle process_;
    74   size_t last_working_set_size_;
    75 };
    77 }  // namespace base
    79 #endif  // BASE_PROCESS_H_

mercurial