Wed, 31 Dec 2014 06:09:35 +0100
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 #include "base/process.h"
6 #include "base/logging.h"
7 #include "base/process_util.h"
8 #include "base/scoped_ptr.h"
10 namespace base {
12 void Process::Close() {
13 if (!process_)
14 return;
15 CloseProcessHandle(process_);
16 process_ = NULL;
17 }
19 void Process::Terminate(int result_code) {
20 if (!process_)
21 return;
22 ::TerminateProcess(process_, result_code);
23 }
25 bool Process::IsProcessBackgrounded() const {
26 DCHECK(process_);
27 DWORD priority = GetPriorityClass(process_);
28 if (priority == 0)
29 return false; // Failure case.
30 return priority == BELOW_NORMAL_PRIORITY_CLASS;
31 }
33 bool Process::SetProcessBackgrounded(bool value) {
34 DCHECK(process_);
35 DWORD priority = value ? BELOW_NORMAL_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS;
36 return (SetPriorityClass(process_, priority) != 0);
37 }
39 bool Process::EmptyWorkingSet() {
40 if (!process_)
41 return false;
43 BOOL rv = SetProcessWorkingSetSize(process_, -1, -1);
44 return rv == TRUE;
45 }
47 ProcessId Process::pid() const {
48 if (process_ == 0)
49 return 0;
51 return GetProcId(process_);
52 }
54 bool Process::is_current() const {
55 return process_ == GetCurrentProcess();
56 }
58 // static
59 Process Process::Current() {
60 return Process(GetCurrentProcess());
61 }
63 } // namespace base