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

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

Issue 7189055: Deciding best connection to schedule requests on based on cwnd and idle time (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Reuploading because net/socket/socket_test_util.cc is bad Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browser_main.h ('k') | chrome/browser/browser_main_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_main.h" 5 #include "chrome/browser/browser_main.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #include "content/common/hi_res_timer_manager.h" 93 #include "content/common/hi_res_timer_manager.h"
94 #include "content/common/main_function_params.h" 94 #include "content/common/main_function_params.h"
95 #include "content/common/result_codes.h" 95 #include "content/common/result_codes.h"
96 #include "grit/app_locale_settings.h" 96 #include "grit/app_locale_settings.h"
97 #include "grit/chromium_strings.h" 97 #include "grit/chromium_strings.h"
98 #include "grit/generated_resources.h" 98 #include "grit/generated_resources.h"
99 #include "grit/platform_locale_settings.h" 99 #include "grit/platform_locale_settings.h"
100 #include "net/base/cookie_monster.h" 100 #include "net/base/cookie_monster.h"
101 #include "net/base/net_module.h" 101 #include "net/base/net_module.h"
102 #include "net/base/network_change_notifier.h" 102 #include "net/base/network_change_notifier.h"
103 #include "net/http/http_basic_stream.h"
103 #include "net/http/http_network_layer.h" 104 #include "net/http/http_network_layer.h"
104 #include "net/http/http_stream_factory.h" 105 #include "net/http/http_stream_factory.h"
105 #include "net/socket/client_socket_pool_base.h" 106 #include "net/socket/client_socket_pool_base.h"
106 #include "net/socket/client_socket_pool_manager.h" 107 #include "net/socket/client_socket_pool_manager.h"
107 #include "net/socket/tcp_client_socket.h" 108 #include "net/socket/tcp_client_socket.h"
108 #include "net/spdy/spdy_session.h" 109 #include "net/spdy/spdy_session.h"
109 #include "net/spdy/spdy_session_pool.h" 110 #include "net/spdy/spdy_session_pool.h"
110 #include "net/url_request/url_request.h" 111 #include "net/url_request/url_request.h"
111 #include "net/url_request/url_request_throttler_manager.h" 112 #include "net/url_request/url_request_throttler_manager.h"
112 #include "net/websockets/websocket_job.h" 113 #include "net/websockets/websocket_job.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 #endif 201 #endif
201 202
202 #if defined(TOOLKIT_USES_GTK) 203 #if defined(TOOLKIT_USES_GTK)
203 #include "ui/gfx/gtk_util.h" 204 #include "ui/gfx/gtk_util.h"
204 #endif 205 #endif
205 206
206 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) 207 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2)
207 #include "views/touchui/touch_factory.h" 208 #include "views/touchui/touch_factory.h"
208 #endif 209 #endif
209 210
211 namespace {
212 void SetSocketReusePolicy(int warmest_socket_trial_group,
213 const int socket_policy[],
214 int num_groups) {
215 const int* result = std::find(socket_policy, socket_policy + num_groups,
216 warmest_socket_trial_group);
217 DCHECK_NE(result, socket_policy + num_groups)
218 << "Not a valid socket reuse policy group";
219 net::SetSocketReusePolicy(result - socket_policy);
220 }
221 }
222
210 namespace net { 223 namespace net {
211 class NetLog; 224 class NetLog;
212 } // namespace net 225 } // namespace net
213 226
214 // BrowserMainParts ------------------------------------------------------------ 227 // BrowserMainParts ------------------------------------------------------------
215 228
216 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) 229 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters)
217 : parameters_(parameters), 230 : parameters_(parameters),
218 parsed_command_line_(parameters.command_line_) { 231 parsed_command_line_(parameters.command_line_) {
219 } 232 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { 479 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) {
467 int value = 0; 480 int value = 0;
468 base::StringToInt(parsed_command_line().GetSwitchValueASCII( 481 base::StringToInt(parsed_command_line().GetSwitchValueASCII(
469 switches::kMaxSpdyConcurrentStreams), 482 switches::kMaxSpdyConcurrentStreams),
470 &value); 483 &value);
471 if (value > 0) 484 if (value > 0)
472 net::SpdySession::set_max_concurrent_streams(value); 485 net::SpdySession::set_max_concurrent_streams(value);
473 } 486 }
474 } 487 }
475 488
489 // If --socket-reuse-policy is not specified, run an A/B test for choosing the
490 // warmest socket.
491 void BrowserMainParts::WarmConnectionFieldTrial() {
492 const CommandLine& command_line = parsed_command_line();
493 if (command_line.HasSwitch(switches::kSocketReusePolicy)) {
494 std::string socket_reuse_policy_str = command_line.GetSwitchValueASCII(
495 switches::kSocketReusePolicy);
496 int policy = -1;
497 base::StringToInt(socket_reuse_policy_str, &policy);
498
499 const int policy_list[] = { 0, 1, 2 };
500 VLOG(1) << "Setting socket_reuse_policy = " << policy;
501 SetSocketReusePolicy(policy, policy_list, arraysize(policy_list));
502 return;
503 }
504
505 const base::FieldTrial::Probability kWarmSocketDivisor = 100;
506 const base::FieldTrial::Probability kWarmSocketProbability = 33;
507
508 // After January 30, 2013 builds, it will always be in default group.
509 scoped_refptr<base::FieldTrial> warmest_socket_trial(
510 new base::FieldTrial(
511 "WarmSocketImpact", kWarmSocketDivisor, "last_accessed_socket",
512 2013, 1, 30));
513
514 // Default value is USE_LAST_ACCESSED_SOCKET.
515 const int last_accessed_socket = warmest_socket_trial->kDefaultGroupNumber;
516 const int warmest_socket = warmest_socket_trial->AppendGroup(
517 "warmest_socket", kWarmSocketProbability);
518 const int warm_socket = warmest_socket_trial->AppendGroup(
519 "warm_socket", kWarmSocketProbability);
520
521 const int warmest_socket_trial_group = warmest_socket_trial->group();
522
523 const int policy_list[] = { warmest_socket, warm_socket,
524 last_accessed_socket };
525 SetSocketReusePolicy(warmest_socket_trial_group, policy_list,
526 arraysize(policy_list));
527 }
528
476 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is 529 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is
477 // specified, run an A/B test for automatically establishing backup TCP 530 // specified, run an A/B test for automatically establishing backup TCP
478 // connections when a certain timeout value is exceeded. 531 // connections when a certain timeout value is exceeded.
479 void BrowserMainParts::ConnectBackupJobsFieldTrial() { 532 void BrowserMainParts::ConnectBackupJobsFieldTrial() {
480 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { 533 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) {
481 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( 534 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
482 true); 535 true);
483 } else if (parsed_command_line().HasSwitch( 536 } else if (parsed_command_line().HasSwitch(
484 switches::kDisableConnectBackupJobs)) { 537 switches::kDisableConnectBackupJobs)) {
485 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( 538 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled(
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start(); 638 chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start();
586 639
587 // Note: make sure to call ConnectionFieldTrial() before 640 // Note: make sure to call ConnectionFieldTrial() before
588 // ProxyConnectionsFieldTrial(). 641 // ProxyConnectionsFieldTrial().
589 ConnectionFieldTrial(); 642 ConnectionFieldTrial();
590 SocketTimeoutFieldTrial(); 643 SocketTimeoutFieldTrial();
591 ProxyConnectionsFieldTrial(); 644 ProxyConnectionsFieldTrial();
592 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); 645 prerender::ConfigurePrefetchAndPrerender(parsed_command_line());
593 SpdyFieldTrial(); 646 SpdyFieldTrial();
594 ConnectBackupJobsFieldTrial(); 647 ConnectBackupJobsFieldTrial();
648 WarmConnectionFieldTrial();
595 } 649 }
596 650
597 // ----------------------------------------------------------------------------- 651 // -----------------------------------------------------------------------------
598 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure 652 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure
599 653
600 namespace { 654 namespace {
601 655
602 // This function provides some ways to test crash and assertion handling 656 // This function provides some ways to test crash and assertion handling
603 // behavior of the program. 657 // behavior of the program.
604 void HandleTestParameters(const CommandLine& command_line) { 658 void HandleTestParameters(const CommandLine& command_line) {
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 #if defined(OS_CHROMEOS) 2039 #if defined(OS_CHROMEOS)
1986 // To be precise, logout (browser shutdown) is not yet done, but the 2040 // To be precise, logout (browser shutdown) is not yet done, but the
1987 // remaining work is negligible, hence we say LogoutDone here. 2041 // remaining work is negligible, hence we say LogoutDone here.
1988 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", 2042 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone",
1989 false); 2043 false);
1990 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); 2044 chromeos::BootTimesLoader::Get()->WriteLogoutTimes();
1991 #endif 2045 #endif
1992 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); 2046 TRACE_EVENT_END_ETW("BrowserMain", 0, 0);
1993 return result_code; 2047 return result_code;
1994 } 2048 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_main.h ('k') | chrome/browser/browser_main_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698