summaryrefslogtreecommitdiffstats
path: root/net/socket/socket_test_util.cc
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.cc
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.cc')
-rw-r--r--net/socket/socket_test_util.cc59
1 files changed, 55 insertions, 4 deletions
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 9e74d88..360f34f 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -256,10 +256,6 @@ MockSSLClientSocket::~MockSSLClientSocket() {
Disconnect();
}
-void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
- ssl_info->Reset();
-}
-
int MockSSLClientSocket::Connect(net::CompletionCallback* callback) {
ConnectCallback* connect_callback = new ConnectCallback(
this, callback, data_->connect.result);
@@ -293,6 +289,16 @@ int MockSSLClientSocket::Write(net::IOBuffer* buf, int buf_len,
return transport_->Write(buf, buf_len, callback);
}
+void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
+ ssl_info->Reset();
+}
+
+SSLClientSocket::NextProtoStatus MockSSLClientSocket::GetNextProto(
+ std::string* proto) {
+ *proto = data_->next_proto;
+ return data_->next_proto_status;
+}
+
MockRead StaticSocketDataProvider::GetNextRead() {
DCHECK(!at_read_eof());
reads_[read_index_].time_stamp = base::Time::Now();
@@ -386,6 +392,51 @@ void DynamicSocketDataProvider::SimulateRead(const char* data) {
reads_.push_back(MockRead(data));
}
+DelayedSocketData::DelayedSocketData(
+ int write_delay, MockRead* reads, size_t reads_count,
+ MockWrite* writes, size_t writes_count)
+ : StaticSocketDataProvider(reads, reads_count, writes, writes_count),
+ write_delay_(write_delay),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
+ DCHECK_GE(write_delay_, 0);
+}
+
+DelayedSocketData::DelayedSocketData(
+ const MockConnect& connect, int write_delay, MockRead* reads,
+ size_t reads_count, MockWrite* writes, size_t writes_count)
+ : StaticSocketDataProvider(reads, reads_count, writes, writes_count),
+ write_delay_(write_delay),
+ ALLOW_THIS_IN_INITIALIZER_LIST(factory_(this)) {
+ DCHECK_GE(write_delay_, 0);
+ set_connect_data(connect);
+}
+
+MockRead DelayedSocketData::GetNextRead() {
+ if (write_delay_)
+ return MockRead(true, ERR_IO_PENDING);
+ return StaticSocketDataProvider::GetNextRead();
+}
+
+MockWriteResult DelayedSocketData::OnWrite(const std::string& data) {
+ MockWriteResult rv = StaticSocketDataProvider::OnWrite(data);
+ // Now that our write has completed, we can allow reads to continue.
+ if (!--write_delay_)
+ MessageLoop::current()->PostDelayedTask(FROM_HERE,
+ factory_.NewRunnableMethod(&DelayedSocketData::CompleteRead), 100);
+ return rv;
+}
+
+void DelayedSocketData::Reset() {
+ set_socket(NULL);
+ factory_.RevokeAll();
+ StaticSocketDataProvider::Reset();
+}
+
+void DelayedSocketData::CompleteRead() {
+ if (socket())
+ socket()->OnReadComplete(GetNextRead());
+}
+
void MockClientSocketFactory::AddSocketDataProvider(
SocketDataProvider* data) {
mock_data_.Add(data);