summaryrefslogtreecommitdiffstats
path: root/net/socket/socket_test_util.h
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-26 22:20:54 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-26 22:20:54 +0000
commit2ff8b3133033d6130ea87df3ab2290a226c7bca7 (patch)
tree74ee45d17428c359a0bd8db8b97e51eeb4b7c44c /net/socket/socket_test_util.h
parent106113b3dde22f7d8b3a7f9a00a8884668cda782 (diff)
downloadchromium_src-2ff8b3133033d6130ea87df3ab2290a226c7bca7.zip
chromium_src-2ff8b3133033d6130ea87df3ab2290a226c7bca7.tar.gz
chromium_src-2ff8b3133033d6130ea87df3ab2290a226c7bca7.tar.bz2
SPDY: Fix Alternate-Protocol.
(1) In DoInitConnection() we do the existing spdy session check. If it exists there, then we assuem it exists in DoSpdySendRequest(). Unfortunately, we didn't do the same check. Use a member variable to store the HostPortPair. (2) In DoInitConnection(), we used the scheme://urlhost:urlport as the connection group. With Alternate-Protocol, we used the scheme://urlhost:urlport even though we were connecting to a different port, with a different protocol (TLS). This means we would mix conflicting sockets in the ClientSocketPool. I fix this by dropping scheme://, since it's unnecessary, and would cause us not to share SSL sockets in different connection groups (since the specified scheme might be http://, but due to Alternate-Protocol, we actually do an SSL connect). I also don't use the urlhost:urlport, but use the host:port that we actually connect to. TODO(willchan): Fix Alternate-Protocol so it works properly with proxies. I need to change CONNECT for http proxies and patch the SOCKs connects. Review URL: http://codereview.chromium.org/1755005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45627 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/socket_test_util.h')
-rw-r--r--net/socket/socket_test_util.h51
1 files changed, 48 insertions, 3 deletions
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index 4358a72..e309786c 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -229,9 +229,51 @@ class DynamicSocketDataProvider : public SocketDataProvider {
// SSLSocketDataProviders only need to keep track of the return code from calls
// to Connect().
struct SSLSocketDataProvider {
- SSLSocketDataProvider(bool async, int result) : connect(async, result) { }
+ SSLSocketDataProvider(bool async, int result)
+ : connect(async, result),
+ next_proto_status(SSLClientSocket::kNextProtoUnsupported) { }
MockConnect connect;
+ SSLClientSocket::NextProtoStatus next_proto_status;
+ std::string next_proto;
+};
+
+// A DataProvider where the client must write a request before the reads (e.g.
+// the response) will complete.
+class DelayedSocketData : public StaticSocketDataProvider,
+ public base::RefCounted<DelayedSocketData> {
+ public:
+ // |write_delay| the number of MockWrites to complete before allowing
+ // a MockRead to complete.
+ // |reads| the list of MockRead completions.
+ // |writes| the list of MockWrite completions.
+ // Note: All MockReads and MockWrites must be async.
+ // Note: The MockRead and MockWrite lists musts end with a EOF
+ // e.g. a MockRead(true, 0, 0);
+ DelayedSocketData(int write_delay,
+ MockRead* reads, size_t reads_count,
+ MockWrite* writes, size_t writes_count);
+
+ // |connect| the result for the connect phase.
+ // |reads| the list of MockRead completions.
+ // |write_delay| the number of MockWrites to complete before allowing
+ // a MockRead to complete.
+ // |writes| the list of MockWrite completions.
+ // Note: All MockReads and MockWrites must be async.
+ // Note: The MockRead and MockWrite lists musts end with a EOF
+ // e.g. a MockRead(true, 0, 0);
+ DelayedSocketData(const MockConnect& connect, int write_delay,
+ MockRead* reads, size_t reads_count,
+ MockWrite* writes, size_t writes_count);
+
+ virtual MockRead GetNextRead();
+ virtual MockWriteResult OnWrite(const std::string& data);
+ virtual void Reset();
+ void CompleteRead();
+
+ private:
+ int write_delay_;
+ ScopedRunnableMethodFactory<DelayedSocketData> factory_;
};
// Holds an array of SocketDataProvider elements. As Mock{TCP,SSL}ClientSocket
@@ -401,8 +443,7 @@ class MockSSLClientSocket : public MockClientSocket {
net::SSLSocketDataProvider* socket);
~MockSSLClientSocket();
- virtual void GetSSLInfo(net::SSLInfo* ssl_info);
-
+ // ClientSocket methods:
virtual int Connect(net::CompletionCallback* callback);
virtual void Disconnect();
@@ -412,6 +453,10 @@ class MockSSLClientSocket : public MockClientSocket {
virtual int Write(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback);
+ // SSLClientSocket methods:
+ virtual void GetSSLInfo(net::SSLInfo* ssl_info);
+ virtual NextProtoStatus GetNextProto(std::string* proto);
+
// This MockSocket does not implement the manual async IO feature.
virtual void OnReadComplete(const MockRead& data) { NOTIMPLEMENTED(); }