OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chrome_content_browser_client.h" | 5 #include "chrome/browser/chrome_content_browser_client.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 // GetVariationParams has the side-effect of assigning the client to | 1212 // GetVariationParams has the side-effect of assigning the client to |
1213 // a field trial group. | 1213 // a field trial group. |
1214 std::map<std::string, std::string> params; | 1214 std::map<std::string, std::string> params; |
1215 if (variations::GetVariationParams(field_trial_name, ¶ms)) { | 1215 if (variations::GetVariationParams(field_trial_name, ¶ms)) { |
1216 for (const auto& param : params) { | 1216 for (const auto& param : params) { |
1217 blink_settings.push_back(base::StringPrintf( | 1217 blink_settings.push_back(base::StringPrintf( |
1218 "%s=%s", param.first.c_str(), param.second.c_str())); | 1218 "%s=%s", param.first.c_str(), param.second.c_str())); |
1219 } | 1219 } |
1220 } | 1220 } |
1221 } | 1221 } |
| 1222 |
| 1223 // Flags for the ResourcePriorities field trial. The settings are |
| 1224 // encoded in the field trial group name instead of as variations |
| 1225 // because the variations code is not accessible from the loader. |
| 1226 // |
| 1227 // The group name encoding looks like this: |
| 1228 // <descriptiveName>_ABCDE_E2_F_G |
| 1229 // A - fetchDeferLateScripts (1 for true, 0 for false) |
| 1230 // B - fetchIncreaseFontPriority (1 for true, 0 for false) |
| 1231 // C - fetchIncreaseAsyncScriptPriority (1 for true, 0 for false) |
| 1232 // D - fetchIncreasePriorities (1 for true, 0 for false) |
| 1233 // E - fetchEnableLayoutBlockingThreshold (1 for true, 0 for false) |
| 1234 // E2 - fetchLayoutBlockingThreshold (Numeric) |
| 1235 // F - fetchMaxNumDelayableWhileLayoutBlocking (Numeric) |
| 1236 // G - fetchMaxNumDelayableRequests (Numeric) |
| 1237 // |
| 1238 // Only A-D are relevant to blink and exposed as settings |
| 1239 // Any group names (Control, Default, etc) will not match the pattern or |
| 1240 // flags and will get the default settings which is the expected behavior. |
| 1241 std::string resource_priorities_trial_group = |
| 1242 base::FieldTrialList::FindFullName("ResourcePriorities"); |
| 1243 std::vector<std::string> split_group( |
| 1244 base::SplitString(resource_priorities_trial_group, "_", |
| 1245 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)); |
| 1246 if (split_group.size() == 5 && split_group[1].length() == 5) { |
| 1247 if (split_group[1].at(0) == '1') |
| 1248 blink_settings.push_back("fetchDeferLateScripts=true"); |
| 1249 if (split_group[1].at(1) == '1') |
| 1250 blink_settings.push_back("fetchIncreaseFontPriority=true"); |
| 1251 if (split_group[1].at(2) == '1') |
| 1252 blink_settings.push_back("fetchIncreaseAsyncScriptPriority=true"); |
| 1253 if (split_group[1].at(3) == '1') |
| 1254 blink_settings.push_back("fetchIncreasePriorities=true"); |
| 1255 } |
| 1256 |
1222 if (blink_settings.empty()) { | 1257 if (blink_settings.empty()) { |
1223 return; | 1258 return; |
1224 } | 1259 } |
1225 | 1260 |
1226 if (browser_command_line.HasSwitch(switches::kBlinkSettings) || | 1261 if (browser_command_line.HasSwitch(switches::kBlinkSettings) || |
1227 command_line->HasSwitch(switches::kBlinkSettings)) { | 1262 command_line->HasSwitch(switches::kBlinkSettings)) { |
1228 // The field trial is configured to force users that specify the | 1263 // The field trials should be configured to force users that specify the |
1229 // blink-settings flag into a group with no params, and we return | 1264 // blink-settings flag into a group with no params, and we return |
1230 // above if no params were specified, so it's an error if we reach | 1265 // above if no params were specified, so it's an error if we reach |
1231 // this point. | 1266 // this point. |
1232 LOG(WARNING) << "Received field trial params, " | 1267 LOG(WARNING) << "Received field trial params, " |
1233 "but blink-settings switch already specified."; | 1268 "but blink-settings switch already specified."; |
1234 return; | 1269 return; |
1235 } | 1270 } |
1236 | 1271 |
1237 command_line->AppendSwitchASCII(switches::kBlinkSettings, | 1272 command_line->AppendSwitchASCII(switches::kBlinkSettings, |
1238 base::JoinString(blink_settings, ",")); | 1273 base::JoinString(blink_settings, ",")); |
(...skipping 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2566 switches::kDisableWebRtcEncryption, | 2601 switches::kDisableWebRtcEncryption, |
2567 }; | 2602 }; |
2568 to_command_line->CopySwitchesFrom(from_command_line, | 2603 to_command_line->CopySwitchesFrom(from_command_line, |
2569 kWebRtcDevSwitchNames, | 2604 kWebRtcDevSwitchNames, |
2570 arraysize(kWebRtcDevSwitchNames)); | 2605 arraysize(kWebRtcDevSwitchNames)); |
2571 } | 2606 } |
2572 } | 2607 } |
2573 #endif // defined(ENABLE_WEBRTC) | 2608 #endif // defined(ENABLE_WEBRTC) |
2574 | 2609 |
2575 } // namespace chrome | 2610 } // namespace chrome |
OLD | NEW |