ipc/chromium/src/base/process_win.cc

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.

michael@0 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
michael@0 2 // Use of this source code is governed by a BSD-style license that can be
michael@0 3 // found in the LICENSE file.
michael@0 4
michael@0 5 #include "base/process.h"
michael@0 6 #include "base/logging.h"
michael@0 7 #include "base/process_util.h"
michael@0 8 #include "base/scoped_ptr.h"
michael@0 9
michael@0 10 namespace base {
michael@0 11
michael@0 12 void Process::Close() {
michael@0 13 if (!process_)
michael@0 14 return;
michael@0 15 CloseProcessHandle(process_);
michael@0 16 process_ = NULL;
michael@0 17 }
michael@0 18
michael@0 19 void Process::Terminate(int result_code) {
michael@0 20 if (!process_)
michael@0 21 return;
michael@0 22 ::TerminateProcess(process_, result_code);
michael@0 23 }
michael@0 24
michael@0 25 bool Process::IsProcessBackgrounded() const {
michael@0 26 DCHECK(process_);
michael@0 27 DWORD priority = GetPriorityClass(process_);
michael@0 28 if (priority == 0)
michael@0 29 return false; // Failure case.
michael@0 30 return priority == BELOW_NORMAL_PRIORITY_CLASS;
michael@0 31 }
michael@0 32
michael@0 33 bool Process::SetProcessBackgrounded(bool value) {
michael@0 34 DCHECK(process_);
michael@0 35 DWORD priority = value ? BELOW_NORMAL_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS;
michael@0 36 return (SetPriorityClass(process_, priority) != 0);
michael@0 37 }
michael@0 38
michael@0 39 bool Process::EmptyWorkingSet() {
michael@0 40 if (!process_)
michael@0 41 return false;
michael@0 42
michael@0 43 BOOL rv = SetProcessWorkingSetSize(process_, -1, -1);
michael@0 44 return rv == TRUE;
michael@0 45 }
michael@0 46
michael@0 47 ProcessId Process::pid() const {
michael@0 48 if (process_ == 0)
michael@0 49 return 0;
michael@0 50
michael@0 51 return GetProcId(process_);
michael@0 52 }
michael@0 53
michael@0 54 bool Process::is_current() const {
michael@0 55 return process_ == GetCurrentProcess();
michael@0 56 }
michael@0 57
michael@0 58 // static
michael@0 59 Process Process::Current() {
michael@0 60 return Process(GetCurrentProcess());
michael@0 61 }
michael@0 62
michael@0 63 } // namespace base

mercurial