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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 1230133005: Fix Resource Priorities and Scheduling (Chrome Side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added unit tests Created 5 years, 4 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 (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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 // GetVariationParams has the side-effect of assigning the client to 1211 // GetVariationParams has the side-effect of assigning the client to
1212 // a field trial group. 1212 // a field trial group.
1213 std::map<std::string, std::string> params; 1213 std::map<std::string, std::string> params;
1214 if (variations::GetVariationParams(field_trial_name, &params)) { 1214 if (variations::GetVariationParams(field_trial_name, &params)) {
1215 for (const auto& param : params) { 1215 for (const auto& param : params) {
1216 blink_settings.push_back(base::StringPrintf( 1216 blink_settings.push_back(base::StringPrintf(
1217 "%s=%s", param.first.c_str(), param.second.c_str())); 1217 "%s=%s", param.first.c_str(), param.second.c_str()));
1218 } 1218 }
1219 } 1219 }
1220 } 1220 }
1221
1222 // Flags for the ResourcePriorities field trial. The settings are
1223 // encoded in the field trial group name instead of as variations
1224 // because the variations code is not accessible from the loader.
1225 //
1226 // The group name encoding looks like this:
1227 // <descriptiveName>_ABCDE_E2_F_G
1228 // A - fetchDeferLateScripts (1 for true, 0 for false)
1229 // B - fetchIncreaseFontPriority (1 for true, 0 for false)
1230 // C - fetchIncreaseAsyncScriptPriority (1 for true, 0 for false)
1231 // D - fetchIncreasePriorities (1 for true, 0 for false)
1232 // E - fetchEnableLayoutBlockingThreshold (1 for true, 0 for false)
1233 // E2 - fetchLayoutBlockingThreshold (Numeric)
1234 // F - fetchMaxNumDelayableWhileLayoutBlocking (Numeric)
1235 // G - fetchMaxNumDelayableRequests (Numeric)
1236 //
1237 // Only A-D are relevant to blink and exposed as settings
1238 // Any group names (Control, Default, etc) will not match the pattern or
1239 // flags and will get the default settings which is the expected behavior.
1240 std::string resource_priorities_trial_group =
1241 base::FieldTrialList::FindFullName("ResourcePriorities");
1242 std::vector<std::string> split_group(
1243 base::SplitString(resource_priorities_trial_group, "_",
1244 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL));
1245 if (split_group.size() == 5 && split_group[1].length() == 5) {
1246 if (split_group[1].at(0) == '1')
1247 blink_settings.push_back("fetchDeferLateScripts=true");
1248 if (split_group[1].at(1) == '1')
1249 blink_settings.push_back("fetchIncreaseFontPriority=true");
1250 if (split_group[1].at(2) == '1')
1251 blink_settings.push_back("fetchIncreaseAsyncScriptPriority=true");
1252 if (split_group[1].at(3) == '1')
1253 blink_settings.push_back("fetchIncreasePriorities=true");
1254 }
1255
1221 if (blink_settings.empty()) { 1256 if (blink_settings.empty()) {
1222 return; 1257 return;
1223 } 1258 }
1224 1259
1225 if (browser_command_line.HasSwitch(switches::kBlinkSettings) || 1260 if (browser_command_line.HasSwitch(switches::kBlinkSettings) ||
1226 command_line->HasSwitch(switches::kBlinkSettings)) { 1261 command_line->HasSwitch(switches::kBlinkSettings)) {
1227 // The field trial is configured to force users that specify the 1262 // The field trial is configured to force users that specify the
Bryan McQuade 2015/08/11 13:25:07 can you update this comment to start with "The fie
Pat Meenan 2015/08/11 14:37:36 Done.
1228 // blink-settings flag into a group with no params, and we return 1263 // blink-settings flag into a group with no params, and we return
1229 // above if no params were specified, so it's an error if we reach 1264 // above if no params were specified, so it's an error if we reach
1230 // this point. 1265 // this point.
1231 LOG(WARNING) << "Received field trial params, " 1266 LOG(WARNING) << "Received field trial params, "
1232 "but blink-settings switch already specified."; 1267 "but blink-settings switch already specified.";
1233 return; 1268 return;
1234 } 1269 }
1235 1270
1236 command_line->AppendSwitchASCII(switches::kBlinkSettings, 1271 command_line->AppendSwitchASCII(switches::kBlinkSettings,
1237 base::JoinString(blink_settings, ",")); 1272 base::JoinString(blink_settings, ","));
(...skipping 1326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 switches::kDisableWebRtcEncryption, 2599 switches::kDisableWebRtcEncryption,
2565 }; 2600 };
2566 to_command_line->CopySwitchesFrom(from_command_line, 2601 to_command_line->CopySwitchesFrom(from_command_line,
2567 kWebRtcDevSwitchNames, 2602 kWebRtcDevSwitchNames,
2568 arraysize(kWebRtcDevSwitchNames)); 2603 arraysize(kWebRtcDevSwitchNames));
2569 } 2604 }
2570 } 2605 }
2571 #endif // defined(ENABLE_WEBRTC) 2606 #endif // defined(ENABLE_WEBRTC)
2572 2607
2573 } // namespace chrome 2608 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_content_browser_client_unittest.cc » ('j') | content/browser/loader/resource_scheduler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698