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

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

Issue 11416205: Move EnableSpdy from HttpNetworkLayer to IOThread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/io_thread.h" 5 #include "chrome/browser/io_thread.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 644
645 if (parsed_command_line.HasSwitch(switches::kEnableWebSocketOverSpdy)) { 645 if (parsed_command_line.HasSwitch(switches::kEnableWebSocketOverSpdy)) {
646 // Enable WebSocket over SPDY. 646 // Enable WebSocket over SPDY.
647 net::WebSocketJob::set_websocket_over_spdy_enabled(true); 647 net::WebSocketJob::set_websocket_over_spdy_enabled(true);
648 } 648 }
649 649
650 bool used_spdy_switch = false; 650 bool used_spdy_switch = false;
651 if (parsed_command_line.HasSwitch(switches::kUseSpdy)) { 651 if (parsed_command_line.HasSwitch(switches::kUseSpdy)) {
652 std::string spdy_mode = 652 std::string spdy_mode =
653 parsed_command_line.GetSwitchValueASCII(switches::kUseSpdy); 653 parsed_command_line.GetSwitchValueASCII(switches::kUseSpdy);
654 net::HttpNetworkLayer::EnableSpdy(spdy_mode); 654 EnableSpdy(spdy_mode);
655 used_spdy_switch = true; 655 used_spdy_switch = true;
656 } 656 }
657 if (parsed_command_line.HasSwitch(switches::kEnableSpdy3)) { 657 if (parsed_command_line.HasSwitch(switches::kEnableSpdy3)) {
658 net::HttpStreamFactory::EnableNpnSpdy3(); 658 net::HttpStreamFactory::EnableNpnSpdy3();
659 used_spdy_switch = true; 659 used_spdy_switch = true;
660 } else if (parsed_command_line.HasSwitch(switches::kEnableNpn)) { 660 } else if (parsed_command_line.HasSwitch(switches::kEnableNpn)) {
661 net::HttpStreamFactory::EnableNpnSpdy(); 661 net::HttpStreamFactory::EnableNpnSpdy();
662 used_spdy_switch = true; 662 used_spdy_switch = true;
663 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { 663 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
664 net::HttpStreamFactory::EnableNpnHttpOnly(); 664 net::HttpStreamFactory::EnableNpnHttpOnly();
665 used_spdy_switch = true; 665 used_spdy_switch = true;
666 } 666 }
667 if (!used_spdy_switch) { 667 if (!used_spdy_switch) {
668 net::HttpStreamFactory::EnableNpnSpdy3(); 668 net::HttpStreamFactory::EnableNpnSpdy3();
669 } 669 }
670 } 670 }
671 671
672 void IOThread::EnableSpdy(const std::string& mode) {
673 static const char kOff[] = "off";
674 static const char kSSL[] = "ssl";
675 static const char kDisableSSL[] = "no-ssl";
676 static const char kDisablePing[] = "no-ping";
677 static const char kExclude[] = "exclude"; // Hosts to exclude
678 static const char kDisableCompression[] = "no-compress";
679 static const char kDisableAltProtocols[] = "no-alt-protocols";
680 static const char kForceAltProtocols[] = "force-alt-protocols";
681 static const char kSingleDomain[] = "single-domain";
Ryan Sleevi 2012/11/27 20:06:38 You have many more options documented here than in
Ryan Hamilton 2012/11/27 20:52:53 No idea what the history here is. I've updated th
682
683 static const char kInitialMaxConcurrentStreams[] = "init-max-streams";
684
685 std::vector<std::string> spdy_options;
686 base::SplitString(mode, ',', &spdy_options);
687
688 for (std::vector<std::string>::iterator it = spdy_options.begin();
689 it != spdy_options.end(); ++it) {
690 const std::string& element = *it;
691 std::vector<std::string> name_value;
692 base::SplitString(element, '=', &name_value);
693 const std::string& option = name_value[0];
694 const std::string value = name_value.size() > 1 ? name_value[1] : "";
695
696 if (option == kOff) {
697 net::HttpStreamFactory::set_spdy_enabled(false);
698 } else if (option == kDisableSSL) {
699 net::SpdySession::set_default_protocol(net::kProtoSPDY2);
700 net::HttpStreamFactory::set_force_spdy_over_ssl(false);
701 net::HttpStreamFactory::set_force_spdy_always(true);
702 } else if (option == kSSL) {
703 net::SpdySession::set_default_protocol(net::kProtoSPDY2);
704 net::HttpStreamFactory::set_force_spdy_over_ssl(true);
705 net::HttpStreamFactory::set_force_spdy_always(true);
706 } else if (option == kDisablePing) {
707 net::SpdySession::set_enable_ping_based_connection_checking(false);
708 } else if (option == kExclude) {
709 net::HttpStreamFactory::add_forced_spdy_exclusion(value);
710 } else if (option == kDisableCompression) {
711 net::BufferedSpdyFramer::set_enable_compression_default(false);
712 } else if (option == kDisableAltProtocols) {
713 net::HttpStreamFactory::set_use_alternate_protocols(false);
714 } else if (option == kForceAltProtocols) {
715 net::PortAlternateProtocolPair pair;
716 pair.port = 443;
717 pair.protocol = net::NPN_SPDY_2;
718 net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
719 } else if (option == kSingleDomain) {
720 net::SpdySessionPool::ForceSingleDomain();
721 LOG(ERROR) << "FORCING SINGLE DOMAIN";
Ryan Sleevi 2012/11/27 20:06:38 Does this *really* need to be a LOG(ERROR)?
Ryan Hamilton 2012/11/27 20:52:53 Changed to DLOG(INFO).
722 } else if (option == kInitialMaxConcurrentStreams) {
723 int streams;
724 if (base::StringToInt(value, &streams) && streams > 0)
725 net::SpdySession::set_init_max_concurrent_streams(streams);
726 } else if (option.empty() && it == spdy_options.begin()) {
727 continue;
Ryan Sleevi 2012/11/27 20:06:38 So ",foo" is a valid option string?
Ryan Hamilton 2012/11/27 20:52:53 Actually that appears to crash. I've fixed a bug
728 } else {
729 LOG(DFATAL) << "Unrecognized spdy option: " << option;
Ryan Sleevi 2012/11/27 20:06:38 Should you just rewrite this as LOG(ERROR)? Trying
Ryan Hamilton 2012/11/27 20:52:53 I'm happy to change this, but in my experience wit
730 }
Ryan Sleevi 2012/11/27 20:06:38 It strikes me as odd that "off,ssl,no-ssl" is a pe
Ryan Hamilton 2012/11/27 20:52:53 Yes, this is a very strange piece of code.
731 }
732 }
733
672 // static 734 // static
673 void IOThread::RegisterPrefs(PrefService* local_state) { 735 void IOThread::RegisterPrefs(PrefService* local_state) {
674 local_state->RegisterStringPref(prefs::kAuthSchemes, 736 local_state->RegisterStringPref(prefs::kAuthSchemes,
675 "basic,digest,ntlm,negotiate," 737 "basic,digest,ntlm,negotiate,"
676 "spdyproxy"); 738 "spdyproxy");
677 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, 739 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup,
678 false); 740 false);
679 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); 741 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false);
680 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); 742 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, "");
681 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); 743 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, "");
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 new net::HttpNetworkLayer( 870 new net::HttpNetworkLayer(
809 new net::HttpNetworkSession(system_params))); 871 new net::HttpNetworkSession(system_params)));
810 globals_->system_ftp_transaction_factory.reset( 872 globals_->system_ftp_transaction_factory.reset(
811 new net::FtpNetworkLayer(globals_->host_resolver.get())); 873 new net::FtpNetworkLayer(globals_->host_resolver.get()));
812 globals_->system_request_context.reset( 874 globals_->system_request_context.reset(
813 ConstructSystemRequestContext(globals_, net_log_)); 875 ConstructSystemRequestContext(globals_, net_log_));
814 876
815 sdch_manager_->set_sdch_fetcher( 877 sdch_manager_->set_sdch_fetcher(
816 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 878 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
817 } 879 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698