| 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/metrics/field_trial.h" |
| 10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
| 11 #include "base/process/kill.h" | 11 #include "base/process/kill.h" |
| 12 #include "base/strings/string_util.h" |
| 12 #include "base/win/windows_version.h" | 13 #include "base/win/windows_version.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 DWORD kBasicProcessAccess = | 17 DWORD kBasicProcessAccess = |
| 17 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; | 18 PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION | SYNCHRONIZE; |
| 18 | 19 |
| 19 } // namespace | 20 } // namespace |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // background priority for background renderers (this code path is | 183 // background priority for background renderers (this code path is |
| 183 // technically for more than just the renderers but they're the only use | 184 // technically for more than just the renderers but they're the only use |
| 184 // case in practice and experimenting here direclty is thus easier -- plus | 185 // case in practice and experimenting here direclty is thus easier -- plus |
| 185 // it doesn't really hurt as above we already state our intent of using | 186 // it doesn't really hurt as above we already state our intent of using |
| 186 // PROCESS_MODE_BACKGROUND_BEGIN if available which is essentially | 187 // PROCESS_MODE_BACKGROUND_BEGIN if available which is essentially |
| 187 // IDLE_PRIORITY_CLASS plus lowered IO priority). Enabled by default in the | 188 // IDLE_PRIORITY_CLASS plus lowered IO priority). Enabled by default in the |
| 188 // asbence of field trials to get coverage on the perf waterfall. | 189 // asbence of field trials to get coverage on the perf waterfall. |
| 189 DWORD background_priority = IDLE_PRIORITY_CLASS; | 190 DWORD background_priority = IDLE_PRIORITY_CLASS; |
| 190 base::FieldTrial* trial = | 191 base::FieldTrial* trial = |
| 191 base::FieldTrialList::Find("BackgroundRendererProcesses"); | 192 base::FieldTrialList::Find("BackgroundRendererProcesses"); |
| 192 if (trial && trial->group_name() == "AllowBelowNormalFromBrowser") | 193 if (trial && StartsWith(trial->group_name(), "AllowBelowNormalFromBrowser", |
| 194 CompareCase::SENSITIVE)) { |
| 193 background_priority = BELOW_NORMAL_PRIORITY_CLASS; | 195 background_priority = BELOW_NORMAL_PRIORITY_CLASS; |
| 196 } |
| 194 | 197 |
| 195 priority = value ? background_priority : NORMAL_PRIORITY_CLASS; | 198 priority = value ? background_priority : NORMAL_PRIORITY_CLASS; |
| 196 } | 199 } |
| 197 | 200 |
| 198 return (::SetPriorityClass(Handle(), priority) != 0); | 201 return (::SetPriorityClass(Handle(), priority) != 0); |
| 199 } | 202 } |
| 200 | 203 |
| 201 int Process::GetPriority() const { | 204 int Process::GetPriority() const { |
| 202 DCHECK(IsValid()); | 205 DCHECK(IsValid()); |
| 203 return ::GetPriorityClass(Handle()); | 206 return ::GetPriorityClass(Handle()); |
| 204 } | 207 } |
| 205 | 208 |
| 206 } // namespace base | 209 } // namespace base |
| OLD | NEW |