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

Side by Side Diff: components/network_session_configurator/network_session_configurator.cc

Issue 2892613002: IOThread: Use URLRequestContextBuilder::NetworkSessionParams. (Closed)
Patch Set: Merge Created 3 years, 6 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 #include "components/network_session_configurator/network_session_configurator.h " 5 #include "components/network_session_configurator/network_session_configurator.h "
6 6
7 #include <map> 7 #include <map>
8 #include <unordered_set> 8 #include <unordered_set>
9 9
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 const std::string& GetVariationParam( 42 const std::string& GetVariationParam(
43 const std::map<std::string, std::string>& params, 43 const std::map<std::string, std::string>& params,
44 const std::string& key) { 44 const std::string& key) {
45 std::map<std::string, std::string>::const_iterator it = params.find(key); 45 std::map<std::string, std::string>::const_iterator it = params.find(key);
46 if (it == params.end()) 46 if (it == params.end())
47 return base::EmptyString(); 47 return base::EmptyString();
48 48
49 return it->second; 49 return it->second;
50 } 50 }
51 51
52 void ConfigureTCPFastOpenParams(base::StringPiece tfo_trial_group, 52 void ConfigureTCPFastOpenParams(
53 net::HttpNetworkSession::Params* params) { 53 base::StringPiece tfo_trial_group,
54 net::URLRequestContextBuilder::HttpNetworkSessionParams* params) {
54 if (tfo_trial_group == kTCPFastOpenHttpsEnabledGroupName) 55 if (tfo_trial_group == kTCPFastOpenHttpsEnabledGroupName)
55 params->enable_tcp_fast_open_for_ssl = true; 56 params->enable_tcp_fast_open_for_ssl = true;
56 } 57 }
57 58
58 net::SettingsMap GetHttp2Settings( 59 net::SettingsMap GetHttp2Settings(
59 const VariationParameters& http2_trial_params) { 60 const VariationParameters& http2_trial_params) {
60 net::SettingsMap http2_settings; 61 net::SettingsMap http2_settings;
61 62
62 const std::string settings_string = 63 const std::string settings_string =
63 GetVariationParam(http2_trial_params, "http2_settings"); 64 GetVariationParam(http2_trial_params, "http2_settings");
(...skipping 10 matching lines...) Expand all
74 continue; 75 continue;
75 uint32_t value; 76 uint32_t value;
76 if (!base::StringToUint(key_value.second, &value)) 77 if (!base::StringToUint(key_value.second, &value))
77 continue; 78 continue;
78 http2_settings[static_cast<net::SpdySettingsIds>(key)] = value; 79 http2_settings[static_cast<net::SpdySettingsIds>(key)] = value;
79 } 80 }
80 81
81 return http2_settings; 82 return http2_settings;
82 } 83 }
83 84
84 void ConfigureHttp2Params(base::StringPiece http2_trial_group, 85 void ConfigureHttp2Params(
85 const VariationParameters& http2_trial_params, 86 base::StringPiece http2_trial_group,
86 net::HttpNetworkSession::Params* params) { 87 const VariationParameters& http2_trial_params,
88 net::URLRequestContextBuilder::HttpNetworkSessionParams* params) {
87 if (http2_trial_group.starts_with(kHttp2FieldTrialDisablePrefix)) { 89 if (http2_trial_group.starts_with(kHttp2FieldTrialDisablePrefix)) {
88 params->enable_http2 = false; 90 params->enable_http2 = false;
89 return; 91 return;
90 } 92 }
91 params->http2_settings = GetHttp2Settings(http2_trial_params); 93 params->http2_settings = GetHttp2Settings(http2_trial_params);
92 } 94 }
93 95
94 bool ShouldEnableQuic(base::StringPiece quic_trial_group, 96 bool ShouldEnableQuic(base::StringPiece quic_trial_group,
95 const VariationParameters& quic_trial_params, 97 const VariationParameters& quic_trial_params,
96 bool is_quic_force_disabled, 98 bool is_quic_force_disabled,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 GetVariationParam(quic_trial_params, "quic_version")); 235 GetVariationParam(quic_trial_params, "quic_version"));
234 } 236 }
235 237
236 bool ShouldEnableServerPushCancelation( 238 bool ShouldEnableServerPushCancelation(
237 const VariationParameters& quic_trial_params) { 239 const VariationParameters& quic_trial_params) {
238 return base::LowerCaseEqualsASCII( 240 return base::LowerCaseEqualsASCII(
239 GetVariationParam(quic_trial_params, "enable_server_push_cancellation"), 241 GetVariationParam(quic_trial_params, "enable_server_push_cancellation"),
240 "true"); 242 "true");
241 } 243 }
242 244
243 void ConfigureQuicParams(base::StringPiece quic_trial_group, 245 void ConfigureQuicParams(
244 const VariationParameters& quic_trial_params, 246 base::StringPiece quic_trial_group,
245 bool is_quic_force_disabled, 247 const VariationParameters& quic_trial_params,
246 bool is_quic_force_enabled, 248 bool is_quic_force_disabled,
247 const std::string& quic_user_agent_id, 249 bool is_quic_force_enabled,
248 net::HttpNetworkSession::Params* params) { 250 const std::string& quic_user_agent_id,
251 net::URLRequestContextBuilder::HttpNetworkSessionParams* params) {
249 params->enable_quic = ShouldEnableQuic( 252 params->enable_quic = ShouldEnableQuic(
250 quic_trial_group, quic_trial_params, is_quic_force_disabled, 253 quic_trial_group, quic_trial_params, is_quic_force_disabled,
251 is_quic_force_enabled); 254 is_quic_force_enabled);
252 params->mark_quic_broken_when_network_blackholes = 255 params->mark_quic_broken_when_network_blackholes =
253 ShouldMarkQuicBrokenWhenNetworkBlackholes(quic_trial_params); 256 ShouldMarkQuicBrokenWhenNetworkBlackholes(quic_trial_params);
254 257
255 params->enable_server_push_cancellation = 258 params->enable_server_push_cancellation =
256 ShouldEnableServerPushCancelation(quic_trial_params); 259 ShouldEnableServerPushCancelation(quic_trial_params);
257 260
258 params->retry_without_alt_svc_on_quic_errors = 261 params->retry_without_alt_svc_on_quic_errors =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 for (size_t i = 0; i < supported_versions.size(); ++i) { 323 for (size_t i = 0; i < supported_versions.size(); ++i) {
321 net::QuicVersion version = supported_versions[i]; 324 net::QuicVersion version = supported_versions[i];
322 if (net::QuicVersionToString(version) == quic_version) { 325 if (net::QuicVersionToString(version) == quic_version) {
323 return version; 326 return version;
324 } 327 }
325 } 328 }
326 329
327 return net::QUIC_VERSION_UNSUPPORTED; 330 return net::QUIC_VERSION_UNSUPPORTED;
328 } 331 }
329 332
330 void ParseFieldTrials(bool is_quic_force_disabled, 333 void ParseFieldTrials(
331 bool is_quic_force_enabled, 334 bool is_quic_force_disabled,
332 const std::string& quic_user_agent_id, 335 bool is_quic_force_enabled,
333 net::HttpNetworkSession::Params* params) { 336 const std::string& quic_user_agent_id,
337 net::URLRequestContextBuilder::HttpNetworkSessionParams* params) {
334 std::string quic_trial_group = 338 std::string quic_trial_group =
335 base::FieldTrialList::FindFullName(kQuicFieldTrialName); 339 base::FieldTrialList::FindFullName(kQuicFieldTrialName);
336 VariationParameters quic_trial_params; 340 VariationParameters quic_trial_params;
337 if (!variations::GetVariationParams(kQuicFieldTrialName, &quic_trial_params)) 341 if (!variations::GetVariationParams(kQuicFieldTrialName, &quic_trial_params))
338 quic_trial_params.clear(); 342 quic_trial_params.clear();
339 ConfigureQuicParams(quic_trial_group, quic_trial_params, 343 ConfigureQuicParams(quic_trial_group, quic_trial_params,
340 is_quic_force_disabled, is_quic_force_enabled, 344 is_quic_force_disabled, is_quic_force_enabled,
341 quic_user_agent_id, params); 345 quic_user_agent_id, params);
342 346
343 std::string http2_trial_group = 347 std::string http2_trial_group =
344 base::FieldTrialList::FindFullName(kHttp2FieldTrialName); 348 base::FieldTrialList::FindFullName(kHttp2FieldTrialName);
345 VariationParameters http2_trial_params; 349 VariationParameters http2_trial_params;
346 if (!variations::GetVariationParams(kHttp2FieldTrialName, 350 if (!variations::GetVariationParams(kHttp2FieldTrialName,
347 &http2_trial_params)) 351 &http2_trial_params))
348 http2_trial_params.clear(); 352 http2_trial_params.clear();
349 ConfigureHttp2Params(http2_trial_group, http2_trial_params, params); 353 ConfigureHttp2Params(http2_trial_group, http2_trial_params, params);
350 354
351 const std::string tfo_trial_group = 355 const std::string tfo_trial_group =
352 base::FieldTrialList::FindFullName(kTCPFastOpenFieldTrialName); 356 base::FieldTrialList::FindFullName(kTCPFastOpenFieldTrialName);
353 ConfigureTCPFastOpenParams(tfo_trial_group, params); 357 ConfigureTCPFastOpenParams(tfo_trial_group, params);
354 } 358 }
355 359
356 } // namespace network_session_configurator 360 } // namespace network_session_configurator
OLDNEW
« no previous file with comments | « components/network_session_configurator/network_session_configurator.h ('k') | net/http/http_network_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698