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 #ifndef COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ | 5 #ifndef COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ |
6 #define COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ | 6 #define COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | |
9 #include <string> | 10 #include <string> |
10 #include <vector> | |
11 | 11 |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "base/task_scheduler/scheduler_worker_params.h" | 14 #include "base/task_scheduler/scheduler_worker_params.h" |
15 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 15 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
16 #include "base/threading/platform_thread.h" | |
17 | 16 |
18 namespace base { | 17 namespace base { |
19 class CommandLine; | 18 class CommandLine; |
20 } | 19 } |
21 | 20 |
22 namespace task_scheduler_util { | 21 namespace task_scheduler_util { |
23 | 22 |
24 class SchedulerImmutableWorkerPoolParams { | 23 // Builds a SchedulerWorkerPoolParams from |pool_descriptor| and |
25 public: | 24 // |backward_compatibility|. Returns an invalid SchedulerWorkerPoolParams on |
26 SchedulerImmutableWorkerPoolParams( | 25 // failure. |
27 const char* name, | 26 // |
28 base::ThreadPriority priority_hint, | 27 // |pool_descriptor| is a semi-colon separated value string with the following |
29 base::SchedulerBackwardCompatibility backward_compatibility = | 28 // items: |
30 base::SchedulerBackwardCompatibility::DISABLED); | 29 // 0. Minimum Thread Count (int) |
31 | 30 // 1. Maximum Thread Count (int) |
32 const char* name() const { return name_; } | 31 // 2. Thread Count Multiplier (double) |
33 base::ThreadPriority priority_hint() const { return priority_hint_; } | 32 // 3. Thread Count Offset (int) |
34 base::SchedulerBackwardCompatibility backward_compatibility() const { | 33 // 4. Detach Time in Milliseconds (int) |
35 return backward_compatibility_; | 34 // 5. Standby Thread Policy (string) |
36 } | 35 // Additional values may appear as necessary and will be ignored. |
37 | 36 std::unique_ptr<base::SchedulerWorkerPoolParams> StringToWorkerPoolParams( |
38 private: | 37 const base::StringPiece pool_descriptor, |
39 const char* name_; | 38 base::SchedulerBackwardCompatibility backward_compatibility = |
40 base::ThreadPriority priority_hint_; | 39 base::SchedulerBackwardCompatibility::DISABLED); |
41 base::SchedulerBackwardCompatibility backward_compatibility_; | |
42 }; | |
43 | |
44 // Returns a SchedulerWorkerPoolParams vector to initialize pools specified in | |
45 // |constant_worker_pool_params_vector|. SchedulerWorkerPoolParams members | |
46 // without a counterpart in SchedulerImmutableWorkerPoolParams are initialized | |
47 // based of |variation_params|. Returns an empty vector on failure. | |
48 std::vector<base::SchedulerWorkerPoolParams> GetWorkerPoolParams( | |
49 const std::vector<SchedulerImmutableWorkerPoolParams>& | |
50 constant_worker_pool_params_vector, | |
51 const std::map<std::string, std::string>& variation_params); | |
robliao
2017/04/03 17:42:36
The browser and renderer have the same pool config
fdoray
2017/04/03 19:01:44
Done.
| |
52 | 40 |
53 #if !defined(OS_IOS) | 41 #if !defined(OS_IOS) |
54 // Serializes variation params from the BrowserScheduler field trial whose key | 42 // Serializes variation params from the BrowserScheduler field trial whose key |
55 // start with |prefix| to the --task-scheduler-variation-params switch of | 43 // start with |prefix| to the --task-scheduler-variation-params switch of |
56 // |command_line|. | 44 // |command_line|. |
57 void AddVariationParamsToCommandLine(base::StringPiece key_prefix, | 45 void AddVariationParamsToCommandLine(base::StringPiece key_prefix, |
58 base::CommandLine* command_line); | 46 base::CommandLine* command_line); |
59 | 47 |
60 // Returns a map of key-value pairs deserialized from the | 48 // Returns a map of key-value pairs deserialized from the |
61 // --task-scheduler-variation-params switch of |command_line|. | 49 // --task-scheduler-variation-params switch of |command_line|. |
62 std::map<std::string, std::string> GetVariationParamsFromCommandLine( | 50 std::map<std::string, std::string> GetVariationParamsFromCommandLine( |
63 const base::CommandLine& command_line); | 51 const base::CommandLine& command_line); |
64 #endif // !defined(OS_IOS) | 52 #endif // !defined(OS_IOS) |
65 | 53 |
66 } // namespace task_scheduler_util | 54 } // namespace task_scheduler_util |
67 | 55 |
68 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ | 56 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ |
OLD | NEW |