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" |
9 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
10 #include "base/win/windows_version.h" | 11 #include "base/win/windows_version.h" |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 DWORD kBasicProcessAccess = | 15 DWORD kBasicProcessAccess = |
15 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; | 16 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; |
16 | 17 |
17 } // namespace | 18 } // namespace |
18 | 19 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool Process::SetProcessBackgrounded(bool value) { | 159 bool Process::SetProcessBackgrounded(bool value) { |
159 DCHECK(IsValid()); | 160 DCHECK(IsValid()); |
160 // Vista and above introduce a real background mode, which not only | 161 // Vista and above introduce a real background mode, which not only |
161 // sets the priority class on the threads but also on the IO generated | 162 // sets the priority class on the threads but also on the IO generated |
162 // by it. Unfortunately it can only be set for the calling process. | 163 // by it. Unfortunately it can only be set for the calling process. |
163 DWORD priority; | 164 DWORD priority; |
164 if ((base::win::GetVersion() >= base::win::VERSION_VISTA) && (is_current())) { | 165 if ((base::win::GetVersion() >= base::win::VERSION_VISTA) && (is_current())) { |
165 priority = value ? PROCESS_MODE_BACKGROUND_BEGIN : | 166 priority = value ? PROCESS_MODE_BACKGROUND_BEGIN : |
166 PROCESS_MODE_BACKGROUND_END; | 167 PROCESS_MODE_BACKGROUND_END; |
167 } else { | 168 } else { |
168 priority = value ? BELOW_NORMAL_PRIORITY_CLASS : NORMAL_PRIORITY_CLASS; | 169 // Experiment (http://crbug.com/458594) with using IDLE_PRIORITY_CLASS as a |
| 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; |
169 } | 184 } |
170 | 185 |
171 return (::SetPriorityClass(Handle(), priority) != 0); | 186 return (::SetPriorityClass(Handle(), priority) != 0); |
172 } | 187 } |
173 | 188 |
174 int Process::GetPriority() const { | 189 int Process::GetPriority() const { |
175 DCHECK(IsValid()); | 190 DCHECK(IsValid()); |
176 return ::GetPriorityClass(Handle()); | 191 return ::GetPriorityClass(Handle()); |
177 } | 192 } |
178 | 193 |
179 } // namespace base | 194 } // namespace base |
OLD | NEW |