Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: base/process/process_mac.cc

Issue 2914913002: [Mac] Enable AppNap for renderers (Closed)
Patch Set: Add comment for magic numbers Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/process/process.h ('k') | chrome/app/helper-Info.plist » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <mach/mach.h> 7 #include <mach/mach.h>
8 8
9 #include "base/feature_list.h" 9 #include "base/feature_list.h"
10 #include "base/mac/mach_logging.h" 10 #include "base/mac/mach_logging.h"
11 #include "base/metrics/field_trial_params.h"
11 12
12 namespace base { 13 namespace base {
13 14
15 namespace {
16 const char kAppNapFeatureParamName[] = "app_nap";
17 }
18
14 // Enables backgrounding hidden renderers on Mac. 19 // Enables backgrounding hidden renderers on Mac.
15 const Feature kMacAllowBackgroundingProcesses{"MacAllowBackgroundingProcesses", 20 const Feature kMacAllowBackgroundingProcesses{"MacAllowBackgroundingProcesses",
16 FEATURE_DISABLED_BY_DEFAULT}; 21 FEATURE_DISABLED_BY_DEFAULT};
17 22
23 bool Process::IsAppNapEnabled() {
24 return !base::GetFieldTrialParamValueByFeature(
25 kMacAllowBackgroundingProcesses, kAppNapFeatureParamName)
26 .empty();
27 }
28
18 bool Process::CanBackgroundProcesses() { 29 bool Process::CanBackgroundProcesses() {
19 return FeatureList::IsEnabled(kMacAllowBackgroundingProcesses); 30 return FeatureList::IsEnabled(kMacAllowBackgroundingProcesses) &&
31 !IsAppNapEnabled();
20 } 32 }
21 33
22 bool Process::IsProcessBackgrounded(PortProvider* port_provider) const { 34 bool Process::IsProcessBackgrounded(PortProvider* port_provider) const {
23 DCHECK(IsValid()); 35 DCHECK(IsValid());
24 if (port_provider == nullptr || !CanBackgroundProcesses()) 36 if (port_provider == nullptr || !CanBackgroundProcesses())
25 return false; 37 return false;
26 38
27 mach_port_t task_port = port_provider->TaskForPid(Pid()); 39 mach_port_t task_port = port_provider->TaskForPid(Pid());
28 if (task_port == TASK_NULL) 40 if (task_port == TASK_NULL)
29 return false; 41 return false;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 TASK_QOS_POLICY_COUNT); 93 TASK_QOS_POLICY_COUNT);
82 if (result != KERN_SUCCESS) { 94 if (result != KERN_SUCCESS) {
83 MACH_LOG(ERROR, result) << "task_policy_set TASK_OVERRIDE_QOS_POLICY"; 95 MACH_LOG(ERROR, result) << "task_policy_set TASK_OVERRIDE_QOS_POLICY";
84 return false; 96 return false;
85 } 97 }
86 98
87 return true; 99 return true;
88 } 100 }
89 101
90 } // namespace base 102 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process.h ('k') | chrome/app/helper-Info.plist » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698