summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/http/http_proxy_client_socket.cc8
-rw-r--r--net/http/http_proxy_client_socket.h1
-rw-r--r--net/socket/client_socket.cc6
-rw-r--r--net/socket/client_socket.h9
-rw-r--r--net/socket/client_socket_pool_base.cc21
-rw-r--r--net/socket/client_socket_pool_base.h8
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc11
-rw-r--r--net/socket/socket_test_util.cc21
-rw-r--r--net/socket/socket_test_util.h29
-rw-r--r--net/socket/socks5_client_socket.cc8
-rw-r--r--net/socket/socks5_client_socket.h1
-rw-r--r--net/socket/socks_client_socket.cc8
-rw-r--r--net/socket/socks_client_socket.h1
-rw-r--r--net/socket/ssl_client_socket_mac.cc8
-rw-r--r--net/socket/ssl_client_socket_mac.h1
-rw-r--r--net/socket/ssl_client_socket_nss.cc8
-rw-r--r--net/socket/ssl_client_socket_nss.h1
-rw-r--r--net/socket/ssl_client_socket_win.cc8
-rw-r--r--net/socket/ssl_client_socket_win.h1
-rw-r--r--net/socket/tcp_client_socket_libevent.cc4
-rw-r--r--net/socket/tcp_client_socket_libevent.h1
-rw-r--r--net/socket/tcp_client_socket_pool_unittest.cc3
-rw-r--r--net/socket/tcp_client_socket_win.cc4
-rw-r--r--net/socket/tcp_client_socket_win.h1
24 files changed, 142 insertions, 30 deletions
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index eccd652..7d768d2 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -197,6 +197,14 @@ void HttpProxyClientSocket::SetOmniboxSpeculation() {
}
}
+bool HttpProxyClientSocket::WasEverUsed() const {
+ if (transport_.get() && transport_->socket()) {
+ return transport_->socket()->WasEverUsed();
+ }
+ NOTREACHED();
+ return false;
+}
+
int HttpProxyClientSocket::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(!user_callback_);
diff --git a/net/http/http_proxy_client_socket.h b/net/http/http_proxy_client_socket.h
index adfcc11..4702118 100644
--- a/net/http/http_proxy_client_socket.h
+++ b/net/http/http_proxy_client_socket.h
@@ -72,6 +72,7 @@ class HttpProxyClientSocket : public ClientSocket {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/client_socket.cc b/net/socket/client_socket.cc
index aba0366..0edee70 100644
--- a/net/socket/client_socket.cc
+++ b/net/socket/client_socket.cc
@@ -93,5 +93,9 @@ void ClientSocket::UseHistory::set_omnibox_speculation() {
omnibox_speculation_ = true;
}
-} // namespace net
+bool ClientSocket::UseHistory::was_used_to_convey_data() const {
+ DCHECK(!was_used_to_convey_data_ || was_ever_connected_);
+ return was_used_to_convey_data_;
+}
+} // namespace net
diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h
index 6a4fb31..1a48a11 100644
--- a/net/socket/client_socket.h
+++ b/net/socket/client_socket.h
@@ -58,11 +58,16 @@ class ClientSocket : public Socket {
virtual const BoundNetLog& NetLog() const = 0;
// Set the annotation to indicate this socket was created for speculative
- // reasons. This call is generally fowarded to a basic TCPClientSocket*,
+ // reasons. This call is generally forwarded to a basic TCPClientSocket*,
// where a UseHistory can be updated.
virtual void SetSubresourceSpeculation() = 0;
virtual void SetOmniboxSpeculation() = 0;
+ // Returns true if the underlying transport socket ever had any reads or
+ // writes. ClientSockets layered on top of transport sockets should forward
+ // this call to the transport socket.
+ virtual bool WasEverUsed() 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
@@ -84,6 +89,8 @@ class ClientSocket : public Socket {
void set_subresource_speculation();
void set_omnibox_speculation();
+ bool was_used_to_convey_data() const;
+
private:
// Summarize the statistics for this socket.
void EmitPreconnectionHistograms() const;
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index beb79ae..b982aa0 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -286,8 +286,8 @@ bool ClientSocketPoolBaseHelper::AssignIdleSocketToGroup(
base::TimeDelta idle_time =
base::TimeTicks::Now() - idle_socket.start_time;
HandOutSocket(
- idle_socket.socket, idle_socket.used, request->handle(), idle_time,
- group, request->net_log());
+ idle_socket.socket, idle_socket.socket->WasEverUsed(),
+ request->handle(), idle_time, group, request->net_log());
return true;
}
delete idle_socket.socket;
@@ -447,8 +447,11 @@ bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup(
base::TimeTicks now,
base::TimeDelta timeout) const {
bool timed_out = (now - start_time) >= timeout;
- return timed_out ||
- !(used ? socket->IsConnectedAndIdle() : socket->IsConnected());
+ if (timed_out)
+ return true;
+ if (socket->WasEverUsed())
+ return !socket->IsConnectedAndIdle();
+ return !socket->IsConnected();
}
void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) {
@@ -474,7 +477,8 @@ void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) {
std::deque<IdleSocket>::iterator j = group->mutable_idle_sockets()->begin();
while (j != group->idle_sockets().end()) {
base::TimeDelta timeout =
- j->used ? used_idle_socket_timeout_ : unused_idle_socket_timeout_;
+ j->socket->WasEverUsed() ?
+ used_idle_socket_timeout_ : unused_idle_socket_timeout_;
if (force || j->ShouldCleanup(now, timeout)) {
delete j->socket;
j = group->mutable_idle_sockets()->erase(j);
@@ -553,7 +557,7 @@ void ClientSocketPoolBaseHelper::ReleaseSocket(const std::string& group_name,
id == pool_generation_number_;
if (can_reuse) {
// Add it to the idle list.
- AddIdleSocket(socket, true /* used socket */, group);
+ AddIdleSocket(socket, group);
OnAvailableSocketSlot(group_name, group);
} else {
delete socket;
@@ -651,7 +655,7 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
InvokeUserCallbackLater(r->handle(), r->callback(), result);
} else {
- AddIdleSocket(socket.release(), false /* unused socket */, group);
+ AddIdleSocket(socket.release(), group);
OnAvailableSocketSlot(group_name, group);
CheckForStalledSocketGroups();
}
@@ -771,12 +775,11 @@ void ClientSocketPoolBaseHelper::HandOutSocket(
}
void ClientSocketPoolBaseHelper::AddIdleSocket(
- ClientSocket* socket, bool used, Group* group) {
+ ClientSocket* socket, Group* group) {
DCHECK(socket);
IdleSocket idle_socket;
idle_socket.socket = socket;
idle_socket.start_time = base::TimeTicks::Now();
- idle_socket.used = used;
group->mutable_idle_sockets()->push_back(idle_socket);
IncrementIdleCount();
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index 2540fde..11540b2 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -252,10 +252,9 @@ class ClientSocketPoolBaseHelper
// Entry for a persistent socket which became idle at time |start_time|.
struct IdleSocket {
- IdleSocket() : socket(NULL), used(false) {}
+ IdleSocket() : socket(NULL) {}
ClientSocket* socket;
base::TimeTicks start_time;
- bool used; // Indicates whether or not the socket has been used yet.
// An idle socket should be removed if it can't be reused, or has been idle
// for too long. |now| is the current time value (TimeTicks::Now()).
@@ -396,9 +395,8 @@ class ClientSocketPoolBaseHelper
Group* group,
const BoundNetLog& net_log);
- // Adds |socket| to the list of idle sockets for |group|. |used| indicates
- // whether or not the socket has previously been used.
- void AddIdleSocket(ClientSocket* socket, bool used, Group* group);
+ // Adds |socket| to the list of idle sockets for |group|.
+ void AddIdleSocket(ClientSocket* socket, Group* group);
// Iterates through |group_map_|, canceling all ConnectJobs and deleting
// groups if they are no longer needed.
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 006d4e81..b196168 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -42,7 +42,7 @@ typedef ClientSocketPoolBase<TestSocketParams> TestClientSocketPoolBase;
class MockClientSocket : public ClientSocket {
public:
- MockClientSocket() : connected_(false) {}
+ MockClientSocket() : connected_(false), was_used_to_convey_data_(false) {}
// Socket methods:
virtual int Read(
@@ -51,8 +51,9 @@ class MockClientSocket : public ClientSocket {
}
virtual int Write(
- IOBuffer* /* buf */, int /* len */, CompletionCallback* /* callback */) {
- return ERR_UNEXPECTED;
+ IOBuffer* /* buf */, int len, CompletionCallback* /* callback */) {
+ was_used_to_convey_data_ = true;
+ return len;
}
virtual bool SetReceiveBufferSize(int32 size) { return true; }
virtual bool SetSendBufferSize(int32 size) { return true; }
@@ -78,10 +79,12 @@ class MockClientSocket : public ClientSocket {
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
+ virtual bool WasEverUsed() const { return was_used_to_convey_data_; }
private:
bool connected_;
BoundNetLog net_log_;
+ bool was_used_to_convey_data_;
DISALLOW_COPY_AND_ASSIGN(MockClientSocket);
};
@@ -1669,6 +1672,8 @@ TEST_F(ClientSocketPoolBaseTest, CleanupTimedOutIdleSockets) {
req.handle()->Reset();
EXPECT_EQ(OK, req2.WaitForResult());
+ // Use the socket.
+ EXPECT_EQ(1, req2.handle()->socket()->Write(NULL, 1, NULL));
req2.handle()->Reset();
// We post all of our delayed tasks with a 2ms delay. I.e. they don't
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index bd47f7c..440c790 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -178,7 +178,8 @@ MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
peer_closed_connection_(false),
pending_buf_(NULL),
pending_buf_len_(0),
- pending_callback_(NULL) {
+ pending_callback_(NULL),
+ was_used_to_convey_data_(false) {
DCHECK(data_);
data_->Reset();
}
@@ -248,10 +249,13 @@ int MockTCPClientSocket::Write(net::IOBuffer* buf, int buf_len,
std::string data(buf->data(), buf_len);
net::MockWriteResult write_result = data_->OnWrite(data);
+ was_used_to_convey_data_ = true;
+
if (write_result.async) {
RunCallbackAsync(callback, write_result.result);
return net::ERR_IO_PENDING;
}
+
return write_result.result;
}
@@ -279,6 +283,8 @@ int MockTCPClientSocket::CompleteRead() {
DCHECK(pending_buf_);
DCHECK(pending_buf_len_ > 0);
+ was_used_to_convey_data_ = true;
+
// Save the pending async IO data and reset our |pending_| state.
net::IOBuffer* buf = pending_buf_;
int buf_len = pending_buf_len_;
@@ -323,7 +329,8 @@ DeterministicMockTCPClientSocket::DeterministicMockTCPClientSocket(
read_buf_len_(0),
read_pending_(false),
read_callback_(NULL),
- data_(data) {}
+ data_(data),
+ was_used_to_convey_data_(false) {}
void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {}
@@ -366,6 +373,8 @@ int DeterministicMockTCPClientSocket::Write(
write_pending_ = true;
return net::ERR_IO_PENDING;
}
+
+ was_used_to_convey_data_ = true;
write_pending_ = false;
return write_result.result;
}
@@ -390,10 +399,12 @@ int DeterministicMockTCPClientSocket::Read(
return ERR_IO_PENDING;
}
+ was_used_to_convey_data_ = true;
return CompleteRead();
}
void DeterministicMockTCPClientSocket::CompleteWrite(){
+ was_used_to_convey_data_ = true;
write_pending_ = false;
write_callback_->Run(write_result_);
}
@@ -403,6 +414,8 @@ int DeterministicMockTCPClientSocket::CompleteRead() {
DCHECK_LE(read_data_.data_len, read_buf_len_);
DCHECK(read_buf_);
+ was_used_to_convey_data_ = true;
+
if (read_data_.result == ERR_IO_PENDING)
read_data_ = data_->GetNextRead();
DCHECK_NE(ERR_IO_PENDING, read_data_.result);
@@ -497,6 +510,10 @@ bool MockSSLClientSocket::IsConnected() const {
return transport_->socket()->IsConnected();
}
+bool MockSSLClientSocket::WasEverUsed() const {
+ return transport_->socket()->WasEverUsed();
+}
+
int MockSSLClientSocket::Read(net::IOBuffer* buf, int buf_len,
net::CompletionCallback* callback) {
return transport_->socket()->Read(buf, buf_len, callback);
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index aaa514e..7cc6f84 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -564,6 +564,7 @@ class MockTCPClientSocket : public MockClientSocket {
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const { return IsConnected(); }
+ virtual bool WasEverUsed() const { return was_used_to_convey_data_; }
// Socket methods:
virtual int Read(net::IOBuffer* buf, int buf_len,
@@ -594,6 +595,7 @@ class MockTCPClientSocket : public MockClientSocket {
net::IOBuffer* pending_buf_;
int pending_buf_len_;
net::CompletionCallback* pending_callback_;
+ bool was_used_to_convey_data_;
};
class DeterministicMockTCPClientSocket : public MockClientSocket,
@@ -601,20 +603,26 @@ class DeterministicMockTCPClientSocket : public MockClientSocket,
public:
DeterministicMockTCPClientSocket(net::NetLog* net_log,
net::DeterministicSocketData* data);
- virtual int Write(net::IOBuffer* buf, int buf_len,
- net::CompletionCallback* callback);
- virtual int Read(net::IOBuffer* buf, int buf_len,
- net::CompletionCallback* callback);
- virtual void CompleteWrite();
- virtual int CompleteRead();
- virtual void OnReadComplete(const MockRead& data);
+ // ClientSocket methods:
virtual int Connect(net::CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
virtual bool IsConnectedAndIdle() const { return IsConnected(); }
- bool write_pending() { return write_pending_; }
- bool read_pending() { return read_pending_; }
+ virtual bool WasEverUsed() const { return was_used_to_convey_data_; }
+
+ // Socket methods:
+ virtual int Write(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback);
+ virtual int Read(net::IOBuffer* buf, int buf_len,
+ net::CompletionCallback* callback);
+
+ bool write_pending() const { return write_pending_; }
+ bool read_pending() const { return read_pending_; }
+
+ void CompleteWrite();
+ int CompleteRead();
+ void OnReadComplete(const MockRead& data);
private:
bool write_pending_;
@@ -628,6 +636,7 @@ class DeterministicMockTCPClientSocket : public MockClientSocket,
bool read_pending_;
net::CompletionCallback* read_callback_;
net::DeterministicSocketData* data_;
+ bool was_used_to_convey_data_;
};
class MockSSLClientSocket : public MockClientSocket {
@@ -643,6 +652,7 @@ class MockSSLClientSocket : public MockClientSocket {
virtual int Connect(net::CompletionCallback* callback);
virtual void Disconnect();
virtual bool IsConnected() const;
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(net::IOBuffer* buf, int buf_len,
@@ -666,6 +676,7 @@ class MockSSLClientSocket : public MockClientSocket {
net::SSLSocketDataProvider* data_;
bool is_npn_state_set_;
bool new_npn_value_;
+ bool was_used_to_convey_data_;
};
class TestSocketRequest : public CallbackRunner< Tuple1<int> > {
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
index 0af7b9b..0b8f08f 100644
--- a/net/socket/socks5_client_socket.cc
+++ b/net/socket/socks5_client_socket.cc
@@ -122,6 +122,14 @@ void SOCKS5ClientSocket::SetOmniboxSpeculation() {
}
}
+bool SOCKS5ClientSocket::WasEverUsed() const {
+ if (transport_.get() && transport_->socket()) {
+ return transport_->socket()->WasEverUsed();
+ }
+ NOTREACHED();
+ return false;
+}
+
// 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 63e3e6a..72e27db 100644
--- a/net/socket/socks5_client_socket.h
+++ b/net/socket/socks5_client_socket.h
@@ -58,6 +58,7 @@ class SOCKS5ClientSocket : public ClientSocket {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index c38021f..8e9e675 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -157,6 +157,14 @@ void SOCKSClientSocket::SetOmniboxSpeculation() {
}
}
+bool SOCKSClientSocket::WasEverUsed() const {
+ if (transport_.get() && transport_->socket()) {
+ return transport_->socket()->WasEverUsed();
+ }
+ NOTREACHED();
+ return false;
+}
+
// 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 3ac8f62..e9e9695 100644
--- a/net/socket/socks_client_socket.h
+++ b/net/socket/socks_client_socket.h
@@ -55,6 +55,7 @@ class SOCKSClientSocket : public ClientSocket {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/ssl_client_socket_mac.cc b/net/socket/ssl_client_socket_mac.cc
index 6fdd2e9..284937a 100644
--- a/net/socket/ssl_client_socket_mac.cc
+++ b/net/socket/ssl_client_socket_mac.cc
@@ -607,6 +607,14 @@ void SSLClientSocketMac::SetOmniboxSpeculation() {
}
}
+bool SSLClientSocketMac::WasEverUsed() const {
+ if (transport_.get() && transport_->socket()) {
+ return transport_->socket()->WasEverUsed();
+ }
+ NOTREACHED();
+ return false;
+}
+
int SSLClientSocketMac::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(completed_handshake_);
diff --git a/net/socket/ssl_client_socket_mac.h b/net/socket/ssl_client_socket_mac.h
index 26a270c..05b9735 100644
--- a/net/socket/ssl_client_socket_mac.h
+++ b/net/socket/ssl_client_socket_mac.h
@@ -49,6 +49,7 @@ class SSLClientSocketMac : public SSLClientSocket {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index d69d202..f46bfcc 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -677,6 +677,14 @@ void SSLClientSocketNSS::SetOmniboxSpeculation() {
}
}
+bool SSLClientSocketNSS::WasEverUsed() const {
+ if (transport_.get() && transport_->socket()) {
+ return transport_->socket()->WasEverUsed();
+ }
+ NOTREACHED();
+ return false;
+}
+
int SSLClientSocketNSS::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
EnterFunction(buf_len);
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index dabe5c4..c43b718 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -58,6 +58,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/ssl_client_socket_win.cc b/net/socket/ssl_client_socket_win.cc
index 1bf704c..99c9322 100644
--- a/net/socket/ssl_client_socket_win.cc
+++ b/net/socket/ssl_client_socket_win.cc
@@ -646,6 +646,14 @@ void SSLClientSocketWin::SetOmniboxSpeculation() {
}
}
+bool SSLClientSocketWin::WasEverUsed() const {
+ if (transport_.get() && transport_->socket()) {
+ return transport_->socket()->WasEverUsed();
+ }
+ NOTREACHED();
+ return false;
+}
+
int SSLClientSocketWin::Read(IOBuffer* buf, int buf_len,
CompletionCallback* callback) {
DCHECK(completed_handshake());
diff --git a/net/socket/ssl_client_socket_win.h b/net/socket/ssl_client_socket_win.h
index 44a5374..38cdb32 100644
--- a/net/socket/ssl_client_socket_win.h
+++ b/net/socket/ssl_client_socket_win.h
@@ -53,6 +53,7 @@ class SSLClientSocketWin : public SSLClientSocket {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len, CompletionCallback* callback);
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index a63528b..15c3738 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -541,4 +541,8 @@ void TCPClientSocketLibevent::SetOmniboxSpeculation() {
use_history_.set_subresource_speculation();
}
+bool TCPClientSocketLibevent::WasEverUsed() const {
+ return use_history_.was_used_to_convey_data();
+}
+
} // namespace net
diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h
index 8d68bff..980e4cd 100644
--- a/net/socket/tcp_client_socket_libevent.h
+++ b/net/socket/tcp_client_socket_libevent.h
@@ -42,6 +42,7 @@ class TCPClientSocketLibevent : public ClientSocket, NonThreadSafe {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
// Multiple outstanding requests are not supported.
diff --git a/net/socket/tcp_client_socket_pool_unittest.cc b/net/socket/tcp_client_socket_pool_unittest.cc
index 5bcf7e1..ddcd5bf 100644
--- a/net/socket/tcp_client_socket_pool_unittest.cc
+++ b/net/socket/tcp_client_socket_pool_unittest.cc
@@ -52,6 +52,7 @@ class MockClientSocket : public ClientSocket {
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
+ virtual bool WasEverUsed() const { return false; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -96,6 +97,7 @@ class MockFailingClientSocket : public ClientSocket {
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
+ virtual bool WasEverUsed() const { return false; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
@@ -153,6 +155,7 @@ class MockPendingClientSocket : public ClientSocket {
virtual void SetSubresourceSpeculation() {}
virtual void SetOmniboxSpeculation() {}
+ virtual bool WasEverUsed() const { return false; }
// Socket methods:
virtual int Read(IOBuffer* buf, int buf_len,
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index ed2cccb..1a1f308 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -524,6 +524,10 @@ void TCPClientSocketWin::SetOmniboxSpeculation() {
use_history_.set_subresource_speculation();
}
+bool TCPClientSocketWin::WasEverUsed() const {
+ return use_history_.was_used_to_convey_data();
+}
+
int TCPClientSocketWin::Read(IOBuffer* buf,
int buf_len,
CompletionCallback* callback) {
diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h
index bd31960..be25157 100644
--- a/net/socket/tcp_client_socket_win.h
+++ b/net/socket/tcp_client_socket_win.h
@@ -39,6 +39,7 @@ class TCPClientSocketWin : public ClientSocket, NonThreadSafe {
virtual const BoundNetLog& NetLog() const { return net_log_; }
virtual void SetSubresourceSpeculation();
virtual void SetOmniboxSpeculation();
+ virtual bool WasEverUsed() const;
// Socket methods:
// Multiple outstanding requests are not supported.