summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/devtools/device/usb/android_usb_socket.cc6
-rw-r--r--chrome/browser/devtools/device/usb/android_usb_socket.h1
-rw-r--r--chrome/browser/extensions/api/socket/tls_socket_unittest.cc3
-rw-r--r--content/browser/renderer_host/p2p/socket_host_test_utils.cc6
-rw-r--r--content/browser/renderer_host/p2p/socket_host_test_utils.h1
-rw-r--r--jingle/glue/fake_ssl_client_socket.cc5
-rw-r--r--jingle/glue/fake_ssl_client_socket.h3
-rw-r--r--jingle/glue/fake_ssl_client_socket_unittest.cc1
-rw-r--r--jingle/glue/proxy_resolving_client_socket.cc5
-rw-r--r--jingle/glue/proxy_resolving_client_socket.h3
-rw-r--r--net/http/http_proxy_client_socket.cc4
-rw-r--r--net/http/http_proxy_client_socket.h3
-rw-r--r--net/http/http_proxy_client_socket_wrapper.cc4
-rw-r--r--net/http/http_proxy_client_socket_wrapper.h1
-rw-r--r--net/server/http_server_unittest.cc7
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc6
-rw-r--r--net/socket/socket_test_util.cc5
-rw-r--r--net/socket/socket_test_util.h1
-rw-r--r--net/socket/socks5_client_socket.cc4
-rw-r--r--net/socket/socks5_client_socket.h3
-rw-r--r--net/socket/socks_client_socket.cc4
-rw-r--r--net/socket/socks_client_socket.h3
-rw-r--r--net/socket/ssl_client_socket_nss.cc5
-rw-r--r--net/socket/ssl_client_socket_nss.h2
-rw-r--r--net/socket/ssl_client_socket_openssl.cc4
-rw-r--r--net/socket/ssl_client_socket_openssl.h2
-rw-r--r--net/socket/ssl_client_socket_unittest.cc20
-rw-r--r--net/socket/ssl_server_socket_nss.cc6
-rw-r--r--net/socket/ssl_server_socket_nss.h2
-rw-r--r--net/socket/ssl_server_socket_openssl.cc4
-rw-r--r--net/socket/ssl_server_socket_openssl.h3
-rw-r--r--net/socket/ssl_server_socket_unittest.cc7
-rw-r--r--net/socket/stream_socket.h8
-rw-r--r--net/socket/tcp_client_socket.cc33
-rw-r--r--net/socket/tcp_client_socket.h8
-rw-r--r--net/socket/transport_client_socket_pool_test_util.cc14
-rw-r--r--net/socket/unix_domain_client_socket_posix.cc5
-rw-r--r--net/socket/unix_domain_client_socket_posix.h3
-rw-r--r--net/socket/websocket_endpoint_lock_manager_unittest.cc6
-rw-r--r--net/spdy/spdy_proxy_client_socket.cc5
-rw-r--r--net/spdy/spdy_proxy_client_socket.h3
-rw-r--r--net/spdy/spdy_test_util_common.cc8
-rw-r--r--remoting/protocol/ssl_hmac_channel_authenticator.cc4
43 files changed, 225 insertions, 6 deletions
diff --git a/chrome/browser/devtools/device/usb/android_usb_socket.cc b/chrome/browser/devtools/device/usb/android_usb_socket.cc
index 1310f6e..dcca5a2 100644
--- a/chrome/browser/devtools/device/usb/android_usb_socket.cc
+++ b/chrome/browser/devtools/device/usb/android_usb_socket.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/devtools/device/usb/android_usb_socket.h"
#include "base/callback_helpers.h"
+#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "net/base/net_errors.h"
@@ -239,6 +240,11 @@ void AndroidUsbSocket::GetConnectionAttempts(
out->clear();
}
+int64_t AndroidUsbSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
void AndroidUsbSocket::RespondToReader(bool disconnect) {
if (read_callback_.is_null() || (read_buffer_.empty() && !disconnect))
return;
diff --git a/chrome/browser/devtools/device/usb/android_usb_socket.h b/chrome/browser/devtools/device/usb/android_usb_socket.h
index fa22deb..786f404 100644
--- a/chrome/browser/devtools/device/usb/android_usb_socket.h
+++ b/chrome/browser/devtools/device/usb/android_usb_socket.h
@@ -56,6 +56,7 @@ class AndroidUsbSocket : public net::StreamSocket,
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override {
}
+ int64_t GetTotalReceivedBytes() const override;
private:
void RespondToReader(bool disconnect);
diff --git a/chrome/browser/extensions/api/socket/tls_socket_unittest.cc b/chrome/browser/extensions/api/socket/tls_socket_unittest.cc
index 858d06d..801c03d 100644
--- a/chrome/browser/extensions/api/socket/tls_socket_unittest.cc
+++ b/chrome/browser/extensions/api/socket/tls_socket_unittest.cc
@@ -4,6 +4,8 @@
#include "extensions/browser/api/socket/tls_socket.h"
+#include <stdint.h>
+
#include <deque>
#include <utility>
@@ -56,6 +58,7 @@ class MockSSLClientSocket : public net::SSLClientSocket {
MOCK_CONST_METHOD1(GetConnectionAttempts, void(net::ConnectionAttempts*));
MOCK_METHOD0(ClearConnectionAttempts, void());
MOCK_METHOD1(AddConnectionAttempts, void(const net::ConnectionAttempts&));
+ MOCK_CONST_METHOD0(GetTotalReceivedBytes, int64_t());
MOCK_METHOD5(ExportKeyingMaterial,
int(const StringPiece&,
bool,
diff --git a/content/browser/renderer_host/p2p/socket_host_test_utils.cc b/content/browser/renderer_host/p2p/socket_host_test_utils.cc
index cc37c02..1f56903 100644
--- a/content/browser/renderer_host/p2p/socket_host_test_utils.cc
+++ b/content/browser/renderer_host/p2p/socket_host_test_utils.cc
@@ -4,6 +4,7 @@
#include "content/browser/renderer_host/p2p/socket_host_test_utils.h"
+#include "base/logging.h"
#include "base/sys_byteorder.h"
#include "base/thread_task_runner_handle.h"
#include "net/base/completion_callback.h"
@@ -176,6 +177,11 @@ void FakeSocket::GetConnectionAttempts(net::ConnectionAttempts* out) const {
out->clear();
}
+int64_t FakeSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
void CreateRandomPacket(std::vector<char>* packet) {
size_t size = kStunHeaderSize + rand() % 1000;
packet->resize(size);
diff --git a/content/browser/renderer_host/p2p/socket_host_test_utils.h b/content/browser/renderer_host/p2p/socket_host_test_utils.h
index 17172e6f..497b672 100644
--- a/content/browser/renderer_host/p2p/socket_host_test_utils.h
+++ b/content/browser/renderer_host/p2p/socket_host_test_utils.h
@@ -67,6 +67,7 @@ class FakeSocket : public net::StreamSocket {
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override {
}
+ int64_t GetTotalReceivedBytes() const override;
private:
void DoAsyncWrite(scoped_refptr<net::IOBuffer> buf, int buf_len,
diff --git a/jingle/glue/fake_ssl_client_socket.cc b/jingle/glue/fake_ssl_client_socket.cc
index 657bd76..58f1164 100644
--- a/jingle/glue/fake_ssl_client_socket.cc
+++ b/jingle/glue/fake_ssl_client_socket.cc
@@ -349,4 +349,9 @@ void FakeSSLClientSocket::GetConnectionAttempts(
out->clear();
}
+int64_t FakeSSLClientSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
} // namespace jingle_glue
diff --git a/jingle/glue/fake_ssl_client_socket.h b/jingle/glue/fake_ssl_client_socket.h
index 8f90429..c6a41c2 100644
--- a/jingle/glue/fake_ssl_client_socket.h
+++ b/jingle/glue/fake_ssl_client_socket.h
@@ -16,6 +16,8 @@
#ifndef JINGLE_GLUE_FAKE_SSL_CLIENT_SOCKET_H_
#define JINGLE_GLUE_FAKE_SSL_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include <cstddef>
#include "base/basictypes.h"
@@ -71,6 +73,7 @@ class FakeSSLClientSocket : public net::StreamSocket {
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override {
}
+ int64_t GetTotalReceivedBytes() const override;
private:
enum HandshakeState {
diff --git a/jingle/glue/fake_ssl_client_socket_unittest.cc b/jingle/glue/fake_ssl_client_socket_unittest.cc
index 0f81127..4d7165d 100644
--- a/jingle/glue/fake_ssl_client_socket_unittest.cc
+++ b/jingle/glue/fake_ssl_client_socket_unittest.cc
@@ -71,6 +71,7 @@ class MockClientSocket : public net::StreamSocket {
MOCK_CONST_METHOD1(GetConnectionAttempts, void(net::ConnectionAttempts*));
MOCK_METHOD0(ClearConnectionAttempts, void());
MOCK_METHOD1(AddConnectionAttempts, void(const net::ConnectionAttempts&));
+ MOCK_CONST_METHOD0(GetTotalReceivedBytes, int64_t());
};
// Break up |data| into a bunch of chunked MockReads/Writes and push
diff --git a/jingle/glue/proxy_resolving_client_socket.cc b/jingle/glue/proxy_resolving_client_socket.cc
index e71f362..dc5608b 100644
--- a/jingle/glue/proxy_resolving_client_socket.cc
+++ b/jingle/glue/proxy_resolving_client_socket.cc
@@ -425,6 +425,11 @@ void ProxyResolvingClientSocket::GetConnectionAttempts(
out->clear();
}
+int64_t ProxyResolvingClientSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
void ProxyResolvingClientSocket::CloseTransportSocket() {
if (transport_.get() && transport_->socket())
transport_->socket()->Disconnect();
diff --git a/jingle/glue/proxy_resolving_client_socket.h b/jingle/glue/proxy_resolving_client_socket.h
index 14c8e24..7d76778 100644
--- a/jingle/glue/proxy_resolving_client_socket.h
+++ b/jingle/glue/proxy_resolving_client_socket.h
@@ -8,6 +8,8 @@
#ifndef JINGLE_GLUE_PROXY_RESOLVING_CLIENT_SOCKET_H_
#define JINGLE_GLUE_PROXY_RESOLVING_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
@@ -74,6 +76,7 @@ class ProxyResolvingClientSocket : public net::StreamSocket {
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override {
}
+ int64_t GetTotalReceivedBytes() const override;
private:
// Proxy resolution and connection functions.
diff --git a/net/http/http_proxy_client_socket.cc b/net/http/http_proxy_client_socket.cc
index f188333..ddcd2a4 100644
--- a/net/http/http_proxy_client_socket.cc
+++ b/net/http/http_proxy_client_socket.cc
@@ -212,6 +212,10 @@ void HttpProxyClientSocket::GetConnectionAttempts(
out->clear();
}
+int64_t HttpProxyClientSocket::GetTotalReceivedBytes() const {
+ return transport_->socket()->GetTotalReceivedBytes();
+}
+
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 f154a88..42e21b8 100644
--- a/net/http/http_proxy_client_socket.h
+++ b/net/http/http_proxy_client_socket.h
@@ -5,6 +5,8 @@
#ifndef NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
#define NET_HTTP_HTTP_PROXY_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include <string>
#include "base/basictypes.h"
@@ -73,6 +75,7 @@ class HttpProxyClientSocket : public ProxyClientSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/http/http_proxy_client_socket_wrapper.cc b/net/http/http_proxy_client_socket_wrapper.cc
index 40acc5c..d69ed34 100644
--- a/net/http/http_proxy_client_socket_wrapper.cc
+++ b/net/http/http_proxy_client_socket_wrapper.cc
@@ -274,6 +274,10 @@ void HttpProxyClientSocketWrapper::AddConnectionAttempts(
transport_socket_->AddConnectionAttempts(attempts);
}
+int64_t HttpProxyClientSocketWrapper::GetTotalReceivedBytes() const {
+ return transport_socket_->GetTotalReceivedBytes();
+}
+
int HttpProxyClientSocketWrapper::Read(IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) {
diff --git a/net/http/http_proxy_client_socket_wrapper.h b/net/http/http_proxy_client_socket_wrapper.h
index b3bfa29..f8010e6 100644
--- a/net/http/http_proxy_client_socket_wrapper.h
+++ b/net/http/http_proxy_client_socket_wrapper.h
@@ -101,6 +101,7 @@ class HttpProxyClientSocketWrapper : public ProxyClientSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override;
void AddConnectionAttempts(const ConnectionAttempts& attempts) override;
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/server/http_server_unittest.cc b/net/server/http_server_unittest.cc
index 170a720..98571fb 100644
--- a/net/server/http_server_unittest.cc
+++ b/net/server/http_server_unittest.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <stdint.h>
+
#include <algorithm>
#include <utility>
#include <vector>
@@ -12,6 +14,7 @@
#include "base/compiler_specific.h"
#include "base/format_macros.h"
#include "base/location.h"
+#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
@@ -503,6 +506,10 @@ class MockStreamSocket : public StreamSocket {
}
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
// Socket
int Read(IOBuffer* buf,
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index 7c42ee1..6b58813 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -4,6 +4,8 @@
#include "net/socket/client_socket_pool_base.h"
+#include <stdint.h>
+
#include <vector>
#include "base/bind.h"
@@ -186,6 +188,10 @@ class MockClientSocket : public StreamSocket {
}
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
private:
bool connected_;
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 19a6722..36bbeca 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -869,6 +869,11 @@ void MockClientSocket::GetConnectionAttempts(ConnectionAttempts* out) const {
out->clear();
}
+int64_t MockClientSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
void MockClientSocket::GetSSLCertRequestInfo(
SSLCertRequestInfo* cert_request_info) {
}
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index b576df1..92089b1 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -649,6 +649,7 @@ class MockClientSocket : public SSLClientSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// SSLClientSocket implementation.
void GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info) override;
diff --git a/net/socket/socks5_client_socket.cc b/net/socket/socks5_client_socket.cc
index 4ac9ca5..3c07cda9 100644
--- a/net/socket/socks5_client_socket.cc
+++ b/net/socket/socks5_client_socket.cc
@@ -150,6 +150,10 @@ void SOCKS5ClientSocket::GetConnectionAttempts(ConnectionAttempts* out) const {
out->clear();
}
+int64_t SOCKS5ClientSocket::GetTotalReceivedBytes() const {
+ return transport_->socket()->GetTotalReceivedBytes();
+}
+
// 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 bd9b5b4..643241f 100644
--- a/net/socket/socks5_client_socket.h
+++ b/net/socket/socks5_client_socket.h
@@ -5,6 +5,8 @@
#ifndef NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_
#define NET_SOCKET_SOCKS5_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include <string>
#include "base/basictypes.h"
@@ -57,6 +59,7 @@ class NET_EXPORT_PRIVATE SOCKS5ClientSocket : public StreamSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/socket/socks_client_socket.cc b/net/socket/socks_client_socket.cc
index dbdc0251..fab0920 100644
--- a/net/socket/socks_client_socket.cc
+++ b/net/socket/socks_client_socket.cc
@@ -178,6 +178,10 @@ void SOCKSClientSocket::GetConnectionAttempts(ConnectionAttempts* out) const {
out->clear();
}
+int64_t SOCKSClientSocket::GetTotalReceivedBytes() const {
+ return transport_->socket()->GetTotalReceivedBytes();
+}
+
// 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 ee2918a..4360e2d 100644
--- a/net/socket/socks_client_socket.h
+++ b/net/socket/socks_client_socket.h
@@ -5,6 +5,8 @@
#ifndef NET_SOCKET_SOCKS_CLIENT_SOCKET_H_
#define NET_SOCKET_SOCKS_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include <string>
#include "base/basictypes.h"
@@ -55,6 +57,7 @@ class NET_EXPORT_PRIVATE SOCKSClientSocket : public StreamSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/socket/ssl_client_socket_nss.cc b/net/socket/ssl_client_socket_nss.cc
index 6d9760f..9f3aff6 100644
--- a/net/socket/ssl_client_socket_nss.cc
+++ b/net/socket/ssl_client_socket_nss.cc
@@ -2448,6 +2448,11 @@ void SSLClientSocketNSS::GetConnectionAttempts(ConnectionAttempts* out) const {
out->clear();
}
+int64_t SSLClientSocketNSS::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
void SSLClientSocketNSS::GetSSLCertRequestInfo(
SSLCertRequestInfo* cert_request_info) {
EnterFunction("");
diff --git a/net/socket/ssl_client_socket_nss.h b/net/socket/ssl_client_socket_nss.h
index 12483c3..c2393e2 100644
--- a/net/socket/ssl_client_socket_nss.h
+++ b/net/socket/ssl_client_socket_nss.h
@@ -9,6 +9,7 @@
#include <keyt.h>
#include <nspr.h>
#include <nss.h>
+#include <stdint.h>
#include <string>
#include <vector>
@@ -84,6 +85,7 @@ class SSLClientSocketNSS : public SSLClientSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc
index 9c208d3..92bf8f0 100644
--- a/net/socket/ssl_client_socket_openssl.cc
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -743,6 +743,10 @@ void SSLClientSocketOpenSSL::GetConnectionAttempts(
out->clear();
}
+int64_t SSLClientSocketOpenSSL::GetTotalReceivedBytes() const {
+ return transport_->socket()->GetTotalReceivedBytes();
+}
+
int SSLClientSocketOpenSSL::Read(IOBuffer* buf,
int buf_len,
const CompletionCallback& callback) {
diff --git a/net/socket/ssl_client_socket_openssl.h b/net/socket/ssl_client_socket_openssl.h
index 228214b..33ea40a 100644
--- a/net/socket/ssl_client_socket_openssl.h
+++ b/net/socket/ssl_client_socket_openssl.h
@@ -7,6 +7,7 @@
#include <openssl/base.h>
#include <openssl/ssl.h>
+#include <stdint.h>
#include <string>
#include <vector>
@@ -83,6 +84,7 @@ class SSLClientSocketOpenSSL : public SSLClientSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/socket/ssl_client_socket_unittest.cc b/net/socket/ssl_client_socket_unittest.cc
index d151cfb..324029f 100644
--- a/net/socket/ssl_client_socket_unittest.cc
+++ b/net/socket/ssl_client_socket_unittest.cc
@@ -104,6 +104,9 @@ class WrappedStreamSocket : public StreamSocket {
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {
transport_->AddConnectionAttempts(attempts);
}
+ int64_t GetTotalReceivedBytes() const override {
+ return transport_->GetTotalReceivedBytes();
+ }
// Socket implementation:
int Read(IOBuffer* buf,
@@ -1213,6 +1216,8 @@ TEST_F(SSLClientSocketTest, Read) {
TestCompletionCallback callback;
scoped_ptr<StreamSocket> transport(
new TCPClientSocket(addr, NULL, NetLog::Source()));
+ DCHECK_EQ(0, transport->GetTotalReceivedBytes());
+
int rv = transport->Connect(callback.callback());
if (rv == ERR_IO_PENDING)
rv = callback.WaitForResult();
@@ -1220,6 +1225,7 @@ TEST_F(SSLClientSocketTest, Read) {
scoped_ptr<SSLClientSocket> sock(CreateSSLClientSocket(
transport.Pass(), test_server.host_port_pair(), SSLConfig()));
+ DCHECK_EQ(0, sock->GetTotalReceivedBytes());
rv = sock->Connect(callback.callback());
if (rv == ERR_IO_PENDING)
@@ -1227,6 +1233,10 @@ TEST_F(SSLClientSocketTest, Read) {
EXPECT_EQ(OK, rv);
EXPECT_TRUE(sock->IsConnected());
+ // Number of network bytes received should increase because of SSL socket
+ // establishment.
+ DCHECK_GT(sock->GetTotalReceivedBytes(), 0);
+
const char request_text[] = "GET / HTTP/1.0\r\n\r\n";
scoped_refptr<IOBuffer> request_buffer(
new IOBuffer(arraysize(request_text) - 1));
@@ -1241,6 +1251,8 @@ TEST_F(SSLClientSocketTest, Read) {
EXPECT_EQ(static_cast<int>(arraysize(request_text) - 1), rv);
scoped_refptr<IOBuffer> buf(new IOBuffer(4096));
+ int64_t unencrypted_bytes_read = 0;
+ int64_t network_bytes_read_during_handshake = sock->GetTotalReceivedBytes();
for (;;) {
rv = sock->Read(buf.get(), 4096, callback.callback());
EXPECT_TRUE(rv >= 0 || rv == ERR_IO_PENDING);
@@ -1251,7 +1263,15 @@ TEST_F(SSLClientSocketTest, Read) {
EXPECT_GE(rv, 0);
if (rv <= 0)
break;
+ unencrypted_bytes_read += rv;
}
+ DCHECK_GT(unencrypted_bytes_read, 0);
+ // Reading the payload should increase the number of bytes on network layer.
+ DCHECK_GT(sock->GetTotalReceivedBytes(), network_bytes_read_during_handshake);
+ // Number of bytes received on the network after the handshake should be
+ // higher than the number of encrypted bytes read.
+ DCHECK_GE(sock->GetTotalReceivedBytes() - network_bytes_read_during_handshake,
+ unencrypted_bytes_read);
// The peer should have cleanly closed the connection with a close_notify.
EXPECT_EQ(0, rv);
diff --git a/net/socket/ssl_server_socket_nss.cc b/net/socket/ssl_server_socket_nss.cc
index 614265e..9bcf8ee 100644
--- a/net/socket/ssl_server_socket_nss.cc
+++ b/net/socket/ssl_server_socket_nss.cc
@@ -31,6 +31,7 @@
#include "base/callback_helpers.h"
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "crypto/nss_util_internal.h"
#include "crypto/rsa_private_key.h"
@@ -311,6 +312,11 @@ void SSLServerSocketNSS::GetConnectionAttempts(ConnectionAttempts* out) const {
out->clear();
}
+int64_t SSLServerSocketNSS::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
int SSLServerSocketNSS::InitializeSSLOptions() {
// Transport connected, now hook it up to nss
nss_fd_ = memio_CreateIOLayer(kRecvBufferSize, kSendBufferSize);
diff --git a/net/socket/ssl_server_socket_nss.h b/net/socket/ssl_server_socket_nss.h
index d1bcec6..e30811b 100644
--- a/net/socket/ssl_server_socket_nss.h
+++ b/net/socket/ssl_server_socket_nss.h
@@ -9,6 +9,7 @@
#include <keyt.h>
#include <nspr.h>
#include <nss.h>
+#include <stdint.h>
#include "base/memory/scoped_ptr.h"
#include "net/base/completion_callback.h"
@@ -69,6 +70,7 @@ class SSLServerSocketNSS : public SSLServerSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
private:
enum State {
diff --git a/net/socket/ssl_server_socket_openssl.cc b/net/socket/ssl_server_socket_openssl.cc
index e8cbf5b..3fd749a 100644
--- a/net/socket/ssl_server_socket_openssl.cc
+++ b/net/socket/ssl_server_socket_openssl.cc
@@ -253,6 +253,10 @@ void SSLServerSocketOpenSSL::GetConnectionAttempts(
out->clear();
}
+int64_t SSLServerSocketOpenSSL::GetTotalReceivedBytes() const {
+ return transport_socket_->GetTotalReceivedBytes();
+}
+
void SSLServerSocketOpenSSL::OnSendComplete(int result) {
if (next_handshake_state_ == STATE_HANDSHAKE) {
// In handshake phase.
diff --git a/net/socket/ssl_server_socket_openssl.h b/net/socket/ssl_server_socket_openssl.h
index 34e8bb0..a073e7e 100644
--- a/net/socket/ssl_server_socket_openssl.h
+++ b/net/socket/ssl_server_socket_openssl.h
@@ -5,6 +5,8 @@
#ifndef NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_
#define NET_SOCKET_SSL_SERVER_SOCKET_OPENSSL_H_
+#include <stdint.h>
+
#include "base/memory/scoped_ptr.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
@@ -71,6 +73,7 @@ class SSLServerSocketOpenSSL : public SSLServerSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
private:
enum State {
diff --git a/net/socket/ssl_server_socket_unittest.cc b/net/socket/ssl_server_socket_unittest.cc
index 6bc52b1..03ff361 100644
--- a/net/socket/ssl_server_socket_unittest.cc
+++ b/net/socket/ssl_server_socket_unittest.cc
@@ -15,6 +15,7 @@
#include "net/socket/ssl_server_socket.h"
+#include <stdint.h>
#include <stdlib.h>
#include <queue>
@@ -23,6 +24,7 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/location.h"
+#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/thread_task_runner_handle.h"
@@ -239,6 +241,11 @@ class FakeSocket : public StreamSocket {
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
+
private:
BoundNetLog net_log_;
FakeDataChannel* incoming_;
diff --git a/net/socket/stream_socket.h b/net/socket/stream_socket.h
index 5669ea3..ebd43e1 100644
--- a/net/socket/stream_socket.h
+++ b/net/socket/stream_socket.h
@@ -5,6 +5,8 @@
#ifndef NET_SOCKET_STREAM_SOCKET_H_
#define NET_SOCKET_STREAM_SOCKET_H_
+#include <stdint.h>
+
#include "net/log/net_log.h"
#include "net/socket/connection_attempts.h"
#include "net/socket/next_proto.h"
@@ -106,6 +108,12 @@ class NET_EXPORT_PRIVATE StreamSocket : public Socket {
// Adds |attempts| to the socket's list of connection attempts.
virtual void AddConnectionAttempts(const ConnectionAttempts& attempts) = 0;
+ // Returns the total number of number bytes read by the socket. This only
+ // counts the payload bytes. Transport headers are not counted. Returns
+ // 0 if the socket does not implement the function. The count is reset when
+ // Disconnect() is called.
+ virtual int64_t GetTotalReceivedBytes() 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.cc b/net/socket/tcp_client_socket.cc
index 78b24de..d0a5700 100644
--- a/net/socket/tcp_client_socket.cc
+++ b/net/socket/tcp_client_socket.cc
@@ -23,8 +23,8 @@ TCPClientSocket::TCPClientSocket(const AddressList& addresses,
addresses_(addresses),
current_address_index_(-1),
next_connect_state_(CONNECT_STATE_NONE),
- previously_disconnected_(false) {
-}
+ previously_disconnected_(false),
+ total_received_bytes_(0) {}
TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket,
const IPEndPoint& peer_address)
@@ -32,7 +32,8 @@ TCPClientSocket::TCPClientSocket(scoped_ptr<TCPSocket> connected_socket,
addresses_(AddressList(peer_address)),
current_address_index_(0),
next_connect_state_(CONNECT_STATE_NONE),
- previously_disconnected_(false) {
+ previously_disconnected_(false),
+ total_received_bytes_(0) {
DCHECK(socket_);
socket_->SetDefaultOptionsForClient();
@@ -187,6 +188,7 @@ void TCPClientSocket::Disconnect() {
}
void TCPClientSocket::DoDisconnect() {
+ total_received_bytes_ = 0;
EmitTCPMetricsHistogramsOnDisconnect();
// If connecting or already connected, record that the socket has been
// disconnected.
@@ -264,10 +266,12 @@ int TCPClientSocket::Read(IOBuffer* buf,
// |socket_| is owned by this class and the callback won't be run once
// |socket_| is gone. Therefore, it is safe to use base::Unretained() here.
CompletionCallback read_callback = base::Bind(
- &TCPClientSocket::DidCompleteReadWrite, base::Unretained(this), callback);
+ &TCPClientSocket::DidCompleteRead, base::Unretained(this), callback);
int result = socket_->Read(buf, buf_len, read_callback);
- if (result > 0)
+ if (result > 0) {
use_history_.set_was_used_to_convey_data();
+ total_received_bytes_ += result;
+ }
return result;
}
@@ -280,7 +284,7 @@ int TCPClientSocket::Write(IOBuffer* buf,
// |socket_| is owned by this class and the callback won't be run once
// |socket_| is gone. Therefore, it is safe to use base::Unretained() here.
CompletionCallback write_callback = base::Bind(
- &TCPClientSocket::DidCompleteReadWrite, base::Unretained(this), callback);
+ &TCPClientSocket::DidCompleteWrite, base::Unretained(this), callback);
int result = socket_->Write(buf, buf_len, write_callback);
if (result > 0)
use_history_.set_was_used_to_convey_data();
@@ -318,6 +322,10 @@ void TCPClientSocket::AddConnectionAttempts(
attempts.end());
}
+int64_t TCPClientSocket::GetTotalReceivedBytes() const {
+ return total_received_bytes_;
+}
+
void TCPClientSocket::DidCompleteConnect(int result) {
DCHECK_EQ(next_connect_state_, CONNECT_STATE_CONNECT_COMPLETE);
DCHECK_NE(result, ERR_IO_PENDING);
@@ -330,6 +338,19 @@ void TCPClientSocket::DidCompleteConnect(int result) {
}
}
+void TCPClientSocket::DidCompleteRead(const CompletionCallback& callback,
+ int result) {
+ if (result > 0)
+ total_received_bytes_ += result;
+
+ DidCompleteReadWrite(callback, result);
+}
+
+void TCPClientSocket::DidCompleteWrite(const CompletionCallback& callback,
+ int result) {
+ DidCompleteReadWrite(callback, result);
+}
+
void TCPClientSocket::DidCompleteReadWrite(const CompletionCallback& callback,
int result) {
if (result > 0)
diff --git a/net/socket/tcp_client_socket.h b/net/socket/tcp_client_socket.h
index 064b5eb..8872cb8 100644
--- a/net/socket/tcp_client_socket.h
+++ b/net/socket/tcp_client_socket.h
@@ -5,6 +5,8 @@
#ifndef NET_SOCKET_TCP_CLIENT_SOCKET_H_
#define NET_SOCKET_TCP_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -73,6 +75,7 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override;
void AddConnectionAttempts(const ConnectionAttempts& attempts) override;
+ int64_t GetTotalReceivedBytes() const override;
private:
// State machine for connecting the socket.
@@ -92,6 +95,8 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
void DoDisconnect();
void DidCompleteConnect(int result);
+ void DidCompleteRead(const CompletionCallback& callback, int result);
+ void DidCompleteWrite(const CompletionCallback& callback, int result);
void DidCompleteReadWrite(const CompletionCallback& callback, int result);
int OpenSocket(AddressFamily family);
@@ -128,6 +133,9 @@ class NET_EXPORT TCPClientSocket : public StreamSocket {
// Failed connection attempts made while trying to connect this socket.
ConnectionAttempts connection_attempts_;
+ // Total number of bytes received by the socket.
+ int64_t total_received_bytes_;
+
DISALLOW_COPY_AND_ASSIGN(TCPClientSocket);
};
diff --git a/net/socket/transport_client_socket_pool_test_util.cc b/net/socket/transport_client_socket_pool_test_util.cc
index c13ffdd..5e5f074 100644
--- a/net/socket/transport_client_socket_pool_test_util.cc
+++ b/net/socket/transport_client_socket_pool_test_util.cc
@@ -4,6 +4,8 @@
#include "net/socket/transport_client_socket_pool_test_util.h"
+#include <stdint.h>
+
#include <string>
#include "base/location.h"
@@ -77,6 +79,10 @@ class MockConnectClientSocket : public StreamSocket {
}
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
// Socket implementation.
int Read(IOBuffer* buf,
@@ -140,6 +146,10 @@ class MockFailingClientSocket : public StreamSocket {
}
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
// Socket implementation.
int Read(IOBuffer* buf,
@@ -266,6 +276,10 @@ class MockTriggerableClientSocket : public StreamSocket {
connection_attempts_.insert(connection_attempts_.begin(), attempts.begin(),
attempts.end());
}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/socket/unix_domain_client_socket_posix.cc b/net/socket/unix_domain_client_socket_posix.cc
index 5e55a92..d8cbfaf 100644
--- a/net/socket/unix_domain_client_socket_posix.cc
+++ b/net/socket/unix_domain_client_socket_posix.cc
@@ -152,6 +152,11 @@ void UnixDomainClientSocket::GetConnectionAttempts(
out->clear();
}
+int64_t UnixDomainClientSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
int UnixDomainClientSocket::Read(IOBuffer* buf, int buf_len,
const CompletionCallback& callback) {
DCHECK(socket_);
diff --git a/net/socket/unix_domain_client_socket_posix.h b/net/socket/unix_domain_client_socket_posix.h
index 4e2c17d..b978e13 100644
--- a/net/socket/unix_domain_client_socket_posix.h
+++ b/net/socket/unix_domain_client_socket_posix.h
@@ -5,6 +5,8 @@
#ifndef NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_
#define NET_SOCKET_UNIX_DOMAIN_CLIENT_SOCKET_POSIX_H_
+#include <stdint.h>
+
#include <string>
#include "base/basictypes.h"
@@ -58,6 +60,7 @@ class NET_EXPORT UnixDomainClientSocket : public StreamSocket {
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/socket/websocket_endpoint_lock_manager_unittest.cc b/net/socket/websocket_endpoint_lock_manager_unittest.cc
index 29fc067..20127bf 100644
--- a/net/socket/websocket_endpoint_lock_manager_unittest.cc
+++ b/net/socket/websocket_endpoint_lock_manager_unittest.cc
@@ -4,6 +4,7 @@
#include "net/socket/websocket_endpoint_lock_manager.h"
+#include "base/logging.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
#include "base/time/time.h"
@@ -62,6 +63,11 @@ class FakeStreamSocket : public StreamSocket {
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
+
// Socket implementation
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 6c28026..9f0d594 100644
--- a/net/spdy/spdy_proxy_client_socket.cc
+++ b/net/spdy/spdy_proxy_client_socket.cc
@@ -194,6 +194,11 @@ void SpdyProxyClientSocket::GetConnectionAttempts(
out->clear();
}
+int64_t SpdyProxyClientSocket::GetTotalReceivedBytes() const {
+ NOTIMPLEMENTED();
+ return 0;
+}
+
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 c3dd2a3..df9c21c 100644
--- a/net/spdy/spdy_proxy_client_socket.h
+++ b/net/spdy/spdy_proxy_client_socket.h
@@ -5,6 +5,8 @@
#ifndef NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_
#define NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_
+#include <stdint.h>
+
#include <list>
#include <string>
@@ -74,6 +76,7 @@ class NET_EXPORT_PRIVATE SpdyProxyClientSocket : public ProxyClientSocket,
void GetConnectionAttempts(ConnectionAttempts* out) const override;
void ClearConnectionAttempts() override {}
void AddConnectionAttempts(const ConnectionAttempts& attempts) override {}
+ int64_t GetTotalReceivedBytes() const override;
// Socket implementation.
int Read(IOBuffer* buf,
diff --git a/net/spdy/spdy_test_util_common.cc b/net/spdy/spdy_test_util_common.cc
index 9fbbdbf..186a02b 100644
--- a/net/spdy/spdy_test_util_common.cc
+++ b/net/spdy/spdy_test_util_common.cc
@@ -4,9 +4,12 @@
#include "net/spdy/spdy_test_util_common.h"
+#include <stdint.h>
+
#include <cstddef>
#include "base/compiler_specific.h"
+#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
@@ -661,6 +664,11 @@ class FakeSpdySessionClientSocket : public MockClientSocket {
return false;
}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
+
private:
int read_result_;
};
diff --git a/remoting/protocol/ssl_hmac_channel_authenticator.cc b/remoting/protocol/ssl_hmac_channel_authenticator.cc
index 367b95b..e994e29 100644
--- a/remoting/protocol/ssl_hmac_channel_authenticator.cc
+++ b/remoting/protocol/ssl_hmac_channel_authenticator.cc
@@ -132,6 +132,10 @@ class NetStreamSocketAdapter : public net::StreamSocket {
void AddConnectionAttempts(const net::ConnectionAttempts& attempts) override {
NOTREACHED();
}
+ int64_t GetTotalReceivedBytes() const override {
+ NOTIMPLEMENTED();
+ return 0;
+ }
private:
scoped_ptr<P2PStreamSocket> socket_;