diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-15 23:14:14 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-15 23:14:14 +0000 |
commit | 85c0ed8299a1c029964ed58082e6d94a32d4dd9b (patch) | |
tree | 9b8ee6b9c9a8240f9fbe58adc96fa379ab856b76 | |
parent | b7a12f7cfbace2b35037aac28d71b1a5159cad7e (diff) | |
download | chromium_src-85c0ed8299a1c029964ed58082e6d94a32d4dd9b.zip chromium_src-85c0ed8299a1c029964ed58082e6d94a32d4dd9b.tar.gz chromium_src-85c0ed8299a1c029964ed58082e6d94a32d4dd9b.tar.bz2 |
Flip: Comma delimit the various flip options. Redo the fixed testing server flags.
Renames --testing-fixed-server to --testing-fixed-host. Adds --testing-fixed-http-port and --testing-fixed-https-port.
Review URL: http://codereview.chromium.org/501032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34624 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_main.cc | 14 | ||||
-rw-r--r-- | chrome/browser/net/dns_global.cc | 9 | ||||
-rw-r--r-- | chrome/common/chrome_switches.cc | 10 | ||||
-rw-r--r-- | chrome/common/chrome_switches.h | 4 | ||||
-rw-r--r-- | net/base/fixed_host_resolver.cc | 20 | ||||
-rw-r--r-- | net/base/fixed_host_resolver.h | 7 | ||||
-rw-r--r-- | net/flip/flip_network_transaction.cc | 9 | ||||
-rw-r--r-- | net/flip/flip_session.h | 1 | ||||
-rw-r--r-- | net/http/http_network_layer.cc | 44 | ||||
-rw-r--r-- | net/http/http_network_layer.h | 2 | ||||
-rw-r--r-- | net/http/http_network_session.cc | 4 | ||||
-rw-r--r-- | net/http/http_network_session.h | 9 | ||||
-rw-r--r-- | net/http/http_network_transaction.cc | 8 | ||||
-rw-r--r-- | net/http/http_network_transaction.h | 1 |
14 files changed, 99 insertions, 43 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index f378f27..01debdb 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -644,6 +644,20 @@ int BrowserMain(const MainFunctionParams& parameters) { net::CookieMonster::EnableFileScheme(); } + if (parsed_command_line.HasSwitch(switches::kFixedHttpPort)) { + std::string http_port_str = + parsed_command_line.GetSwitchValueASCII(switches::kFixedHttpPort); + int http_port = StringToInt(http_port_str); + net::HttpNetworkSession::set_fixed_http_port(http_port); + } + + if (parsed_command_line.HasSwitch(switches::kFixedHttpsPort)) { + std::string https_port_str = + parsed_command_line.GetSwitchValueASCII(switches::kFixedHttpsPort); + int https_port = StringToInt(https_port_str); + net::HttpNetworkSession::set_fixed_https_port(https_port); + } + // Initialize histogram statistics gathering system. StatisticsRecorder statistics; diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc index be0cae3..bb2abad 100644 --- a/chrome/browser/net/dns_global.cc +++ b/chrome/browser/net/dns_global.cc @@ -478,10 +478,10 @@ net::HostResolver* GetGlobalHostResolver() { // The FixedHostResolver allows us to send all network requests through // a designated test server. - if (command_line.HasSwitch(switches::kFixedServer)) { - std::string host_and_port = - WideToASCII(command_line.GetSwitchValue(switches::kFixedServer)); - global_host_resolver = new net::FixedHostResolver(host_and_port); + if (command_line.HasSwitch(switches::kFixedHost)) { + std::string host = + command_line.GetSwitchValueASCII(switches::kFixedHost); + global_host_resolver = new net::FixedHostResolver(host); } else { global_host_resolver = net::CreateSystemHostResolver(); @@ -672,4 +672,3 @@ DnsPrefetcherInit::~DnsPrefetcherInit() { } } // namespace chrome_browser_net - diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc index e6fcabe..64ab2ee 100644 --- a/chrome/common/chrome_switches.cc +++ b/chrome/common/chrome_switches.cc @@ -599,12 +599,16 @@ const char kUseFlip[] = "use-flip"; // Force all requests to go to this server. This commandline is provided // for testing purposes only, and will likely be removed soon. It can also // hurt startup performance as it does a synchronous name resolution on the -// UI thread. The port is not optional. +// UI thread. // The host resolution using this scheme is done exactly once at startup. // From that point on, it is completely a static configuration. // TODO(mbelshe): Remove this flag when testing is complete. -// --testing-fixed-server=myserver:1000 -const char kFixedServer[] = "testing-fixed-server"; +// --testing-fixed-host=myserver +const char kFixedHost[] = "testing-fixed-host"; + +// These two flags are used to force http and https requests to fixed ports. +const char kFixedHttpPort[] = "testing-fixed-http-port"; +const char kFixedHttpsPort[] = "testing-fixed-https-port"; // Use the low fragmentation heap for the CRT. const char kUseLowFragHeapCrt[] = "use-lf-heap"; diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h index d929821..4e9e702 100644 --- a/chrome/common/chrome_switches.h +++ b/chrome/common/chrome_switches.h @@ -169,7 +169,9 @@ extern const char kTrustedPlugins[]; extern const char kTryChromeAgain[]; extern const char kUninstall[]; extern const char kUseFlip[]; -extern const char kFixedServer[]; +extern const char kFixedHost[]; +extern const char kFixedHttpPort[]; +extern const char kFixedHttpsPort[]; extern const char kUseLowFragHeapCrt[]; extern const char kUserAgent[]; extern const char kUserDataDir[]; diff --git a/net/base/fixed_host_resolver.cc b/net/base/fixed_host_resolver.cc index 54e48a9..47089f1 100644 --- a/net/base/fixed_host_resolver.cc +++ b/net/base/fixed_host_resolver.cc @@ -10,12 +10,12 @@ namespace net { -FixedHostResolver::FixedHostResolver(const std::string& host_and_port) +FixedHostResolver::FixedHostResolver(const std::string& host) : initialized_(false) { - std::string host; - int port = 0; - if (!ParseHostAndPort(host_and_port, &host, &port)) { - LOG(ERROR) << "Invalid FixedHostResolver information: " << host_and_port; + int port; + std::string parsed_host; + if (!ParseHostAndPort(host, &parsed_host, &port)) { + LOG(DFATAL) << "Invalid FixedHostResolver information: " << host; return; } @@ -26,12 +26,6 @@ FixedHostResolver::FixedHostResolver(const std::string& host_and_port) return; } - if (port <= 0) { - LOG(ERROR) << "FixedHostResolver must contain a port number"; - return; - } - - address_.SetPort(port); initialized_ = true; } @@ -44,9 +38,9 @@ int FixedHostResolver::Resolve(const RequestInfo& info, return ERR_NAME_NOT_RESOLVED; DCHECK(addresses); - *addresses = address_; + addresses->Copy(address_.head()); + addresses->SetPort(info.port()); return OK; } } // namespace net - diff --git a/net/base/fixed_host_resolver.h b/net/base/fixed_host_resolver.h index 3ae3209..92ffeee 100644 --- a/net/base/fixed_host_resolver.h +++ b/net/base/fixed_host_resolver.h @@ -15,9 +15,9 @@ namespace net { // A FixedHostResolver resolves all addresses to a single address. class FixedHostResolver : public HostResolver { public: - // |host_and_port| is a string representing the resolution. - // example: foo.myproxy.com:1234 - explicit FixedHostResolver(const std::string& host_and_port); + // |host| is a string representing the resolution. + // example: foo.myproxy.com + explicit FixedHostResolver(const std::string& host); // HostResolver methods: virtual int Resolve(const RequestInfo& info, @@ -41,4 +41,3 @@ class FixedHostResolver : public HostResolver { } // namespace net #endif // NET_BASE_MOCK_HOST_RESOLVER_H_ - diff --git a/net/flip/flip_network_transaction.cc b/net/flip/flip_network_transaction.cc index 1e1320a..4b94b1f 100644 --- a/net/flip/flip_network_transaction.cc +++ b/net/flip/flip_network_transaction.cc @@ -218,6 +218,15 @@ int FlipNetworkTransaction::DoInitConnection() { std::string host = request_->url.HostNoBrackets(); int port = request_->url.EffectiveIntPort(); + // Use the fixed testing ports if they've been provided. This is useful for + // debugging. + if (FlipSession::SSLMode()) { + if (session_->fixed_https_port() != 0) + port = session_->fixed_https_port(); + } else if (session_->fixed_http_port() != 0) { + port = session_->fixed_http_port(); + } + std::string connection_group = "flip."; connection_group.append(host); diff --git a/net/flip/flip_session.h b/net/flip/flip_session.h index ff9a324..d0d9142 100644 --- a/net/flip/flip_session.h +++ b/net/flip/flip_session.h @@ -76,6 +76,7 @@ class FlipSession : public base::RefCounted<FlipSession>, // Enable or disable SSL. static void SetSSLMode(bool enable) { use_ssl_ = enable; } + static bool SSLMode() { return use_ssl_; } protected: friend class FlipSessionPool; diff --git a/net/http/http_network_layer.cc b/net/http/http_network_layer.cc index 74cd548..fd8377b 100644 --- a/net/http/http_network_layer.cc +++ b/net/http/http_network_layer.cc @@ -5,6 +5,7 @@ #include "net/http/http_network_layer.h" #include "base/logging.h" +#include "base/string_util.h" #include "net/flip/flip_framer.h" #include "net/flip/flip_network_transaction.h" #include "net/flip/flip_session.h" @@ -37,7 +38,7 @@ HttpTransactionFactory* HttpNetworkLayer::CreateFactory( } //----------------------------------------------------------------------------- -bool HttpNetworkLayer::enable_flip_ = false; +bool HttpNetworkLayer::force_flip_ = false; HttpNetworkLayer::HttpNetworkLayer(ClientSocketFactory* socket_factory, HostResolver* host_resolver, @@ -70,7 +71,7 @@ int HttpNetworkLayer::CreateTransaction(scoped_ptr<HttpTransaction>* trans) { if (suspended_) return ERR_NETWORK_IO_SUSPENDED; - if (enable_flip_) + if (force_flip_) trans->reset(new FlipNetworkTransaction(GetSession())); else trans->reset(new HttpNetworkTransaction(GetSession())); @@ -91,7 +92,7 @@ void HttpNetworkLayer::Suspend(bool suspend) { HttpNetworkSession* HttpNetworkLayer::GetSession() { if (!session_) { DCHECK(proxy_service_); - FlipSessionPool* flip_pool = enable_flip_ ? new FlipSessionPool : NULL; + FlipSessionPool* flip_pool = new FlipSessionPool; session_ = new HttpNetworkSession( host_resolver_, proxy_service_, socket_factory_, ssl_config_service_, flip_pool); @@ -105,20 +106,31 @@ HttpNetworkSession* HttpNetworkLayer::GetSession() { // static void HttpNetworkLayer::EnableFlip(const std::string& mode) { - static const std::string kDisableSSL("no-ssl"); - static const std::string kDisableCompression("no-compress"); - static const std::string kDisableEverything("no-ssl-no-compress"); - - // Enable flip mode. - enable_flip_ = true; - - // Disable SSL - if (mode == kDisableEverything || mode == kDisableSSL) - FlipSession::SetSSLMode(false); + static const char kDisableSSL[] = "no-ssl"; + static const char kDisableCompression[] = "no-compress"; + + std::vector<std::string> flip_options; + SplitString(mode, ',', &flip_options); + + // Force flip mode (use FlipNetworkTransaction for all http requests). + force_flip_ = true; + + for (std::vector<std::string>::iterator it = flip_options.begin(); + it != flip_options.end(); ++it) { + const std::string& option = *it; + + // Disable SSL + if (option == kDisableSSL) { + FlipSession::SetSSLMode(false); + } else if (option == kDisableCompression) { + flip::FlipFramer::set_enable_compression_default(false); + } else if (option.empty() && it == flip_options.begin()) { + continue; + } else { + LOG(DFATAL) << "Unrecognized flip option: " << option; + } + } - // Disable compression - if (mode == kDisableEverything || mode == kDisableCompression) - flip::FlipFramer::set_enable_compression_default(false); } } // namespace net diff --git a/net/http/http_network_layer.h b/net/http/http_network_layer.h index e40be8c..4dbf9a4 100644 --- a/net/http/http_network_layer.h +++ b/net/http/http_network_layer.h @@ -77,7 +77,7 @@ class HttpNetworkLayer : public HttpTransactionFactory { scoped_refptr<FlipSessionPool> flip_session_pool_; bool suspended_; - static bool enable_flip_; + static bool force_flip_; }; } // namespace net diff --git a/net/http/http_network_session.cc b/net/http/http_network_session.cc index f372292..1c6f2fe 100644 --- a/net/http/http_network_session.cc +++ b/net/http/http_network_session.cc @@ -15,6 +15,10 @@ int HttpNetworkSession::max_sockets_ = 100; // static int HttpNetworkSession::max_sockets_per_group_ = 6; +// static +uint16 HttpNetworkSession::g_fixed_http_port = 0; +uint16 HttpNetworkSession::g_fixed_https_port = 0; + HttpNetworkSession::HttpNetworkSession( HostResolver* host_resolver, ProxyService* proxy_service, diff --git a/net/http/http_network_session.h b/net/http/http_network_session.h index f2e76e2..27267bb 100644 --- a/net/http/http_network_session.h +++ b/net/http/http_network_session.h @@ -44,6 +44,12 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { static void set_max_sockets_per_group(int socket_count); + static uint16 fixed_http_port() { return g_fixed_http_port; } + static void set_fixed_http_port(uint16 port) { g_fixed_http_port = port; } + + static uint16 fixed_https_port() { return g_fixed_https_port; } + static void set_fixed_https_port(uint16 port) { g_fixed_https_port = port; } + private: friend class base::RefCounted<HttpNetworkSession>; FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections); @@ -58,6 +64,9 @@ class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { // as home routers blocking the connections!?!? static int max_sockets_per_group_; + static uint16 g_fixed_http_port; + static uint16 g_fixed_https_port; + HttpAuthCache auth_cache_; SSLClientAuthCache ssl_client_auth_cache_; scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; diff --git a/net/http/http_network_transaction.cc b/net/http/http_network_transaction.cc index 41df85f..6e925b8 100644 --- a/net/http/http_network_transaction.cc +++ b/net/http/http_network_transaction.cc @@ -561,6 +561,14 @@ int HttpNetworkTransaction::DoInitConnection() { port = request_->url.EffectiveIntPort(); } + // Use the fixed testing ports if they've been provided. + if (using_ssl_) { + if (session_->fixed_https_port() != 0) + port = session_->fixed_https_port(); + } else if (session_->fixed_http_port() != 0) { + port = session_->fixed_http_port(); + } + // For a connection via HTTP proxy not using CONNECT, the connection // is to the proxy server only. For all other cases // (direct, HTTP proxy CONNECT, SOCKS), the connection is upto the diff --git a/net/http/http_network_transaction.h b/net/http/http_network_transaction.h index f540bd9..d19638b 100644 --- a/net/http/http_network_transaction.h +++ b/net/http/http_network_transaction.h @@ -7,6 +7,7 @@ #include <string> +#include "base/basictypes.h" #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/time.h" |