diff options
Diffstat (limited to 'net')
28 files changed, 101 insertions, 20 deletions
diff --git a/net/curvecp/curvecp_client_socket.cc b/net/curvecp/curvecp_client_socket.cc index 5271174..30bb378 100644 --- a/net/curvecp/curvecp_client_socket.cc +++ b/net/curvecp/curvecp_client_socket.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -96,6 +96,10 @@ base::TimeDelta CurveCPClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +NextProto CurveCPClientSocket::GetNegotiatedProtocol() const { + return kProtoUnknown; +} + int CurveCPClientSocket::Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { diff --git a/net/curvecp/curvecp_client_socket.h b/net/curvecp/curvecp_client_socket.h index 7d7a361..3c6eea6 100644 --- a/net/curvecp/curvecp_client_socket.h +++ b/net/curvecp/curvecp_client_socket.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -39,6 +39,7 @@ class CurveCPClientSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual net::NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket methods: virtual int Read(IOBuffer* buf, diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc index 47aaa7b..f9ba3b8 100644 --- a/net/http/http_proxy_client_socket.cc +++ b/net/http/http_proxy_client_socket.cc @@ -201,6 +201,14 @@ base::TimeDelta HttpProxyClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +NextProto HttpProxyClientSocket::GetNegotiatedProtocol() const { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->GetNegotiatedProtocol(); + } + NOTREACHED(); + return kProtoUnknown; +} + int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { DCHECK(user_callback_.is_null()); diff --git a/net/http/http_proxy_client_socket.h b/net/http/http_proxy_client_socket.h index e0c9980..21d355a 100644 --- a/net/http/http_proxy_client_socket.h +++ b/net/http/http_proxy_client_socket.h @@ -73,6 +73,7 @@ class HttpProxyClientSocket : public ProxyClientSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/http/http_proxy_client_socket_pool.cc b/net/http/http_proxy_client_socket_pool.cc index e6adfac..67018779 100644 --- a/net/http/http_proxy_client_socket_pool.cc +++ b/net/http/http_proxy_client_socket_pool.cc @@ -238,7 +238,7 @@ int HttpProxyConnectJob::DoSSLConnectComplete(int result) { SSLClientSocket* ssl = static_cast<SSLClientSocket*>(transport_socket_handle_->socket()); using_spdy_ = ssl->was_spdy_negotiated(); - protocol_negotiated_ = ssl->protocol_negotiated(); + protocol_negotiated_ = ssl->GetNegotiatedProtocol(); // Reset the timer to just the length of time allowed for HttpProxy handshake // so that a fast SSL connection plus a slow HttpProxy failure doesn't take diff --git a/net/socket/buffered_write_stream_socket.cc b/net/socket/buffered_write_stream_socket.cc index 94c6d57..028dfde 100644 --- a/net/socket/buffered_write_stream_socket.cc +++ b/net/socket/buffered_write_stream_socket.cc @@ -119,6 +119,10 @@ base::TimeDelta BufferedWriteStreamSocket::GetConnectTimeMicros() const { return wrapped_socket_->GetConnectTimeMicros(); } +NextProto BufferedWriteStreamSocket::GetNegotiatedProtocol() const { + return wrapped_socket_->GetNegotiatedProtocol(); +} + void BufferedWriteStreamSocket::DoDelayedWrite() { int result = wrapped_socket_->Write( io_buffer_, io_buffer_->RemainingCapacity(), diff --git a/net/socket/buffered_write_stream_socket.h b/net/socket/buffered_write_stream_socket.h index a504209..a02380d 100644 --- a/net/socket/buffered_write_stream_socket.h +++ b/net/socket/buffered_write_stream_socket.h @@ -59,6 +59,7 @@ class NET_EXPORT_PRIVATE BufferedWriteStreamSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; private: void DoDelayedWrite(); diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc index 6c692fe..d5689c5 100644 --- a/net/socket/client_socket_pool_base_unittest.cc +++ b/net/socket/client_socket_pool_base_unittest.cc @@ -117,6 +117,9 @@ class MockClientSocket : public StreamSocket { base::TimeDelta::FromMicroseconds(10); return kDummyConnectTimeMicros; // Dummy value. } + virtual NextProto GetNegotiatedProtocol() const { + return kProtoUnknown; + } private: bool connected_; diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc index 21eed60..0e9ea78 100644 --- a/net/socket/socket_test_util.cc +++ b/net/socket/socket_test_util.cc @@ -1166,7 +1166,7 @@ bool MockSSLClientSocket::set_was_npn_negotiated(bool negotiated) { return new_npn_value_ = negotiated; } -NextProto MockSSLClientSocket::protocol_negotiated() const { +NextProto MockSSLClientSocket::GetNegotiatedProtocol() const { if (is_protocol_negotiated_set_) return protocol_negotiated_; return data_->protocol_negotiated; diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h index dbac707..350e0b4 100644 --- a/net/socket/socket_test_util.h +++ b/net/socket/socket_test_util.h @@ -750,9 +750,9 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { std::string* server_protos) OVERRIDE; virtual bool was_npn_negotiated() const OVERRIDE; virtual bool set_was_npn_negotiated(bool negotiated) OVERRIDE; - virtual NextProto protocol_negotiated() const OVERRIDE; virtual void set_protocol_negotiated( NextProto protocol_negotiated) OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // This MockSocket does not implement the manual async IO feature. virtual void OnReadComplete(const MockRead& data) OVERRIDE; diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc index 2c9d62a..dd75a4d 100644 --- a/net/socket/socks5_client_socket.cc +++ b/net/socket/socks5_client_socket.cc @@ -159,6 +159,14 @@ base::TimeDelta SOCKS5ClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +NextProto SOCKS5ClientSocket::GetNegotiatedProtocol() const { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->GetNegotiatedProtocol(); + } + NOTREACHED(); + return kProtoUnknown; +} + // Read is called by the transport layer above to read. This can only be done // if the SOCKS handshake is complete. int SOCKS5ClientSocket::Read(IOBuffer* buf, int buf_len, diff --git a/net/socket/socks5_client_socket.h b/net/socket/socks5_client_socket.h index fb09c19..09a4f54 100644 --- a/net/socket/socks5_client_socket.h +++ b/net/socket/socks5_client_socket.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -62,6 +62,7 @@ class NET_EXPORT_PRIVATE SOCKS5ClientSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc index f081563..01983d9 100644 --- a/net/socket/socks_client_socket.cc +++ b/net/socket/socks_client_socket.cc @@ -181,6 +181,14 @@ base::TimeDelta SOCKSClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +NextProto SOCKSClientSocket::GetNegotiatedProtocol() const { + if (transport_.get() && transport_->socket()) { + return transport_->socket()->GetNegotiatedProtocol(); + } + NOTREACHED(); + return kProtoUnknown; +} + // Read is called by the transport layer above to read. This can only be done // if the SOCKS handshake is complete. int SOCKSClientSocket::Read(IOBuffer* buf, int buf_len, diff --git a/net/socket/socks_client_socket.h b/net/socket/socks_client_socket.h index fb88cd2..8dfd773 100644 --- a/net/socket/socks_client_socket.h +++ b/net/socket/socks_client_socket.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -59,6 +59,7 @@ class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/socket/ssl_client_socket.cc b/net/socket/ssl_client_socket.cc index d48233a..9f49425 100644 --- a/net/socket/ssl_client_socket.cc +++ b/net/socket/ssl_client_socket.cc @@ -15,6 +15,7 @@ SSLClientSocket::SSLClientSocket() domain_bound_cert_type_(CLIENT_CERT_INVALID_TYPE) { } +// static NextProto SSLClientSocket::NextProtoFromString( const std::string& proto_string) { if (proto_string == "http1.1" || proto_string == "http/1.1") { @@ -32,6 +33,7 @@ NextProto SSLClientSocket::NextProtoFromString( } } +// static const char* SSLClientSocket::NextProtoToString(NextProto next_proto) { switch (next_proto) { case kProtoHTTP11: @@ -79,6 +81,10 @@ std::string SSLClientSocket::ServerProtosToString( return JoinString(server_protos_with_commas, ','); } +NextProto SSLClientSocket::GetNegotiatedProtocol() const { + return protocol_negotiated_; +} + bool SSLClientSocket::IgnoreCertError(int error, int load_flags) { if (error == OK || load_flags & LOAD_IGNORE_ALL_CERT_ERRORS) return true; @@ -114,10 +120,6 @@ bool SSLClientSocket::set_was_spdy_negotiated(bool negotiated) { return was_spdy_negotiated_ = negotiated; } -NextProto SSLClientSocket::protocol_negotiated() const { - return protocol_negotiated_; -} - void SSLClientSocket::set_protocol_negotiated(NextProto protocol_negotiated) { protocol_negotiated_ = protocol_negotiated; } diff --git a/net/socket/ssl_client_socket.h b/net/socket/ssl_client_socket.h index 8f1284d..14cf163 100644 --- a/net/socket/ssl_client_socket.h +++ b/net/socket/ssl_client_socket.h @@ -88,6 +88,9 @@ class NET_EXPORT SSLClientSocket : public SSLSocket { virtual void GetSSLCertRequestInfo( SSLCertRequestInfo* cert_request_info) = 0; + // StreamSocket: + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; + // Get the application level protocol that we negotiated with the server. // *proto is set to the resulting protocol (n.b. that the string may have // embedded NULs). @@ -123,8 +126,6 @@ class NET_EXPORT SSLClientSocket : public SSLSocket { virtual bool set_was_spdy_negotiated(bool negotiated); - virtual NextProto protocol_negotiated() const; - virtual void set_protocol_negotiated(NextProto protocol_negotiated); // Returns the ServerBoundCertService used by this socket, or NULL if diff --git a/net/socket/ssl_server_socket_nss.cc b/net/socket/ssl_server_socket_nss.cc index bb26b9c..9ba0aaa 100644 --- a/net/socket/ssl_server_socket_nss.cc +++ b/net/socket/ssl_server_socket_nss.cc @@ -245,6 +245,11 @@ base::TimeDelta SSLServerSocketNSS::GetConnectTimeMicros() const { return transport_socket_->GetConnectTimeMicros(); } +NextProto SSLServerSocketNSS::GetNegotiatedProtocol() const { + // NPN is not supported by this class. + return kProtoUnknown; +} + int SSLServerSocketNSS::InitializeSSLOptions() { // Transport connected, now hook it up to nss // TODO(port): specify rx and tx buffer sizes separately diff --git a/net/socket/ssl_server_socket_nss.h b/net/socket/ssl_server_socket_nss.h index 1496362..aefb584 100644 --- a/net/socket/ssl_server_socket_nss.h +++ b/net/socket/ssl_server_socket_nss.h @@ -61,6 +61,7 @@ class SSLServerSocketNSS : public SSLServerSocket { virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; private: enum State { diff --git a/net/socket/ssl_server_socket_unittest.cc b/net/socket/ssl_server_socket_unittest.cc index e800cc6..b456b74 100644 --- a/net/socket/ssl_server_socket_unittest.cc +++ b/net/socket/ssl_server_socket_unittest.cc @@ -194,6 +194,10 @@ class FakeSocket : public StreamSocket { return base::TimeDelta::FromMicroseconds(-1); } + virtual NextProto GetNegotiatedProtocol() const { + return kProtoUnknown; + } + private: net::BoundNetLog net_log_; FakeDataChannel* incoming_; diff --git a/net/socket/stream_socket.h b/net/socket/stream_socket.h index d9fee24..4d7b7e2 100644 --- a/net/socket/stream_socket.h +++ b/net/socket/stream_socket.h @@ -87,6 +87,10 @@ class NET_EXPORT_PRIVATE StreamSocket : public Socket { // Returns the connection setup time of this socket. virtual base::TimeDelta GetConnectTimeMicros() const = 0; + // Returns the protocol negotiated via NPN for this socket, or + // kProtoUnknown will be returned if NPN is not applicable. + virtual NextProto GetNegotiatedProtocol() const = 0; + protected: // The following class is only used to gather statistics about the history of // a socket. It is only instantiated and used in basic sockets, such as diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc index 9b47249..b17f52f 100644 --- a/net/socket/tcp_client_socket_libevent.cc +++ b/net/socket/tcp_client_socket_libevent.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -733,4 +733,8 @@ base::TimeDelta TCPClientSocketLibevent::GetConnectTimeMicros() const { return connect_time_micros_; } +NextProto TCPClientSocketLibevent::GetNegotiatedProtocol() const { + return kProtoUnknown; +} + } // namespace net diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h index a6aa241..5519f3c 100644 --- a/net/socket/tcp_client_socket_libevent.h +++ b/net/socket/tcp_client_socket_libevent.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -56,6 +56,7 @@ class NET_EXPORT_PRIVATE TCPClientSocketLibevent : public StreamSocket, virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket implementation. // Multiple outstanding requests are not supported. diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc index 196522d..28b0eef 100644 --- a/net/socket/tcp_client_socket_win.cc +++ b/net/socket/tcp_client_socket_win.cc @@ -674,6 +674,10 @@ base::TimeDelta TCPClientSocketWin::GetConnectTimeMicros() const { return connect_time_micros_; } +NextProto TCPClientSocketWin::GetNegotiatedProtocol() const { + return kProtoUnknown; +} + int TCPClientSocketWin::Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h index 7f681fa..9fffab8 100644 --- a/net/socket/tcp_client_socket_win.h +++ b/net/socket/tcp_client_socket_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -55,6 +55,7 @@ class NET_EXPORT TCPClientSocketWin : public StreamSocket, virtual bool UsingTCPFastOpen() const; virtual int64 NumBytesRead() const; virtual base::TimeDelta GetConnectTimeMicros() const; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket implementation. // Multiple outstanding requests are not supported. diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc index 3aeda50..0b31083 100644 --- a/net/socket/transport_client_socket_pool_unittest.cc +++ b/net/socket/transport_client_socket_pool_unittest.cc @@ -91,6 +91,9 @@ class MockClientSocket : public StreamSocket { virtual base::TimeDelta GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } + virtual NextProto GetNegotiatedProtocol() const { + return kProtoUnknown; + } // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, @@ -145,6 +148,9 @@ class MockFailingClientSocket : public StreamSocket { virtual base::TimeDelta GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } + virtual NextProto GetNegotiatedProtocol() const { + return kProtoUnknown; + } // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, @@ -224,6 +230,9 @@ class MockPendingClientSocket : public StreamSocket { virtual base::TimeDelta GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } + virtual NextProto GetNegotiatedProtocol() const { + return kProtoUnknown; + } // Socket implementation. virtual int Read(IOBuffer* buf, int buf_len, diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc index 182be87..c0ba9d1 100644 --- a/net/spdy/spdy_proxy_client_socket.cc +++ b/net/spdy/spdy_proxy_client_socket.cc @@ -169,6 +169,10 @@ base::TimeDelta SpdyProxyClientSocket::GetConnectTimeMicros() const { return base::TimeDelta::FromMicroseconds(-1); } +NextProto SpdyProxyClientSocket::GetNegotiatedProtocol() const { + return kProtoUnknown; +} + int SpdyProxyClientSocket::Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback) { DCHECK(read_callback_.is_null()); diff --git a/net/spdy/spdy_proxy_client_socket.h b/net/spdy/spdy_proxy_client_socket.h index 45d5937..fe0ca77 100644 --- a/net/spdy/spdy_proxy_client_socket.h +++ b/net/spdy/spdy_proxy_client_socket.h @@ -75,6 +75,7 @@ class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket, virtual bool UsingTCPFastOpen() const OVERRIDE; virtual int64 NumBytesRead() const OVERRIDE; virtual base::TimeDelta GetConnectTimeMicros() const OVERRIDE; + virtual NextProto GetNegotiatedProtocol() const OVERRIDE; // Socket implementation. virtual int Read(IOBuffer* buf, diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index 3815357..203f328 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -438,7 +438,7 @@ net::Error SpdySession::InitializeWithSocket( NextProto protocol = g_default_protocol; if (is_secure_) { SSLClientSocket* ssl_socket = GetSSLClientSocket(); - NextProto protocol_negotiated = ssl_socket->protocol_negotiated(); + NextProto protocol_negotiated = ssl_socket->GetNegotiatedProtocol(); if (protocol_negotiated != kProtoUnknown) { protocol = protocol_negotiated; } @@ -633,7 +633,7 @@ bool SpdySession::NeedsCredentials() const { if (!is_secure_) return false; SSLClientSocket* ssl_socket = GetSSLClientSocket(); - if (ssl_socket->protocol_negotiated() < kProtoSPDY3) + if (ssl_socket->GetNegotiatedProtocol() < kProtoSPDY3) return false; return ssl_socket->WasDomainBoundCertSent(); } @@ -1187,7 +1187,7 @@ Value* SpdySession::GetInfoAsValue() const { NextProto proto = kProtoUnknown; if (is_secure_) { - proto = GetSSLClientSocket()->protocol_negotiated(); + proto = GetSSLClientSocket()->GetNegotiatedProtocol(); } dict->SetString("protocol_negotiated", SSLClientSocket::NextProtoToString(proto)); @@ -1307,7 +1307,7 @@ bool SpdySession::GetSSLInfo(SSLInfo* ssl_info, SSLClientSocket* ssl_socket = GetSSLClientSocket(); ssl_socket->GetSSLInfo(ssl_info); *was_npn_negotiated = ssl_socket->was_npn_negotiated(); - *protocol_negotiated = ssl_socket->protocol_negotiated(); + *protocol_negotiated = ssl_socket->GetNegotiatedProtocol(); return true; } |