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

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: Rebase 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
« no previous file with comments | « chrome/browser/io_thread.h ('k') | net/http/http_network_layer.h » ('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) 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 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 627
628 if (parsed_command_line.HasSwitch(switches::kEnableWebSocketOverSpdy)) { 628 if (parsed_command_line.HasSwitch(switches::kEnableWebSocketOverSpdy)) {
629 // Enable WebSocket over SPDY. 629 // Enable WebSocket over SPDY.
630 net::WebSocketJob::set_websocket_over_spdy_enabled(true); 630 net::WebSocketJob::set_websocket_over_spdy_enabled(true);
631 } 631 }
632 632
633 bool used_spdy_switch = false; 633 bool used_spdy_switch = false;
634 if (parsed_command_line.HasSwitch(switches::kUseSpdy)) { 634 if (parsed_command_line.HasSwitch(switches::kUseSpdy)) {
635 std::string spdy_mode = 635 std::string spdy_mode =
636 parsed_command_line.GetSwitchValueASCII(switches::kUseSpdy); 636 parsed_command_line.GetSwitchValueASCII(switches::kUseSpdy);
637 net::HttpNetworkLayer::EnableSpdy(spdy_mode); 637 EnableSpdy(spdy_mode);
638 used_spdy_switch = true; 638 used_spdy_switch = true;
639 } 639 }
640 if (parsed_command_line.HasSwitch(switches::kEnableSpdy3)) { 640 if (parsed_command_line.HasSwitch(switches::kEnableSpdy3)) {
641 net::HttpStreamFactory::EnableNpnSpdy3(); 641 net::HttpStreamFactory::EnableNpnSpdy3();
642 used_spdy_switch = true; 642 used_spdy_switch = true;
643 } else if (parsed_command_line.HasSwitch(switches::kEnableNpn)) { 643 } else if (parsed_command_line.HasSwitch(switches::kEnableNpn)) {
644 net::HttpStreamFactory::EnableNpnSpdy(); 644 net::HttpStreamFactory::EnableNpnSpdy();
645 used_spdy_switch = true; 645 used_spdy_switch = true;
646 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) { 646 } else if (parsed_command_line.HasSwitch(switches::kEnableNpnHttpOnly)) {
647 net::HttpStreamFactory::EnableNpnHttpOnly(); 647 net::HttpStreamFactory::EnableNpnHttpOnly();
648 used_spdy_switch = true; 648 used_spdy_switch = true;
649 } 649 }
650 if (!used_spdy_switch) { 650 if (!used_spdy_switch) {
651 net::HttpStreamFactory::EnableNpnSpdy3(); 651 net::HttpStreamFactory::EnableNpnSpdy3();
652 } 652 }
653 } 653 }
654 654
655 void IOThread::EnableSpdy(const std::string& mode) {
656 static const char kOff[] = "off";
657 static const char kSSL[] = "ssl";
658 static const char kDisableSSL[] = "no-ssl";
659 static const char kDisablePing[] = "no-ping";
660 static const char kExclude[] = "exclude"; // Hosts to exclude
661 static const char kDisableCompression[] = "no-compress";
662 static const char kDisableAltProtocols[] = "no-alt-protocols";
663 static const char kForceAltProtocols[] = "force-alt-protocols";
664 static const char kSingleDomain[] = "single-domain";
665
666 static const char kInitialMaxConcurrentStreams[] = "init-max-streams";
667
668 std::vector<std::string> spdy_options;
669 base::SplitString(mode, ',', &spdy_options);
670
671 for (std::vector<std::string>::iterator it = spdy_options.begin();
672 it != spdy_options.end(); ++it) {
673 const std::string& element = *it;
674 std::vector<std::string> name_value;
675 base::SplitString(element, '=', &name_value);
676 const std::string& option = name_value.size() > 0 ? name_value[0] : "";
677 const std::string value = name_value.size() > 1 ? name_value[1] : "";
678
679 if (option == kOff) {
680 net::HttpStreamFactory::set_spdy_enabled(false);
681 } else if (option == kDisableSSL) {
682 net::SpdySession::set_default_protocol(net::kProtoSPDY2);
683 net::HttpStreamFactory::set_force_spdy_over_ssl(false);
684 net::HttpStreamFactory::set_force_spdy_always(true);
685 } else if (option == kSSL) {
686 net::SpdySession::set_default_protocol(net::kProtoSPDY2);
687 net::HttpStreamFactory::set_force_spdy_over_ssl(true);
688 net::HttpStreamFactory::set_force_spdy_always(true);
689 } else if (option == kDisablePing) {
690 net::SpdySession::set_enable_ping_based_connection_checking(false);
691 } else if (option == kExclude) {
692 net::HttpStreamFactory::add_forced_spdy_exclusion(value);
693 } else if (option == kDisableCompression) {
694 net::BufferedSpdyFramer::set_enable_compression_default(false);
695 } else if (option == kDisableAltProtocols) {
696 net::HttpStreamFactory::set_use_alternate_protocols(false);
697 } else if (option == kForceAltProtocols) {
698 net::PortAlternateProtocolPair pair;
699 pair.port = 443;
700 pair.protocol = net::NPN_SPDY_2;
701 net::HttpServerPropertiesImpl::ForceAlternateProtocol(pair);
702 } else if (option == kSingleDomain) {
703 DLOG(INFO) << "FORCING SINGLE DOMAIN";
704 net::SpdySessionPool::ForceSingleDomain();
705 } else if (option == kInitialMaxConcurrentStreams) {
706 int streams;
707 if (base::StringToInt(value, &streams) && streams > 0)
708 net::SpdySession::set_init_max_concurrent_streams(streams);
709 } else if (option.empty() && it == spdy_options.begin()) {
710 continue;
711 } else {
712 LOG(DFATAL) << "Unrecognized spdy option: " << option;
713 }
714 }
715 }
716
655 // static 717 // static
656 void IOThread::RegisterPrefs(PrefService* local_state) { 718 void IOThread::RegisterPrefs(PrefService* local_state) {
657 local_state->RegisterStringPref(prefs::kAuthSchemes, 719 local_state->RegisterStringPref(prefs::kAuthSchemes,
658 "basic,digest,ntlm,negotiate," 720 "basic,digest,ntlm,negotiate,"
659 "spdyproxy"); 721 "spdyproxy");
660 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, 722 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup,
661 false); 723 false);
662 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); 724 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false);
663 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); 725 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, "");
664 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); 726 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, "");
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 globals_->system_request_context.reset( 860 globals_->system_request_context.reset(
799 ConstructSystemRequestContext(globals_, net_log_)); 861 ConstructSystemRequestContext(globals_, net_log_));
800 862
801 sdch_manager_->set_sdch_fetcher( 863 sdch_manager_->set_sdch_fetcher(
802 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); 864 new SdchDictionaryFetcher(system_url_request_context_getter_.get()));
803 } 865 }
804 866
805 void IOThread::UpdateDnsClientEnabled() { 867 void IOThread::UpdateDnsClientEnabled() {
806 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); 868 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_);
807 } 869 }
OLDNEW
« no previous file with comments | « chrome/browser/io_thread.h ('k') | net/http/http_network_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698