diff options
-rw-r--r-- | net/flip/flip_framer.h | 2 | ||||
-rw-r--r-- | net/flip/flip_network_transaction_unittest.cc | 49 | ||||
-rw-r--r-- | net/flip/flip_session.cc | 26 | ||||
-rw-r--r-- | net/flip/flip_session.h | 7 |
4 files changed, 43 insertions, 41 deletions
diff --git a/net/flip/flip_framer.h b/net/flip/flip_framer.h index b7a2cc0..5275017 100644 --- a/net/flip/flip_framer.h +++ b/net/flip/flip_framer.h @@ -174,7 +174,7 @@ class FlipFramer { protected: FRIEND_TEST(FlipFramerTest, Basic); FRIEND_TEST(FlipFramerTest, HeaderBlockBarfsOnOutOfOrderHeaders); - friend class FlipNetworkTransactionTest; + friend class net::FlipNetworkTransactionTest; // For ease of testing we can tweak compression on/off. void set_enable_compression(bool value); diff --git a/net/flip/flip_network_transaction_unittest.cc b/net/flip/flip_network_transaction_unittest.cc index 0d2e97d..01a2faf 100644 --- a/net/flip/flip_network_transaction_unittest.cc +++ b/net/flip/flip_network_transaction_unittest.cc @@ -21,18 +21,15 @@ #include "net/socket/client_socket_factory.h" #include "net/socket/socket_test_util.h" #include "net/socket/ssl_client_socket.h" -#include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" //----------------------------------------------------------------------------- -namespace flip { - -using namespace net; +namespace { // Create a proxy service which fails on all requests (falls back to direct). -ProxyService* CreateNullProxyService() { - return ProxyService::CreateNull(); +net::ProxyService* CreateNullProxyService() { + return net::ProxyService::CreateNull(); } // Helper to manage the lifetimes of the dependencies for a @@ -41,41 +38,45 @@ class SessionDependencies { public: // Default set of dependencies -- "null" proxy service. SessionDependencies() - : host_resolver(new MockHostResolver), + : host_resolver(new net::MockHostResolver), proxy_service(CreateNullProxyService()), - ssl_config_service(new SSLConfigServiceDefaults) {} + ssl_config_service(new net::SSLConfigServiceDefaults) {} // Custom proxy service dependency. - explicit SessionDependencies(ProxyService* proxy_service) - : host_resolver(new MockHostResolver), + explicit SessionDependencies(net::ProxyService* proxy_service) + : host_resolver(new net::MockHostResolver), proxy_service(proxy_service), - ssl_config_service(new SSLConfigServiceDefaults) {} + ssl_config_service(new net::SSLConfigServiceDefaults) {} - scoped_refptr<MockHostResolverBase> host_resolver; - scoped_refptr<ProxyService> proxy_service; - scoped_refptr<SSLConfigService> ssl_config_service; - MockClientSocketFactory socket_factory; + scoped_refptr<net::MockHostResolverBase> host_resolver; + scoped_refptr<net::ProxyService> proxy_service; + scoped_refptr<net::SSLConfigService> ssl_config_service; + net::MockClientSocketFactory socket_factory; }; -ProxyService* CreateFixedProxyService(const std::string& proxy) { +net::ProxyService* CreateFixedProxyService(const std::string& proxy) { net::ProxyConfig proxy_config; proxy_config.proxy_rules.ParseFromString(proxy); - return ProxyService::CreateFixed(proxy_config); + return net::ProxyService::CreateFixed(proxy_config); } -HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { - return new HttpNetworkSession(session_deps->host_resolver, - session_deps->proxy_service, - &session_deps->socket_factory, - session_deps->ssl_config_service); +net::HttpNetworkSession* CreateSession(SessionDependencies* session_deps) { + return new net::HttpNetworkSession(session_deps->host_resolver, + session_deps->proxy_service, + &session_deps->socket_factory, + session_deps->ssl_config_service); } +} // namespace + +namespace net { + class FlipNetworkTransactionTest : public PlatformTest { public: virtual void SetUp() { // Disable compression on this test. - FlipFramer::set_enable_compression_default(false); + flip::FlipFramer::set_enable_compression_default(false); } virtual void TearDown() { @@ -179,6 +180,8 @@ TEST_F(FlipNetworkTransactionTest, Connect) { MockRead(true, 0, 0), // EOF }; + // We disable SSL for this test. + FlipSession::SetSSLMode(false); SimpleGetHelperResult out = SimpleGetHelper(data_reads); EXPECT_EQ(OK, out.rv); EXPECT_EQ("HTTP/1.1 200 OK", out.status_line); diff --git a/net/flip/flip_session.cc b/net/flip/flip_session.cc index 4854067..51631f9 100644 --- a/net/flip/flip_session.cc +++ b/net/flip/flip_session.cc @@ -21,20 +21,11 @@ #include "net/socket/ssl_client_socket.h" #include "net/tools/dump_cache/url_to_filename_encoder.h" -namespace { - -// True if FLIP should run over SSL. -static bool use_ssl_flip = false; - -} // namespace - namespace net { // static scoped_ptr<FlipSessionPool> FlipSession::session_pool_; -// static -bool FlipSession::disable_compression_ = false; -// static +bool FlipSession::use_ssl_ = true; int PrioritizedIOBuffer::order_ = 0; // The FlipStreamImpl is an internal class representing an active FlipStream. @@ -339,7 +330,7 @@ void FlipSession::OnTCPConnect(int result) { connection_.socket()->SetReceiveBufferSize(kSocketBufferSize); connection_.socket()->SetSendBufferSize(kSocketBufferSize); - if (use_ssl_flip) { + if (use_ssl_) { // Add a SSL socket on top of our existing transport socket. ClientSocket* socket = connection_.release_socket(); // TODO(mbelshe): Fix the hostname. This is BROKEN without having @@ -502,6 +493,11 @@ void FlipSession::WriteSocket() { write_pending_ = true; break; } + if (rv < 0) { + // Uhoh - an error! + // TODO(mbelshe): fix me! + NOTIMPLEMENTED(); + } LOG(INFO) << "FLIPSession wrote " << rv << " bytes."; in_flight_write_.release(); } @@ -607,11 +603,11 @@ void FlipSession::OnStreamFrameData(flip::FlipStreamId stream_id, LOG(INFO) << "Flip data for stream " << stream_id << ", " << len << " bytes"; bool valid_stream = IsStreamActive(stream_id); if (!valid_stream) { - LOG(WARNING) << "Received data frame for invalid stream" << stream_id; + LOG(WARNING) << "Received data frame for invalid stream " << stream_id; return; } - if (!len) - return; // This was just an empty data packet. + //if (!len) + // return; // This was just an empty data packet. FlipStreamImpl* stream = active_streams_[stream_id]; if (stream->OnData(data, len)) { DeactivateStream(stream->stream_id()); @@ -675,7 +671,7 @@ void FlipSession::OnSynReply(const flip::FlipSynReplyControlFrame* frame, flip::FlipStreamId stream_id = frame->stream_id(); bool valid_stream = IsStreamActive(stream_id); if (!valid_stream) { - LOG(WARNING) << "Received SYN_REPLY for invalid stream" << stream_id; + LOG(WARNING) << "Received SYN_REPLY for invalid stream " << stream_id; return; } diff --git a/net/flip/flip_session.h b/net/flip/flip_session.h index c8e3f1e..1ee874b 100644 --- a/net/flip/flip_session.h +++ b/net/flip/flip_session.h @@ -112,7 +112,7 @@ class FlipSession : public base::RefCounted<FlipSession>, // status, such as "resolving host", "connecting", etc. LoadState GetLoadState() const; protected: - friend class FlipNetworkTransactionTest; + FRIEND_TEST(FlipNetworkTransactionTest, Connect); friend class FlipSessionPool; // Provide access to the framer for testing. @@ -125,6 +125,9 @@ class FlipSession : public base::RefCounted<FlipSession>, // Closes all open streams. Used as part of shutdown. void CloseAllStreams(net::Error code); + // Enable or disable SSL. This is only to be used for testing. + static void SetSSLMode(bool enable) { use_ssl_ = enable; } + private: // FlipFramerVisitorInterface virtual void OnError(flip::FlipFramer*); @@ -215,7 +218,7 @@ class FlipSession : public base::RefCounted<FlipSession>, // This is our weak session pool - one session per domain. static scoped_ptr<FlipSessionPool> session_pool_; - static bool disable_compression_; + static bool use_ssl_; }; } // namespace net |