Chromium Code Reviews| Index: chrome/browser/browser_main.cc |
| =================================================================== |
| --- chrome/browser/browser_main.cc (revision 88789) |
| +++ chrome/browser/browser_main.cc (working copy) |
| @@ -100,6 +100,7 @@ |
| #include "net/base/cookie_monster.h" |
| #include "net/base/net_module.h" |
| #include "net/base/network_change_notifier.h" |
| +#include "net/http/http_basic_stream.h" |
| #include "net/http/http_network_layer.h" |
| #include "net/http/http_stream_factory.h" |
| #include "net/socket/client_socket_pool_base.h" |
| @@ -207,6 +208,9 @@ |
| #include "views/touchui/touch_factory.h" |
| #endif |
| +using net::internal::ClientSocketPoolBaseHelper; |
|
willchan no longer on Chromium
2011/06/13 15:06:07
internal is a net/ internal implementation detail.
Gagan
2011/06/13 16:45:58
Done.
|
| +using net::HttpBasicStream; |
| + |
| namespace net { |
| class NetLog; |
| } // namespace net |
| @@ -474,6 +478,61 @@ |
| } |
| } |
| +// If --socket-reuse-policy is not specified, run an A/B test for choosing the |
| +// warmest socket. |
| +void BrowserMainParts::WarmConnectionFieldTrial() { |
| + const CommandLine& command_line = parsed_command_line(); |
| + if (command_line.HasSwitch(switches::kSocketReusePolicy)) { |
| + std::string alpha_str = command_line.GetSwitchValueASCII( |
| + switches::kSocketReusePolicy); |
| + int coef = -1; |
| + base::StringToInt(alpha_str, &coef); |
| + |
| + const int socket_policy[] = { 0, 1, 2 }; |
| + LOG(ERROR) << "Chose socket_reuse_policy coef = " << coef; |
|
willchan no longer on Chromium
2011/06/13 15:06:07
Remove this.
Gagan
2011/06/14 18:25:02
Convered to DLOG(INFO)
|
| + ApplySocketReuseGroup(coef, socket_policy, arraysize(socket_policy)); |
|
willchan no longer on Chromium
2011/06/13 15:06:07
I have no idea what "coef" means. You call this wi
Gagan
2011/06/13 16:45:58
Done.
|
| + return; |
| + } |
| + |
| + const base::FieldTrial::Probability kWarmSocketDivisor = 100; |
| + const base::FieldTrial::Probability kWarmSocketProbability = 33; |
| + |
| + // After January 30, 2013 builds, it will always be in default group. |
| + scoped_refptr<base::FieldTrial> warmest_socket_trial( |
| + new base::FieldTrial( |
| + "WarmSocketImpact", kWarmSocketDivisor, "last_accessed_socket", |
| + 2013, 1, 30)); |
| + |
| + // Default value is USE_LAST_ACCESSED_SOCKET. |
| + const int last_accessed_socket = warmest_socket_trial->kDefaultGroupNumber; |
| + const int warmest_socket = warmest_socket_trial->AppendGroup( |
| + "warmest_socket", kWarmSocketProbability); |
| + const int warm_socket = warmest_socket_trial->AppendGroup( |
| + "warm_socket", kWarmSocketProbability); |
| + |
| + const int warmest_socket_trial_group = warmest_socket_trial->group(); |
| + |
| + const int socket_policy[] = { warmest_socket, warm_socket, |
| + last_accessed_socket }; |
| + ApplySocketReuseGroup(warmest_socket_trial_group, socket_policy, |
| + arraysize(socket_policy)); |
| +} |
| + |
| +void BrowserMainParts::ApplySocketReuseGroup(int warmest_socket_trial_group, |
|
willchan no longer on Chromium
2011/06/13 15:06:07
Please move this into an anonymous namespace rathe
Gagan
2011/06/13 16:45:58
Done.
|
| + const int socket_policy[], |
| + int num_groups) { |
| + for (int i = 0; i < num_groups; i++) { |
| + if (warmest_socket_trial_group == socket_policy[i]) { |
| + ClientSocketPoolBaseHelper::SetSocketReusePolicy(i); |
| + HttpBasicStream::SetSocketReusePolicy(i); |
| + return; |
| + } |
| + } |
| + |
| + LOG(ERROR) << "Not a valid socket reuse policy group"; |
|
willchan no longer on Chromium
2011/06/13 15:06:07
This is redundant, just use the NOTREACHED.
Gagan
2011/06/14 18:25:02
Done.
|
| + NOTREACHED() << "Not a valid socket reuse policy group"; |
| +} |
| + |
| // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is |
| // specified, run an A/B test for automatically establishing backup TCP |
| // connections when a certain timeout value is exceeded. |
| @@ -611,6 +670,7 @@ |
| SpdyFieldTrial(); |
| ConnectBackupJobsFieldTrial(); |
| RevocationCheckingDisabledFieldTrial(); |
| + WarmConnectionFieldTrial(); |
| } |
| // ----------------------------------------------------------------------------- |