summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 20:06:05 +0000
committermbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-14 20:06:05 +0000
commitaffe8fef0a2d2e0115c3f0607df819d3e9db6237 (patch)
treeb3d0ae849f1e8121e6e0511eb137e141f950615f
parent72f966bbd75a095ef73a121e16f5713172b51d09 (diff)
downloadchromium_src-affe8fef0a2d2e0115c3f0607df819d3e9db6237.zip
chromium_src-affe8fef0a2d2e0115c3f0607df819d3e9db6237.tar.gz
chromium_src-affe8fef0a2d2e0115c3f0607df819d3e9db6237.tar.bz2
Enable SSL in FLIP.
The unit tests don't test SSL, so add a flag to statically turn off SSL just for the tests. Move flip_network_transaction_unittest mostly into the net namespace, which is probably where it should be. BUG=none TEST=none Review URL: http://codereview.chromium.org/275012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29004 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--net/flip/flip_framer.h2
-rw-r--r--net/flip/flip_network_transaction_unittest.cc49
-rw-r--r--net/flip/flip_session.cc26
-rw-r--r--net/flip/flip_session.h7
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