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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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, | |
M-A Ruel
2011/06/22 14:53:33
smells like:
const int* result = std::find(socket
gagansingh
2011/06/23 15:53:59
Done.
| |
213 const int socket_policy[], | |
214 int num_groups) { | |
215 for (int i = 0; i < num_groups; i++) { | |
216 if (warmest_socket_trial_group == socket_policy[i]) { | |
217 net::SetSocketReusePolicy(i); | |
218 return; | |
219 } | |
220 } | |
221 | |
222 NOTREACHED() << "Not a valid socket reuse policy group"; | |
223 } | |
224 } | |
225 | |
210 namespace net { | 226 namespace net { |
211 class NetLog; | 227 class NetLog; |
212 } // namespace net | 228 } // namespace net |
213 | 229 |
214 // BrowserMainParts ------------------------------------------------------------ | 230 // BrowserMainParts ------------------------------------------------------------ |
215 | 231 |
216 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) | 232 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) |
217 : parameters_(parameters), | 233 : parameters_(parameters), |
218 parsed_command_line_(parameters.command_line_) { | 234 parsed_command_line_(parameters.command_line_) { |
219 } | 235 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { | 483 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { |
468 int value = 0; | 484 int value = 0; |
469 base::StringToInt(parsed_command_line().GetSwitchValueASCII( | 485 base::StringToInt(parsed_command_line().GetSwitchValueASCII( |
470 switches::kMaxSpdyConcurrentStreams), | 486 switches::kMaxSpdyConcurrentStreams), |
471 &value); | 487 &value); |
472 if (value > 0) | 488 if (value > 0) |
473 net::SpdySession::set_max_concurrent_streams(value); | 489 net::SpdySession::set_max_concurrent_streams(value); |
474 } | 490 } |
475 } | 491 } |
476 | 492 |
493 // If --socket-reuse-policy is not specified, run an A/B test for choosing the | |
494 // warmest socket. | |
495 void BrowserMainParts::WarmConnectionFieldTrial() { | |
496 const CommandLine& command_line = parsed_command_line(); | |
497 if (command_line.HasSwitch(switches::kSocketReusePolicy)) { | |
498 std::string socket_reuse_policy_str = command_line.GetSwitchValueASCII( | |
499 switches::kSocketReusePolicy); | |
500 int policy = -1; | |
501 base::StringToInt(socket_reuse_policy_str, &policy); | |
502 | |
503 const int policy_list[] = { 0, 1, 2 }; | |
504 LOG(INFO) << "Setting socket_reuse_policy = " << policy; | |
505 SetSocketReusePolicy(policy, policy_list, arraysize(policy_list)); | |
506 return; | |
507 } | |
508 | |
509 const base::FieldTrial::Probability kWarmSocketDivisor = 100; | |
510 const base::FieldTrial::Probability kWarmSocketProbability = 33; | |
511 | |
512 // After January 30, 2013 builds, it will always be in default group. | |
513 scoped_refptr<base::FieldTrial> warmest_socket_trial( | |
514 new base::FieldTrial( | |
515 "WarmSocketImpact", kWarmSocketDivisor, "last_accessed_socket", | |
516 2013, 1, 30)); | |
517 | |
518 // Default value is USE_LAST_ACCESSED_SOCKET. | |
519 const int last_accessed_socket = warmest_socket_trial->kDefaultGroupNumber; | |
520 const int warmest_socket = warmest_socket_trial->AppendGroup( | |
521 "warmest_socket", kWarmSocketProbability); | |
522 const int warm_socket = warmest_socket_trial->AppendGroup( | |
523 "warm_socket", kWarmSocketProbability); | |
524 | |
525 const int warmest_socket_trial_group = warmest_socket_trial->group(); | |
526 | |
527 const int policy_list[] = { warmest_socket, warm_socket, | |
528 last_accessed_socket }; | |
529 SetSocketReusePolicy(warmest_socket_trial_group, policy_list, | |
530 arraysize(policy_list)); | |
531 } | |
532 | |
477 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is | 533 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is |
478 // specified, run an A/B test for automatically establishing backup TCP | 534 // specified, run an A/B test for automatically establishing backup TCP |
479 // connections when a certain timeout value is exceeded. | 535 // connections when a certain timeout value is exceeded. |
480 void BrowserMainParts::ConnectBackupJobsFieldTrial() { | 536 void BrowserMainParts::ConnectBackupJobsFieldTrial() { |
481 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { | 537 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { |
482 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 538 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
483 true); | 539 true); |
484 } else if (parsed_command_line().HasSwitch( | 540 } else if (parsed_command_line().HasSwitch( |
485 switches::kDisableConnectBackupJobs)) { | 541 switches::kDisableConnectBackupJobs)) { |
486 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 542 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(); | 642 chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start(); |
587 | 643 |
588 // Note: make sure to call ConnectionFieldTrial() before | 644 // Note: make sure to call ConnectionFieldTrial() before |
589 // ProxyConnectionsFieldTrial(). | 645 // ProxyConnectionsFieldTrial(). |
590 ConnectionFieldTrial(); | 646 ConnectionFieldTrial(); |
591 SocketTimeoutFieldTrial(); | 647 SocketTimeoutFieldTrial(); |
592 ProxyConnectionsFieldTrial(); | 648 ProxyConnectionsFieldTrial(); |
593 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 649 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
594 SpdyFieldTrial(); | 650 SpdyFieldTrial(); |
595 ConnectBackupJobsFieldTrial(); | 651 ConnectBackupJobsFieldTrial(); |
652 WarmConnectionFieldTrial(); | |
596 } | 653 } |
597 | 654 |
598 // ----------------------------------------------------------------------------- | 655 // ----------------------------------------------------------------------------- |
599 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure | 656 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure |
600 | 657 |
601 namespace { | 658 namespace { |
602 | 659 |
603 // This function provides some ways to test crash and assertion handling | 660 // This function provides some ways to test crash and assertion handling |
604 // behavior of the program. | 661 // behavior of the program. |
605 void HandleTestParameters(const CommandLine& command_line) { | 662 void HandleTestParameters(const CommandLine& command_line) { |
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1980 #if defined(OS_CHROMEOS) | 2037 #if defined(OS_CHROMEOS) |
1981 // To be precise, logout (browser shutdown) is not yet done, but the | 2038 // To be precise, logout (browser shutdown) is not yet done, but the |
1982 // remaining work is negligible, hence we say LogoutDone here. | 2039 // remaining work is negligible, hence we say LogoutDone here. |
1983 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2040 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
1984 false); | 2041 false); |
1985 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2042 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
1986 #endif | 2043 #endif |
1987 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2044 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
1988 return result_code; | 2045 return result_code; |
1989 } | 2046 } |
OLD | NEW |