Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "components/task_scheduler_util/initialization/browser_util.h" | 5 #include "components/task_scheduler_util/initialization/browser_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/task_scheduler/initialization_util.h" | 10 #include "base/task_scheduler/initialization_util.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 // Returns the worker pool index for |traits| defaulting to FOREGROUND or | 77 // Returns the worker pool index for |traits| defaulting to FOREGROUND or |
| 78 // FOREGROUND_FILE_IO on any other priorities. | 78 // FOREGROUND_FILE_IO on any other priorities. |
| 79 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits) { | 79 size_t BrowserWorkerPoolIndexForTraits(const base::TaskTraits& traits) { |
| 80 const bool is_background = | 80 const bool is_background = |
| 81 traits.priority() == base::TaskPriority::BACKGROUND; | 81 traits.priority() == base::TaskPriority::BACKGROUND; |
| 82 if (traits.with_file_io()) | 82 if (traits.with_file_io()) |
| 83 return is_background ? BACKGROUND_FILE_IO : FOREGROUND_FILE_IO; | 83 return is_background ? BACKGROUND_FILE_IO : FOREGROUND_FILE_IO; |
| 84 | 84 |
| 85 return is_background ? BACKGROUND : FOREGROUND; | 85 return is_background ? BACKGROUND : FOREGROUND; |
| 86 } | 86 } |
| 87 | 87 |
|
fdoray
2016/12/07 13:46:12
#if defined(OS_IOS) the whole function, to get a b
robliao
2016/12/08 01:04:22
Done. For correctness, this is also propagated to
| |
| 88 std::vector<base::SchedulerWorkerPoolParams> | 88 std::vector<base::SchedulerWorkerPoolParams> |
| 89 GetDefaultBrowserSchedulerWorkerPoolParams() { | 89 GetDefaultBrowserSchedulerWorkerPoolParams() { |
| 90 constexpr size_t kNumWorkerPoolsDefined = | 90 constexpr size_t kNumWorkerPoolsDefined = |
| 91 sizeof(BrowserWorkerPoolsConfiguration) / | 91 sizeof(BrowserWorkerPoolsConfiguration) / |
| 92 sizeof(SingleWorkerPoolConfiguration); | 92 sizeof(SingleWorkerPoolConfiguration); |
| 93 static_assert(kNumWorkerPoolsDefined == 4, | 93 static_assert(kNumWorkerPoolsDefined == 4, |
| 94 "Expected 4 worker pools in BrowserWorkerPoolsConfiguration"); | 94 "Expected 4 worker pools in BrowserWorkerPoolsConfiguration"); |
| 95 BrowserWorkerPoolsConfiguration config; | 95 BrowserWorkerPoolsConfiguration config; |
| 96 constexpr size_t kSizeAssignedFields = | 96 constexpr size_t kSizeAssignedFields = |
| 97 sizeof(config.background.threads) + | 97 sizeof(config.background.threads) + |
| 98 sizeof(config.background.detach_period) + | 98 sizeof(config.background.detach_period) + |
| 99 sizeof(config.background.standby_thread_policy); | 99 sizeof(config.background.standby_thread_policy); |
| 100 static_assert(kSizeAssignedFields == sizeof(config.background), | 100 static_assert(kSizeAssignedFields == sizeof(config.background), |
| 101 "Not all fields were assigned"); | 101 "Not all fields were assigned"); |
| 102 #if defined(OS_ANDROID) || defined(OS_IOS) | 102 #if defined(OS_IOS) |
| 103 config.background.standby_thread_policy = StandbyThreadPolicy::ONE; | 103 config.background.standby_thread_policy = StandbyThreadPolicy::ONE; |
| 104 config.background.threads = | 104 config.background.threads = |
| 105 base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0); | 105 base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0); |
| 106 config.background.detach_period = base::TimeDelta::FromSeconds(30); | 106 config.background.detach_period = base::TimeDelta::FromSeconds(30); |
| 107 | 107 |
| 108 config.background_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; | 108 config.background_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; |
| 109 config.background_file_io.threads = | 109 config.background_file_io.threads = |
| 110 base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0); | 110 base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0); |
| 111 config.background_file_io.detach_period = base::TimeDelta::FromSeconds(30); | 111 config.background_file_io.detach_period = base::TimeDelta::FromSeconds(30); |
| 112 | 112 |
| 113 config.foreground.standby_thread_policy = StandbyThreadPolicy::ONE; | 113 config.foreground.standby_thread_policy = StandbyThreadPolicy::ONE; |
| 114 config.foreground.threads = | 114 config.foreground.threads = |
| 115 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0); | 115 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0); |
| 116 config.foreground.detach_period = base::TimeDelta::FromSeconds(30); | 116 config.foreground.detach_period = base::TimeDelta::FromSeconds(30); |
| 117 | 117 |
| 118 config.foreground_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; | 118 config.foreground_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; |
| 119 config.foreground_file_io.threads = | 119 config.foreground_file_io.threads = |
| 120 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0); | 120 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0); |
| 121 config.foreground_file_io.detach_period = base::TimeDelta::FromSeconds(30); | 121 config.foreground_file_io.detach_period = base::TimeDelta::FromSeconds(30); |
| 122 #else | 122 #else |
| 123 config.background.standby_thread_policy = StandbyThreadPolicy::ONE; | 123 NOTREACHED() << "No default configuration available for this platform."; |
| 124 config.background.threads = | |
| 125 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0); | |
| 126 config.background.detach_period = base::TimeDelta::FromSeconds(30); | |
| 127 | |
| 128 config.background_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; | |
| 129 config.background_file_io.threads = | |
| 130 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.1, 0); | |
| 131 config.background_file_io.detach_period = base::TimeDelta::FromSeconds(30); | |
| 132 | |
| 133 config.foreground.standby_thread_policy = StandbyThreadPolicy::ONE; | |
| 134 config.foreground.threads = | |
| 135 base::RecommendedMaxNumberOfThreadsInPool(8, 32, 0.3, 0); | |
| 136 config.foreground.detach_period = base::TimeDelta::FromSeconds(30); | |
| 137 | |
| 138 config.foreground_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; | |
| 139 config.foreground_file_io.threads = | |
| 140 base::RecommendedMaxNumberOfThreadsInPool(8, 32, 0.3, 0); | |
| 141 config.foreground_file_io.detach_period = base::TimeDelta::FromSeconds(30); | |
| 142 #endif | 124 #endif |
| 143 return BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams(config); | 125 return BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams(config); |
| 144 } | 126 } |
| 145 | 127 |
| 146 } // namespace initialization | 128 } // namespace initialization |
| 147 } // namespace task_scheduler_util | 129 } // namespace task_scheduler_util |
| OLD | NEW |