OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/process/process.h" | 5 #include "base/process/process.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/numerics/safe_conversions.h" | 9 #include "base/numerics/safe_conversions.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
11 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 DWORD kBasicProcessAccess = | 15 DWORD kBasicProcessAccess = |
16 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; | 16 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace base { | 20 namespace base { |
21 | 21 |
22 Process::Process(ProcessHandle handle) | 22 Process::Process(ProcessHandle handle) |
23 : is_current_process_(false), | 23 : is_current_process_(false), |
24 process_(handle) { | 24 process_(handle) { |
25 CHECK_NE(handle, ::GetCurrentProcess()); | 25 CHECK_NE(handle, ::GetCurrentProcess()); |
26 } | 26 } |
27 | 27 |
28 Process::Process(RValue other) | 28 Process::Process(Process&& other) |
29 : is_current_process_(other.object->is_current_process_), | 29 : is_current_process_(other.is_current_process_), |
30 process_(other.object->process_.Take()) { | 30 process_(other.process_.Take()) { |
31 other.object->Close(); | 31 other.Close(); |
32 } | 32 } |
33 | 33 |
34 Process::~Process() { | 34 Process::~Process() { |
35 } | 35 } |
36 | 36 |
37 Process& Process::operator=(RValue other) { | 37 Process& Process::operator=(Process&& other) { |
38 if (this != other.object) { | 38 DCHECK_NE(this, &other); |
39 process_.Set(other.object->process_.Take()); | 39 process_.Set(other.process_.Take()); |
40 is_current_process_ = other.object->is_current_process_; | 40 is_current_process_ = other.is_current_process_; |
41 other.object->Close(); | 41 other.Close(); |
42 } | |
43 return *this; | 42 return *this; |
44 } | 43 } |
45 | 44 |
46 // static | 45 // static |
47 Process Process::Current() { | 46 Process Process::Current() { |
48 Process process; | 47 Process process; |
49 process.is_current_process_ = true; | 48 process.is_current_process_ = true; |
50 return process.Pass(); | 49 return process.Pass(); |
51 } | 50 } |
52 | 51 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 181 |
183 return (::SetPriorityClass(Handle(), priority) != 0); | 182 return (::SetPriorityClass(Handle(), priority) != 0); |
184 } | 183 } |
185 | 184 |
186 int Process::GetPriority() const { | 185 int Process::GetPriority() const { |
187 DCHECK(IsValid()); | 186 DCHECK(IsValid()); |
188 return ::GetPriorityClass(Handle()); | 187 return ::GetPriorityClass(Handle()); |
189 } | 188 } |
190 | 189 |
191 } // namespace base | 190 } // namespace base |
OLD | NEW |