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

Side by Side Diff: components/task_scheduler_util/common/variations_util.h

Issue 2749303002: [reference - do not submit] Always create four pools in TaskSchedulerImpl. (Closed)
Patch Set: rebase Created 3 years, 9 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
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 #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>
11 10
12 #include "build/build_config.h" 11 #include "build/build_config.h"
13 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
14 #include "base/task_scheduler/scheduler_worker_params.h" 13 #include "base/task_scheduler/scheduler_worker_params.h"
15 #include "base/task_scheduler/scheduler_worker_pool_params.h" 14 #include "base/task_scheduler/scheduler_worker_pool_params.h"
16 #include "base/threading/platform_thread.h"
17 15
18 namespace base { 16 namespace base {
19 class CommandLine; 17 class CommandLine;
20 } 18 }
21 19
22 namespace task_scheduler_util { 20 namespace task_scheduler_util {
23 21
24 class SchedulerImmutableWorkerPoolParams { 22 // Builds a SchedulerWorkerPoolParams from |pool_descriptor| and
25 public: 23 // |backward_compatibility|. Returns an invalid SchedulerWorkerPoolParams on
26 SchedulerImmutableWorkerPoolParams( 24 // failure.
27 const char* name, 25 //
28 base::ThreadPriority priority_hint, 26 // |pool_descriptor| is a semi-colon separated value string with the following
29 base::SchedulerBackwardCompatibility backward_compatibility = 27 // items:
30 base::SchedulerBackwardCompatibility::DISABLED); 28 // 0. Minimum Thread Count (int)
31 29 // 1. Maximum Thread Count (int)
32 const char* name() const { return name_; } 30 // 2. Thread Count Multiplier (double)
33 base::ThreadPriority priority_hint() const { return priority_hint_; } 31 // 3. Thread Count Offset (int)
34 base::SchedulerBackwardCompatibility backward_compatibility() const { 32 // 4. Detach Time in Milliseconds (int)
35 return backward_compatibility_; 33 // 5. Standby Thread Policy (string)
36 } 34 // Additional values may appear as necessary and will be ignored.
37 35 base::SchedulerWorkerPoolParams StringToVariableWorkerPoolParams(
38 private: 36 const base::StringPiece pool_descriptor,
39 const char* name_; 37 base::SchedulerBackwardCompatibility backward_compatibility =
40 base::ThreadPriority priority_hint_; 38 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);
52 39
53 #if !defined(OS_IOS) 40 #if !defined(OS_IOS)
54 // Serializes variation params from the BrowserScheduler field trial whose key 41 // Serializes variation params from the BrowserScheduler field trial whose key
55 // start with |prefix| to the --task-scheduler-variation-params switch of 42 // start with |prefix| to the --task-scheduler-variation-params switch of
56 // |command_line|. 43 // |command_line|.
57 void AddVariationParamsToCommandLine(base::StringPiece key_prefix, 44 void AddVariationParamsToCommandLine(base::StringPiece key_prefix,
58 base::CommandLine* command_line); 45 base::CommandLine* command_line);
59 46
60 // Returns a map of key-value pairs deserialized from the 47 // Returns a map of key-value pairs deserialized from the
61 // --task-scheduler-variation-params switch of |command_line|. 48 // --task-scheduler-variation-params switch of |command_line|.
62 std::map<std::string, std::string> GetVariationParamsFromCommandLine( 49 std::map<std::string, std::string> GetVariationParamsFromCommandLine(
63 const base::CommandLine& command_line); 50 const base::CommandLine& command_line);
64 #endif // !defined(OS_IOS) 51 #endif // !defined(OS_IOS)
65 52
66 } // namespace task_scheduler_util 53 } // namespace task_scheduler_util
67 54
68 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_ 55 #endif // COMPONENTS_TASK_SCHEDULER_UTIL_COMMON_VARIATIONS_UTIL_H_
OLDNEW
« no previous file with comments | « components/task_scheduler_util/browser/initialization.cc ('k') | components/task_scheduler_util/common/variations_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698