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 using net::internal::ClientSocketPoolBaseHelper; | |
212 using net::HttpBasicStream; | |
213 | |
210 namespace net { | 214 namespace net { |
211 class NetLog; | 215 class NetLog; |
212 } // namespace net | 216 } // namespace net |
213 | 217 |
214 // BrowserMainParts ------------------------------------------------------------ | 218 // BrowserMainParts ------------------------------------------------------------ |
215 | 219 |
216 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) | 220 BrowserMainParts::BrowserMainParts(const MainFunctionParams& parameters) |
217 : parameters_(parameters), | 221 : parameters_(parameters), |
218 parsed_command_line_(parameters.command_line_) { | 222 parsed_command_line_(parameters.command_line_) { |
219 } | 223 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { | 471 if (parsed_command_line().HasSwitch(switches::kMaxSpdyConcurrentStreams)) { |
468 int value = 0; | 472 int value = 0; |
469 base::StringToInt(parsed_command_line().GetSwitchValueASCII( | 473 base::StringToInt(parsed_command_line().GetSwitchValueASCII( |
470 switches::kMaxSpdyConcurrentStreams), | 474 switches::kMaxSpdyConcurrentStreams), |
471 &value); | 475 &value); |
472 if (value > 0) | 476 if (value > 0) |
473 net::SpdySession::set_max_concurrent_streams(value); | 477 net::SpdySession::set_max_concurrent_streams(value); |
474 } | 478 } |
475 } | 479 } |
476 | 480 |
481 // If --bytes-read-vs-last-accessed-decay-coef is not specified, run an A/B | |
482 // test for choosing the warmest socket. | |
483 void BrowserMainParts::WarmConnectionFieldTrial() { | |
484 const CommandLine& command_line = parsed_command_line(); | |
485 if (command_line.HasSwitch(switches::kTcpSocketEstimatedCwndDecayCoef)) { | |
486 std::string alpha_str = command_line.GetSwitchValueASCII( | |
487 switches::kTcpSocketEstimatedCwndDecayCoef); | |
488 double coef = 0; | |
489 base::StringToDouble(alpha_str, &coef); | |
490 ClientSocketPoolBaseHelper::set_tcp_socket_estimated_cwnd_decay_coef( | |
491 coef); | |
492 HttpBasicStream::set_warm_connection_field_trial_group("manual"); | |
493 return; | |
494 } | |
495 | |
496 const base::FieldTrial::Probability kWarmSocketDivisor = 100; | |
497 const base::FieldTrial::Probability kWarmSocketProbability = 33; // 1% prob. | |
Mike Belshe
2011/06/09 16:08:52
The comment is wrong here
Gagan
2011/06/09 19:49:26
Done.
| |
498 | |
499 // After January 30, 2013 builds, it will always be in default group. | |
500 scoped_refptr<base::FieldTrial> warmest_socket_trial( | |
501 new base::FieldTrial( | |
502 "WarmSocketImpact", kWarmSocketDivisor, "last_accessed_socket", | |
503 2013, 1, 30)); | |
504 | |
505 // This (1000000) is the current default value. | |
Mike Belshe
2011/06/09 16:08:52
I think the comment is wrong here too?
Gagan
2011/06/09 19:49:26
Done.
| |
506 const int last_accessed_socket = warmest_socket_trial->kDefaultGroupNumber; | |
507 const int warmest_socket = warmest_socket_trial->AppendGroup( | |
508 "warmest_socket", kWarmSocketProbability); | |
509 const int warm_socket = warmest_socket_trial->AppendGroup( | |
510 "warm_socket", kWarmSocketProbability); | |
511 | |
512 const int warmest_socket_trial_group = warmest_socket_trial->group(); | |
513 | |
514 if (warmest_socket_trial_group == last_accessed_socket) { | |
515 ClientSocketPoolBaseHelper::set_tcp_socket_estimated_cwnd_decay_coef( | |
Mike Belshe
2011/06/09 16:08:52
This seems like a strange place to set the policy.
Gagan
2011/06/09 19:49:26
Done.
| |
516 1000000); | |
517 HttpBasicStream::set_warm_connection_field_trial_group( | |
518 "last_accessed_socket"); | |
519 } else if (warmest_socket_trial_group == warmest_socket) { | |
520 ClientSocketPoolBaseHelper::set_tcp_socket_estimated_cwnd_decay_coef( | |
521 1); | |
522 HttpBasicStream::set_warm_connection_field_trial_group( | |
523 "warmest_socket"); | |
524 } else if (warmest_socket_trial_group == warm_socket) { | |
525 // 1.83841629 = decay of 20 KB per 5 mins. | |
526 ClientSocketPoolBaseHelper::set_tcp_socket_estimated_cwnd_decay_coef( | |
527 1.83841629); | |
528 HttpBasicStream::set_warm_connection_field_trial_group( | |
529 "warm_socket"); | |
530 } else { | |
531 NOTREACHED() << "Invalid bytes_read_vs_last_accessed_alpha"; | |
532 } | |
533 } | |
534 | |
535 | |
477 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is | 536 // If neither --enable-connect-backup-jobs or --disable-connect-backup-jobs is |
478 // specified, run an A/B test for automatically establishing backup TCP | 537 // specified, run an A/B test for automatically establishing backup TCP |
479 // connections when a certain timeout value is exceeded. | 538 // connections when a certain timeout value is exceeded. |
480 void BrowserMainParts::ConnectBackupJobsFieldTrial() { | 539 void BrowserMainParts::ConnectBackupJobsFieldTrial() { |
481 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { | 540 if (parsed_command_line().HasSwitch(switches::kEnableConnectBackupJobs)) { |
482 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 541 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( |
483 true); | 542 true); |
484 } else if (parsed_command_line().HasSwitch( | 543 } else if (parsed_command_line().HasSwitch( |
485 switches::kDisableConnectBackupJobs)) { | 544 switches::kDisableConnectBackupJobs)) { |
486 net::internal::ClientSocketPoolBaseHelper::set_connect_backup_jobs_enabled( | 545 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(); | 645 chrome_browser_net_websocket_experiment::WebSocketExperimentRunner::Start(); |
587 | 646 |
588 // Note: make sure to call ConnectionFieldTrial() before | 647 // Note: make sure to call ConnectionFieldTrial() before |
589 // ProxyConnectionsFieldTrial(). | 648 // ProxyConnectionsFieldTrial(). |
590 ConnectionFieldTrial(); | 649 ConnectionFieldTrial(); |
591 SocketTimeoutFieldTrial(); | 650 SocketTimeoutFieldTrial(); |
592 ProxyConnectionsFieldTrial(); | 651 ProxyConnectionsFieldTrial(); |
593 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); | 652 prerender::ConfigurePrefetchAndPrerender(parsed_command_line()); |
594 SpdyFieldTrial(); | 653 SpdyFieldTrial(); |
595 ConnectBackupJobsFieldTrial(); | 654 ConnectBackupJobsFieldTrial(); |
655 WarmConnectionFieldTrial(); | |
596 } | 656 } |
597 | 657 |
598 // ----------------------------------------------------------------------------- | 658 // ----------------------------------------------------------------------------- |
599 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure | 659 // TODO(viettrungluu): move more/rest of BrowserMain() into above structure |
600 | 660 |
601 namespace { | 661 namespace { |
602 | 662 |
603 // This function provides some ways to test crash and assertion handling | 663 // This function provides some ways to test crash and assertion handling |
604 // behavior of the program. | 664 // behavior of the program. |
605 void HandleTestParameters(const CommandLine& command_line) { | 665 void HandleTestParameters(const CommandLine& command_line) { |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1970 #if defined(OS_CHROMEOS) | 2030 #if defined(OS_CHROMEOS) |
1971 // To be precise, logout (browser shutdown) is not yet done, but the | 2031 // To be precise, logout (browser shutdown) is not yet done, but the |
1972 // remaining work is negligible, hence we say LogoutDone here. | 2032 // remaining work is negligible, hence we say LogoutDone here. |
1973 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 2033 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
1974 false); | 2034 false); |
1975 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 2035 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
1976 #endif | 2036 #endif |
1977 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); | 2037 TRACE_EVENT_END_ETW("BrowserMain", 0, 0); |
1978 return result_code; | 2038 return result_code; |
1979 } | 2039 } |
OLD | NEW |