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

Unified Diff: ios/chrome/browser/ios_chrome_main_parts.mm

Issue 2565013002: Split browser-specific and generic code in components/task_scheduler_util/. (Closed)
Patch Set: self-review Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ios_chrome_main_parts.mm
diff --git a/ios/chrome/browser/ios_chrome_main_parts.mm b/ios/chrome/browser/ios_chrome_main_parts.mm
index b225c56fc5e1e12c4355d923c511aecc7e71ef4c..a3ba139764371d1c063bd70e842bd0d7f464b1fe 100644
--- a/ios/chrome/browser/ios_chrome_main_parts.mm
+++ b/ios/chrome/browser/ios_chrome_main_parts.mm
@@ -31,11 +31,11 @@
#include "components/prefs/json_pref_store.h"
#include "components/prefs/pref_service.h"
#include "components/rappor/rappor_service_impl.h"
-#include "components/task_scheduler_util/initialization/browser_util.h"
-#include "components/task_scheduler_util/variations/browser_variations_util.h"
+#include "components/task_scheduler_util/browser.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/variations/field_trial_config/field_trial_util.h"
#include "components/variations/service/variations_service.h"
+#include "components/variations/variations_associated_data.h"
#include "components/variations/variations_http_header_provider.h"
#include "components/variations/variations_switches.h"
#include "ios/chrome/browser/about_flags.h"
@@ -73,59 +73,25 @@
namespace {
-std::vector<base::SchedulerWorkerPoolParams>
-GetDefaultSchedulerWorkerPoolParams() {
- using StandbyThreadPolicy =
- base::SchedulerWorkerPoolParams::StandbyThreadPolicy;
- constexpr size_t kNumWorkerPoolsDefined =
- sizeof(task_scheduler_util::initialization::
- BrowserWorkerPoolsConfiguration) /
- sizeof(
- task_scheduler_util::initialization::SingleWorkerPoolConfiguration);
- static_assert(kNumWorkerPoolsDefined == 4,
- "Expected 4 worker pools in BrowserWorkerPoolsConfiguration");
- task_scheduler_util::initialization::BrowserWorkerPoolsConfiguration config;
- constexpr size_t kSizeAssignedFields =
- sizeof(config.background.threads) +
- sizeof(config.background.detach_period) +
- sizeof(config.background.standby_thread_policy);
- static_assert(kSizeAssignedFields == sizeof(config.background),
- "Not all fields were assigned");
- config.background.standby_thread_policy = StandbyThreadPolicy::ONE;
- config.background.threads =
- base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0);
- config.background.detach_period = base::TimeDelta::FromSeconds(30);
-
- config.background_file_io.standby_thread_policy = StandbyThreadPolicy::ONE;
- config.background_file_io.threads =
- base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0);
- config.background_file_io.detach_period = base::TimeDelta::FromSeconds(30);
-
- config.foreground.standby_thread_policy = StandbyThreadPolicy::ONE;
- config.foreground.threads =
- base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0);
- config.foreground.detach_period = base::TimeDelta::FromSeconds(30);
-
- config.foreground_file_io.standby_thread_policy = StandbyThreadPolicy::ONE;
- config.foreground_file_io.threads =
- base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0);
- config.foreground_file_io.detach_period = base::TimeDelta::FromSeconds(30);
- return task_scheduler_util::initialization::
- BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams(config);
-}
-
void InitializeTaskScheduler() {
- std::vector<base::SchedulerWorkerPoolParams> params_vector =
- task_scheduler_util::variations::
- GetBrowserSchedulerWorkerPoolParamsFromVariations();
- if (params_vector.empty())
- params_vector = GetDefaultSchedulerWorkerPoolParams();
+ std::map<std::string, std::string> variation_params;
+ variations::GetVariationParams("BrowserScheduler", &variation_params);
+ auto params_vector =
+ task_scheduler_util::GetBrowserWorkerPoolParams(variation_params);
+ if (params_vector.empty()) {
+ variation_params["Background"] = "2;8;0.1;0;30000";
+ variation_params["BackgroundFileIO"] = "2;8;0.1;0;30000";
+ variation_params["Foreground"] = "3;8;0.3;0;30000";
+ variation_params["ForegroundFileIO"] = "3;8;0.3;0;30000";
+ params_vector =
+ task_scheduler_util::GetBrowserWorkerPoolParams(variation_params);
+ }
+ DCHECK(!params_vector.empty());
base::TaskScheduler::CreateAndSetDefaultTaskScheduler(
- params_vector, base::Bind(&task_scheduler_util::initialization::
- BrowserWorkerPoolIndexForTraits));
- task_scheduler_util::variations::
- MaybePerformBrowserTaskSchedulerRedirection();
+ params_vector,
+ base::Bind(&task_scheduler_util::BrowserWorkerPoolIndexForTraits));
+ task_scheduler_util::MaybePerformBrowserTaskSchedulerRedirection();
}
} // namespace
« components/task_scheduler_util/common/BUILD.gn ('K') | « ios/chrome/browser/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698