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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "build/build_config.h" |
| 13 #include "base/strings/string_piece.h" |
12 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 14 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
13 #include "base/threading/platform_thread.h" | 15 #include "base/threading/platform_thread.h" |
14 | 16 |
| 17 namespace base { |
| 18 class CommandLine; |
| 19 } |
| 20 |
15 namespace task_scheduler_util { | 21 namespace task_scheduler_util { |
16 | 22 |
17 class SchedulerImmutableWorkerPoolParams { | 23 class SchedulerImmutableWorkerPoolParams { |
18 public: | 24 public: |
19 SchedulerImmutableWorkerPoolParams(const char* name, | 25 SchedulerImmutableWorkerPoolParams(const char* name, |
20 base::ThreadPriority priority_hint); | 26 base::ThreadPriority priority_hint); |
21 | 27 |
22 const char* name() const { return name_; } | 28 const char* name() const { return name_; } |
23 base::ThreadPriority priority_hint() const { return priority_hint_; } | 29 base::ThreadPriority priority_hint() const { return priority_hint_; } |
24 | 30 |
25 private: | 31 private: |
26 const char* name_; | 32 const char* name_; |
27 base::ThreadPriority priority_hint_; | 33 base::ThreadPriority priority_hint_; |
28 }; | 34 }; |
29 | 35 |
30 // Returns a SchedulerWorkerPoolParams vector to initialize pools specified in | 36 // Returns a SchedulerWorkerPoolParams vector to initialize pools specified in |
31 // |constant_worker_pool_params_vector|. SchedulerWorkerPoolParams members | 37 // |constant_worker_pool_params_vector|. SchedulerWorkerPoolParams members |
32 // without a counterpart in SchedulerImmutableWorkerPoolParams are initialized | 38 // without a counterpart in SchedulerImmutableWorkerPoolParams are initialized |
33 // based of |variation_params|. Returns an empty vector on failure. | 39 // based of |variation_params|. Returns an empty vector on failure. |
34 std::vector<base::SchedulerWorkerPoolParams> GetWorkerPoolParams( | 40 std::vector<base::SchedulerWorkerPoolParams> GetWorkerPoolParams( |
35 const std::vector<SchedulerImmutableWorkerPoolParams>& | 41 const std::vector<SchedulerImmutableWorkerPoolParams>& |
36 constant_worker_pool_params_vector, | 42 constant_worker_pool_params_vector, |
37 const std::map<std::string, std::string>& variation_params); | 43 const std::map<std::string, std::string>& variation_params); |
38 | 44 |
| 45 #if !defined(OS_IOS) |
| 46 // Serializes variation params from the BrowserScheduler field trial whose key |
| 47 // start with |prefix| to the --task-scheduler-variation-params switch of |
| 48 // |command_line|. |
| 49 void AddVariationParamsToCommandLine(base::StringPiece key_prefix, |
| 50 base::CommandLine* command_line); |
| 51 |
| 52 // Returns a map of key-value pairs deserialized from the |
| 53 // --task-scheduler-variation-params switch of |command_line|. |
| 54 std::map<std::string, std::string> GetVariationParamsFromCommandLine( |
| 55 const base::CommandLine& command_line); |
| 56 #endif // !defined(OS_IOS) |
| 57 |
39 } // namespace task_scheduler_util | 58 } // namespace task_scheduler_util |
40 | 59 |
41 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ | 60 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ |
OLD | NEW |