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 #include "ios/chrome/browser/ios_chrome_main_parts.h" | 5 #include "ios/chrome/browser/ios_chrome_main_parts.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "components/flags_ui/pref_service_flags_storage.h" | 24 #include "components/flags_ui/pref_service_flags_storage.h" |
25 #include "components/language_usage_metrics/language_usage_metrics.h" | 25 #include "components/language_usage_metrics/language_usage_metrics.h" |
26 #include "components/metrics/metrics_service.h" | 26 #include "components/metrics/metrics_service.h" |
27 #include "components/metrics/profiler/ios/ios_tracking_synchronizer_delegate.h" | 27 #include "components/metrics/profiler/ios/ios_tracking_synchronizer_delegate.h" |
28 #include "components/metrics/profiler/tracking_synchronizer.h" | 28 #include "components/metrics/profiler/tracking_synchronizer.h" |
29 #include "components/metrics_services_manager/metrics_services_manager.h" | 29 #include "components/metrics_services_manager/metrics_services_manager.h" |
30 #include "components/open_from_clipboard/clipboard_recent_content.h" | 30 #include "components/open_from_clipboard/clipboard_recent_content.h" |
31 #include "components/prefs/json_pref_store.h" | 31 #include "components/prefs/json_pref_store.h" |
32 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
33 #include "components/rappor/rappor_service_impl.h" | 33 #include "components/rappor/rappor_service_impl.h" |
34 #include "components/task_scheduler_util/initialization/browser_util.h" | 34 #include "components/task_scheduler_util/browser.h" |
35 #include "components/task_scheduler_util/variations/browser_variations_util.h" | |
36 #include "components/translate/core/browser/translate_download_manager.h" | 35 #include "components/translate/core/browser/translate_download_manager.h" |
37 #include "components/variations/field_trial_config/field_trial_util.h" | 36 #include "components/variations/field_trial_config/field_trial_util.h" |
38 #include "components/variations/service/variations_service.h" | 37 #include "components/variations/service/variations_service.h" |
| 38 #include "components/variations/variations_associated_data.h" |
39 #include "components/variations/variations_http_header_provider.h" | 39 #include "components/variations/variations_http_header_provider.h" |
40 #include "components/variations/variations_switches.h" | 40 #include "components/variations/variations_switches.h" |
41 #include "ios/chrome/browser/about_flags.h" | 41 #include "ios/chrome/browser/about_flags.h" |
42 #include "ios/chrome/browser/application_context_impl.h" | 42 #include "ios/chrome/browser/application_context_impl.h" |
43 #include "ios/chrome/browser/browser_state/browser_state_keyed_service_factories
.h" | 43 #include "ios/chrome/browser/browser_state/browser_state_keyed_service_factories
.h" |
44 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 44 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
45 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h" | 45 #include "ios/chrome/browser/browser_state/chrome_browser_state_manager.h" |
46 #include "ios/chrome/browser/chrome_paths.h" | 46 #include "ios/chrome/browser/chrome_paths.h" |
47 #include "ios/chrome/browser/chrome_switches.h" | 47 #include "ios/chrome/browser/chrome_switches.h" |
48 #include "ios/chrome/browser/chrome_url_constants.h" | 48 #include "ios/chrome/browser/chrome_url_constants.h" |
(...skipping 17 matching lines...) Expand all Loading... |
66 #include "components/rlz/rlz_tracker.h" // nogncheck | 66 #include "components/rlz/rlz_tracker.h" // nogncheck |
67 #include "ios/chrome/browser/rlz/rlz_tracker_delegate_impl.h" // nogncheck | 67 #include "ios/chrome/browser/rlz/rlz_tracker_delegate_impl.h" // nogncheck |
68 #endif | 68 #endif |
69 | 69 |
70 #if !defined(__has_feature) || !__has_feature(objc_arc) | 70 #if !defined(__has_feature) || !__has_feature(objc_arc) |
71 #error "This file requires ARC support." | 71 #error "This file requires ARC support." |
72 #endif | 72 #endif |
73 | 73 |
74 namespace { | 74 namespace { |
75 | 75 |
76 std::vector<base::SchedulerWorkerPoolParams> | |
77 GetDefaultSchedulerWorkerPoolParams() { | |
78 using StandbyThreadPolicy = | |
79 base::SchedulerWorkerPoolParams::StandbyThreadPolicy; | |
80 constexpr size_t kNumWorkerPoolsDefined = | |
81 sizeof(task_scheduler_util::initialization:: | |
82 BrowserWorkerPoolsConfiguration) / | |
83 sizeof( | |
84 task_scheduler_util::initialization::SingleWorkerPoolConfiguration); | |
85 static_assert(kNumWorkerPoolsDefined == 4, | |
86 "Expected 4 worker pools in BrowserWorkerPoolsConfiguration"); | |
87 task_scheduler_util::initialization::BrowserWorkerPoolsConfiguration config; | |
88 constexpr size_t kSizeAssignedFields = | |
89 sizeof(config.background.threads) + | |
90 sizeof(config.background.detach_period) + | |
91 sizeof(config.background.standby_thread_policy); | |
92 static_assert(kSizeAssignedFields == sizeof(config.background), | |
93 "Not all fields were assigned"); | |
94 config.background.standby_thread_policy = StandbyThreadPolicy::ONE; | |
95 config.background.threads = | |
96 base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0); | |
97 config.background.detach_period = base::TimeDelta::FromSeconds(30); | |
98 | |
99 config.background_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; | |
100 config.background_file_io.threads = | |
101 base::RecommendedMaxNumberOfThreadsInPool(2, 8, 0.1, 0); | |
102 config.background_file_io.detach_period = base::TimeDelta::FromSeconds(30); | |
103 | |
104 config.foreground.standby_thread_policy = StandbyThreadPolicy::ONE; | |
105 config.foreground.threads = | |
106 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0); | |
107 config.foreground.detach_period = base::TimeDelta::FromSeconds(30); | |
108 | |
109 config.foreground_file_io.standby_thread_policy = StandbyThreadPolicy::ONE; | |
110 config.foreground_file_io.threads = | |
111 base::RecommendedMaxNumberOfThreadsInPool(3, 8, 0.3, 0); | |
112 config.foreground_file_io.detach_period = base::TimeDelta::FromSeconds(30); | |
113 return task_scheduler_util::initialization:: | |
114 BrowserWorkerPoolConfigurationToSchedulerWorkerPoolParams(config); | |
115 } | |
116 | |
117 void InitializeTaskScheduler() { | 76 void InitializeTaskScheduler() { |
118 std::vector<base::SchedulerWorkerPoolParams> params_vector = | 77 std::map<std::string, std::string> variation_params; |
119 task_scheduler_util::variations:: | 78 variations::GetVariationParams("BrowserScheduler", &variation_params); |
120 GetBrowserSchedulerWorkerPoolParamsFromVariations(); | 79 auto params_vector = |
121 if (params_vector.empty()) | 80 task_scheduler_util::GetBrowserWorkerPoolParams(variation_params); |
122 params_vector = GetDefaultSchedulerWorkerPoolParams(); | 81 if (params_vector.empty()) { |
| 82 variation_params["Background"] = "2;8;0.1;0;30000"; |
| 83 variation_params["BackgroundFileIO"] = "2;8;0.1;0;30000"; |
| 84 variation_params["Foreground"] = "3;8;0.3;0;30000"; |
| 85 variation_params["ForegroundFileIO"] = "3;8;0.3;0;30000"; |
| 86 params_vector = |
| 87 task_scheduler_util::GetBrowserWorkerPoolParams(variation_params); |
| 88 } |
| 89 DCHECK(!params_vector.empty()); |
123 | 90 |
124 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( | 91 base::TaskScheduler::CreateAndSetDefaultTaskScheduler( |
125 params_vector, base::Bind(&task_scheduler_util::initialization:: | 92 params_vector, |
126 BrowserWorkerPoolIndexForTraits)); | 93 base::Bind(&task_scheduler_util::BrowserWorkerPoolIndexForTraits)); |
127 task_scheduler_util::variations:: | 94 task_scheduler_util::MaybePerformBrowserTaskSchedulerRedirection(); |
128 MaybePerformBrowserTaskSchedulerRedirection(); | |
129 } | 95 } |
130 | 96 |
131 } // namespace | 97 } // namespace |
132 | 98 |
133 IOSChromeMainParts::IOSChromeMainParts( | 99 IOSChromeMainParts::IOSChromeMainParts( |
134 const base::CommandLine& parsed_command_line) | 100 const base::CommandLine& parsed_command_line) |
135 : parsed_command_line_(parsed_command_line), local_state_(nullptr) { | 101 : parsed_command_line_(parsed_command_line), local_state_(nullptr) { |
136 // Chrome disallows cookies by default. All code paths that want to use | 102 // Chrome disallows cookies by default. All code paths that want to use |
137 // cookies need to go through one of Chrome's URLRequestContexts which have | 103 // cookies need to go through one of Chrome's URLRequestContexts which have |
138 // a ChromeNetworkDelegate attached that selectively allows cookies again. | 104 // a ChromeNetworkDelegate attached that selectively allows cookies again. |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 333 |
368 void IOSChromeMainParts::StartMetricsRecording() { | 334 void IOSChromeMainParts::StartMetricsRecording() { |
369 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); | 335 bool wifiOnly = local_state_->GetBoolean(prefs::kMetricsReportingWifiOnly); |
370 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( | 336 bool isConnectionCellular = net::NetworkChangeNotifier::IsConnectionCellular( |
371 net::NetworkChangeNotifier::GetConnectionType()); | 337 net::NetworkChangeNotifier::GetConnectionType()); |
372 bool mayUpload = !wifiOnly || !isConnectionCellular; | 338 bool mayUpload = !wifiOnly || !isConnectionCellular; |
373 | 339 |
374 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( | 340 application_context_->GetMetricsServicesManager()->UpdateUploadPermissions( |
375 mayUpload); | 341 mayUpload); |
376 } | 342 } |
OLD | NEW |