OLD | NEW |
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #include "content/common/hi_res_timer_manager.h" | 94 #include "content/common/hi_res_timer_manager.h" |
95 #include "content/common/main_function_params.h" | 95 #include "content/common/main_function_params.h" |
96 #include "content/common/result_codes.h" | 96 #include "content/common/result_codes.h" |
97 #include "grit/app_locale_settings.h" | 97 #include "grit/app_locale_settings.h" |
98 #include "grit/chromium_strings.h" | 98 #include "grit/chromium_strings.h" |
99 #include "grit/generated_resources.h" | 99 #include "grit/generated_resources.h" |
100 #include "grit/platform_locale_settings.h" | 100 #include "grit/platform_locale_settings.h" |
101 #include "net/base/cookie_monster.h" | 101 #include "net/base/cookie_monster.h" |
102 #include "net/base/net_module.h" | 102 #include "net/base/net_module.h" |
103 #include "net/base/network_change_notifier.h" | 103 #include "net/base/network_change_notifier.h" |
| 104 #include "net/http/http_basic_stream.h" |
104 #include "net/http/http_network_layer.h" | 105 #include "net/http/http_network_layer.h" |
105 #include "net/http/http_stream_factory.h" | 106 #include "net/http/http_stream_factory.h" |
106 #include "net/socket/client_socket_pool_base.h" | 107 #include "net/socket/client_socket_pool_base.h" |
107 #include "net/socket/client_socket_pool_manager.h" | 108 #include "net/socket/client_socket_pool_manager.h" |
108 #include "net/socket/tcp_client_socket.h" | 109 #include "net/socket/tcp_client_socket.h" |
109 #include "net/spdy/spdy_session.h" | 110 #include "net/spdy/spdy_session.h" |
110 #include "net/spdy/spdy_session_pool.h" | 111 #include "net/spdy/spdy_session_pool.h" |
111 #include "net/url_request/url_request.h" | 112 #include "net/url_request/url_request.h" |
112 #include "net/url_request/url_request_throttler_manager.h" | 113 #include "net/url_request/url_request_throttler_manager.h" |
113 #include "net/websockets/websocket_job.h" | 114 #include "net/websockets/websocket_job.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 #endif | 202 #endif |
202 | 203 |
203 #if defined(TOOLKIT_USES_GTK) | 204 #if defined(TOOLKIT_USES_GTK) |
204 #include "ui/gfx/gtk_util.h" | 205 #include "ui/gfx/gtk_util.h" |
205 #endif | 206 #endif |
206 | 207 |
207 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) | 208 #if defined(TOUCH_UI) && defined(HAVE_XINPUT2) |
208 #include "views/touchui/touch_factory.h" | 209 #include "views/touchui/touch_factory.h" |
209 #endif | 210 #endif |
210 | 211 |
| 212 namespace { |
| 213 void SetSocketReusePolicy(int warmest_socket_trial_group, |
| 214 const int socket_policy[], |
| 215 int num_groups) { |
| 216 const int* result = std::find(socket_policy, socket_policy + num_groups, |
| 217 warmest_socket_trial_group); |
| 218 DCHECK_NE(result, socket_policy + num_groups) |
| 219 << "Not a valid socket reuse policy group"; |
| 220 net::SetSocketReusePolicy(result - socket_policy); |
| 221 } |
| 222 } |
| 223 |
211 namespace net { | 224 namespace net { |
212 class NetLog; | 225 class NetLog; |
213 } // namespace net | 226 } // namespace net |
214 | 227 |
215 // BrowserMainParts ------------------------------------------------------------ | 228 // BrowserMainParts ------------------------------------------------------------ |
216 | 229 |
217 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) | 230 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) |
218 : parameters_(parameters), | 231 : parameters_(parameters), |
219 parsed_command_line_(parameters.command_line_) { | 232 parsed_command_line_(parameters.command_line_) { |
220 } | 233 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { | 480 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { |
468 int value = 0; | 481 int value = 0; |
469 base::StringToInt(parsed_command_line().GetSwitchValueASCII( | 482 base::StringToInt(parsed_command_line().GetSwitchValueASCII( |
470 switches::kMaxSpdyConcurrentStreams), | 483 switches::kMaxSpdyConcurrentStreams), |
471 &value); | 484 &value); |
472 if (value > 0) | 485 if (value > 0) |
473 net::SpdySession::set_max_concurrent_streams(value); | 486 net::SpdySession::set_max_concurrent_streams(value); |
474 } | 487 } |
475 } | 488 } |
476 | 489 |
| 490 // If --socket-reuse-policy is not specified, run an A/B test for choosing the |
| 491 // warmest socket. |
| 492 void BrowserMainParts::WarmConnectionFieldTrial() { |
| 493 const CommandLine& command_line = parsed_command_line(); |
| 494 if (command_line.HasSwitch(switches::kSocketReusePolicy)) { |
| 495 std::string socket_reuse_policy_str = command_line.GetSwitchValueASCII( |
| 496 switches::kSocketReusePolicy); |
| 497 int policy = -1; |
| 498 base::StringToInt(socket_reuse_policy_str, &policy); |
| 499 |
| 500 const int policy_list[] = { 0, 1, 2 }; |
| 501 VLOG(1) << "Setting socket_reuse_policy = " << policy; |
| 502 SetSocketReusePolicy(policy, policy_list, arraysize(policy_list)); |
| 503 return; |
| 504 } |
| 505 |
| 506 const base::FieldTrial::Probability kWarmSocketDivisor = 100; |
| 507 const base::FieldTrial::Probability kWarmSocketProbability = 33; |
| 508 |
| 509 // After January 30, 2013 builds, it will always be in default group. |
| 510 scoped_refptr<base::FieldTrial> warmest_socket_trial( |
| 511 new base::FieldTrial( |
| 512 "WarmSocketImpact", kWarmSocketDivisor, "last_accessed_socket", |
| 513 2013, 1, 30)); |
| 514 |
| 515 // Default value is USE_LAST_ACCESSED_SOCKET. |
| 516 const int last_accessed_socket = warmest_socket_trial->kDefaultGroupNumber; |
| 517 const int warmest_socket = warmest_socket_trial->AppendGroup( |
| 518 "warmest_socket", kWarmSocketProbability); |
| 519 const int warm_socket = warmest_socket_trial->AppendGroup( |
| 520 "warm_socket", kWarmSocketProbability); |
| 521 |
| 522 const int warmest_socket_trial_group = warmest_socket_trial->group(); |
| 523 |
| 524 const int policy_list[] = { warmest_socket, warm_socket, |
| 525 last_accessed_socket }; |
| 526 SetSocketReusePolicy(warmest_socket_trial_group, policy_list, |
| 527 arraysize(policy_list)); |
| 528 } |
| 529 |
477 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is | 530 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is |
478 // specified, run an A/B test for automatically establishing backup TCP | 531 // specified, run an A/B test for automatically establishing backup TCP |
479 // connections when a certain timeout value is exceeded. | 532 // connections when a certain timeout value is exceeded. |
480 void BrowserMainParts::ConnectBackupJobsFieldTrial() { | 533 void BrowserMainParts::ConnectBackupJobsFieldTrial() { |
481 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { | 534 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { |
482 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 535 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
483 true); | 536 true); |
484 } else if (parsed_command_line().HasSwitch( | 537 } else if (parsed_command_line().HasSwitch( |
485 switches::kDisableConnectBackupJobs)) { | 538 switches::kDisableConnectBackupJobs)) { |
486 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 539 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start(); | 639 chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start(); |
587 | 640 |
588 // Note: make sure to call ConnectionFieldTrial() before | 641 // Note: make sure to call ConnectionFieldTrial() before |
589 // ProxyConnectionsFieldTrial(). | 642 // ProxyConnectionsFieldTrial(). |
590 ConnectionFieldTrial(); | 643 ConnectionFieldTrial(); |
591 SocketTimeoutFieldTrial(); | 644 SocketTimeoutFieldTrial(); |
592 ProxyConnectionsFieldTrial(); | 645 ProxyConnectionsFieldTrial(); |
593 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 646 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
594 SpdyFieldTrial(); | 647 SpdyFieldTrial(); |
595 ConnectBackupJobsFieldTrial(); | 648 ConnectBackupJobsFieldTrial(); |
| 649 WarmConnectionFieldTrial(); |
596 } | 650 } |
597 | 651 |
598 // ----------------------------------------------------------------------------- | 652 // ----------------------------------------------------------------------------- |
599 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure | 653 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure |
600 | 654 |
601 namespace { | 655 namespace { |
602 | 656 |
603 // This function provides some ways to test crash and assertion handling | 657 // This function provides some ways to test crash and assertion handling |
604 // behavior of the program. | 658 // behavior of the program. |
605 void HandleTestParameters(const CommandLine& command_line) { | 659 void HandleTestParameters(const CommandLine& command_line) { |
(...skipping 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2002 #if defined(OS_CHROMEOS) | 2056 #if defined(OS_CHROMEOS) |
2003 // To be precise, logout (browser shutdown) is not yet done, but the | 2057 // To be precise, logout (browser shutdown) is not yet done, but the |
2004 // remaining work is negligible, hence we say LogoutDone here. | 2058 // remaining work is negligible, hence we say LogoutDone here. |
2005 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2059 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
2006 false); | 2060 false); |
2007 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2061 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
2008 #endif | 2062 #endif |
2009 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2063 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
2010 return result_code; | 2064 return result_code; |
2011 } | 2065 } |
OLD | NEW |