1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ipc/chromium/src/base/process_win.cc Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,63 @@ 1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1.5 +// Use of this source code is governed by a BSD-style license that can be 1.6 +// found in the LICENSE file. 1.7 + 1.8 +#include "base/process.h" 1.9 +#include "base/logging.h" 1.10 +#include "base/process_util.h" 1.11 +#include "base/scoped_ptr.h" 1.12 + 1.13 +namespace base { 1.14 + 1.15 +void Process::Close() { 1.16 + if (!process_) 1.17 + return; 1.18 + CloseProcessHandle(process_); 1.19 + process_ = NULL; 1.20 +} 1.21 + 1.22 +void Process::Terminate(int result_code) { 1.23 + if (!process_) 1.24 + return; 1.25 + ::TerminateProcess(process_, result_code); 1.26 +} 1.27 + 1.28 +bool Process::IsProcessBackgrounded() const { 1.29 + DCHECK(process_); 1.30 + DWORD priority = GetPriorityClass(process_); 1.31 + if (priority == 0) 1.32 + return false; // Failure case. 1.33 + return priority == BELOW_NORMAL_PRIORITY_CLASS; 1.34 +} 1.35 + 1.36 +bool Process::SetProcessBackgrounded(bool value) { 1.37 + DCHECK(process_); 1.38 + DWORD priority = value ? BELOW_NORMAL_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS; 1.39 + return (SetPriorityClass(process_, priority) != 0); 1.40 +} 1.41 + 1.42 +bool Process::EmptyWorkingSet() { 1.43 + if (!process_) 1.44 + return false; 1.45 + 1.46 + BOOL rv = SetProcessWorkingSetSize(process_, -1, -1); 1.47 + return rv == TRUE; 1.48 +} 1.49 + 1.50 +ProcessId Process::pid() const { 1.51 + if (process_ == 0) 1.52 + return 0; 1.53 + 1.54 + return GetProcId(process_); 1.55 +} 1.56 + 1.57 +bool Process::is_current() const { 1.58 + return process_ == GetCurrentProcess(); 1.59 +} 1.60 + 1.61 +// static 1.62 +Process Process::Current() { 1.63 + return Process(GetCurrentProcess()); 1.64 +} 1.65 + 1.66 +} // namespace base