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/metrics/field_trial.h" | |
10 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
11 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
12 | 11 |
13 namespace { | 12 namespace { |
14 | 13 |
15 DWORD kBasicProcessAccess = | 14 DWORD kBasicProcessAccess = |
16 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; | 15 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; |
17 | 16 |
18 } // namespace | 17 } // namespace |
19 | 18 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 bool Process::SetProcessBackgrounded(bool value) { | 158 bool Process::SetProcessBackgrounded(bool value) { |
160 DCHECK(IsValid()); | 159 DCHECK(IsValid()); |
161 // Vista and above introduce a real background mode, which not only | 160 // Vista and above introduce a real background mode, which not only |
162 // sets the priority class on the threads but also on the IO generated | 161 // sets the priority class on the threads but also on the IO generated |
163 // by it. Unfortunately it can only be set for the calling process. | 162 // by it. Unfortunately it can only be set for the calling process. |
164 DWORD priority; | 163 DWORD priority; |
165 if ((base::win::GetVersion() >= base::win::VERSION_VISTA) && (is_current())) { | 164 if ((base::win::GetVersion() >= base::win::VERSION_VISTA) && (is_current())) { |
166 priority = value ? PROCESS_MODE_BACKGROUND_BEGIN : | 165 priority = value ? PROCESS_MODE_BACKGROUND_BEGIN : |
167 PROCESS_MODE_BACKGROUND_END; | 166 PROCESS_MODE_BACKGROUND_END; |
168 } else { | 167 } else { |
169 // Experiment (http://crbug.com/458594) with using IDLE_PRIORITY_CLASS as a | 168 priority = value ? BELOW_NORMAL_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS; |
170 // background priority for background renderers (this code path is | |
171 // technically for more than just the renderers but they're the only use | |
172 // case in practice and experimenting here direclty is thus easier -- plus | |
173 // it doesn't really hurt as above we already state our intent of using | |
174 // PROCESS_MODE_BACKGROUND_BEGIN if available which is essentially | |
175 // IDLE_PRIORITY_CLASS plus lowered IO priority). Enabled by default in the | |
176 // asbence of field trials to get coverage on the perf waterfall. | |
177 DWORD background_priority = IDLE_PRIORITY_CLASS; | |
178 base::FieldTrial* trial = | |
179 base::FieldTrialList::Find("BackgroundRendererProcesses"); | |
180 if (trial && trial->group_name() == "AllowBelowNormalFromBrowser") | |
181 background_priority = BELOW_NORMAL_PRIORITY_CLASS; | |
182 | |
183 priority = value ? background_priority : NORMAL_PRIORITY_CLASS; | |
184 } | 169 } |
185 | 170 |
186 return (::SetPriorityClass(Handle(), priority) != 0); | 171 return (::SetPriorityClass(Handle(), priority) != 0); |
187 } | 172 } |
188 | 173 |
189 int Process::GetPriority() const { | 174 int Process::GetPriority() const { |
190 DCHECK(IsValid()); | 175 DCHECK(IsValid()); |
191 return ::GetPriorityClass(Handle()); | 176 return ::GetPriorityClass(Handle()); |
192 } | 177 } |
193 | 178 |
194 } // namespace base | 179 } // namespace base |
OLD | NEW |