Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(590)

Unified Diff: net/socket/ssl_client_socket_nss.cc

Issue 169643006: Use sockets with unread data if they've never been used before. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tweak SpdySession::IsReused (erf, got mixed in with a rebase) Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/socket/ssl_client_socket_nss.cc
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index 598bb7c154bd02dbe32105ba4098c1034fed2957..624550a1a74a4c1117c8a8c774422927b718461c 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -639,6 +639,7 @@ class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> {
bool IsConnected();
bool HasPendingAsyncOperation();
bool HasUnhandledReceivedData();
+ bool WasEverUsed();
// Called on the network task runner.
// Causes the associated SSL/TLS session ID to be added to NSS's session
@@ -840,6 +841,7 @@ class SSLClientSocketNSS::Core : public base::RefCountedThreadSafe<Core> {
bool nss_waiting_read_;
bool nss_waiting_write_;
bool nss_is_closed_;
+ bool was_used_to_convey_data_;
wtc 2014/03/19 00:17:46 Nit: document this member. I copied your comment f
davidben 2014/03/25 19:50:18 Done.
////////////////////////////////////////////////////////////////////////////
// Members that are ONLY accessed on the NSS task runner:
@@ -936,6 +938,7 @@ SSLClientSocketNSS::Core::Core(
nss_waiting_read_(false),
nss_waiting_write_(false),
nss_is_closed_(false),
+ was_used_to_convey_data_(false),
host_and_port_(host_and_port),
ssl_config_(ssl_config),
nss_fd_(NULL),
@@ -1148,8 +1151,11 @@ int SSLClientSocketNSS::Core::Read(IOBuffer* buf, int buf_len,
return ERR_IO_PENDING;
} else {
DCHECK(!nss_waiting_read_);
- if (rv <= 0)
+ if (rv <= 0) {
nss_is_closed_ = true;
+ } else {
+ was_used_to_convey_data_ = true;
+ }
}
}
@@ -1202,8 +1208,11 @@ int SSLClientSocketNSS::Core::Write(IOBuffer* buf, int buf_len,
return ERR_IO_PENDING;
} else {
DCHECK(!nss_waiting_write_);
- if (rv < 0)
+ if (rv < 0) {
nss_is_closed_ = true;
+ } else {
wtc 2014/03/19 00:17:46 We may want to test rv > 0 here because the condit
davidben 2014/03/25 19:50:18 Done.
+ was_used_to_convey_data_ = true;
+ }
}
}
@@ -1225,6 +1234,11 @@ bool SSLClientSocketNSS::Core::HasUnhandledReceivedData() {
return unhandled_buffer_size_ != 0;
}
+bool SSLClientSocketNSS::Core::WasEverUsed() {
+ DCHECK(OnNetworkTaskRunner());
+ return was_used_to_convey_data_;
+}
+
void SSLClientSocketNSS::Core::CacheSessionIfNecessary() {
// TODO(rsleevi): This should occur on the NSS task runner, due to the use of
// nss_fd_. However, it happens on the network task runner in order to match
@@ -2656,16 +2670,22 @@ void SSLClientSocketNSS::Core::DidNSSRead(int result) {
DCHECK(OnNetworkTaskRunner());
DCHECK(nss_waiting_read_);
nss_waiting_read_ = false;
- if (result <= 0)
+ if (result <= 0) {
nss_is_closed_ = true;
+ } else {
+ was_used_to_convey_data_ = true;
+ }
}
void SSLClientSocketNSS::Core::DidNSSWrite(int result) {
DCHECK(OnNetworkTaskRunner());
DCHECK(nss_waiting_write_);
nss_waiting_write_ = false;
- if (result < 0)
+ if (result < 0) {
nss_is_closed_ = true;
+ } else {
wtc 2014/03/19 00:17:46 We may want to test rv > 0 here because the condit
davidben 2014/03/25 19:50:18 Done.
+ was_used_to_convey_data_ = true;
+ }
}
void SSLClientSocketNSS::Core::BufferSendComplete(int result) {
@@ -3025,11 +3045,9 @@ void SSLClientSocketNSS::SetOmniboxSpeculation() {
}
bool SSLClientSocketNSS::WasEverUsed() const {
- if (transport_.get() && transport_->socket()) {
- return transport_->socket()->WasEverUsed();
- }
- NOTREACHED();
- return false;
+ DCHECK(core_.get());
+
+ return core_->WasEverUsed();
}
bool SSLClientSocketNSS::UsingTCPFastOpen() const {

Powered by Google App Engine
This is Rietveld 408576698