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