Index: net/socket/socket_test_util.h |
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h |
index c8f9b68fe9f8e33953d8b42ee28dc689ae84db9a..e522302e8eb30a8d62ac58e67ace0c224dc55e98 100644 |
--- a/net/socket/socket_test_util.h |
+++ b/net/socket/socket_test_util.h |
@@ -518,6 +518,11 @@ class MockClientSocketFactory : public ClientSocketFactory { |
return mock_data_; |
} |
+ // If |enable_read_if_ready|, ReadIfReady() will be implemented. |
Bence
2017/03/03 16:33:41
"will be implemented" sounds strange, because it i
Bence
2017/03/03 16:33:41
Move this comment to the line above |enable_read_i
xunjieli
2017/03/03 19:41:06
Done.
xunjieli
2017/03/03 19:41:06
Done.
|
+ void set_enable_read_if_ready(bool enable_read_if_ready) { |
+ enable_read_if_ready_ = enable_read_if_ready; |
+ } |
+ |
// ClientSocketFactory |
std::unique_ptr<DatagramClientSocket> CreateDatagramClientSocket( |
DatagramSocket::BindType bind_type, |
@@ -545,6 +550,7 @@ class MockClientSocketFactory : public ClientSocketFactory { |
SocketDataProviderArray<SSLSocketDataProvider> mock_ssl_data_; |
std::vector<uint16_t> udp_client_socket_ports_; |
+ bool enable_read_if_ready_; |
DISALLOW_COPY_AND_ASSIGN(MockClientSocketFactory); |
}; |
@@ -627,6 +633,9 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket { |
int Read(IOBuffer* buf, |
int buf_len, |
const CompletionCallback& callback) override; |
+ int ReadIfReady(IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback) override; |
int Write(IOBuffer* buf, |
int buf_len, |
const CompletionCallback& callback) override; |
@@ -650,9 +659,16 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket { |
void OnConnectComplete(const MockConnect& data) override; |
void OnDataProviderDestroyed() override; |
- private: |
- int CompleteRead(); |
+ // If |enable_read_if_ready|, ReadIfReady() will be implemented. |
Bence
2017/03/03 16:33:41
Same comments as for the identically named method/
xunjieli
2017/03/03 19:41:06
Done.
|
+ void set_enable_read_if_ready(bool enable_read_if_ready) { |
+ enable_read_if_ready_ = enable_read_if_ready; |
+ } |
+ private: |
+ void RetryRead(int rv); |
+ int ReadIfReadyImpl(IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback); |
AddressList addresses_; |
SocketDataProvider* data_; |
@@ -668,10 +684,15 @@ class MockTCPClientSocket : public MockClientSocket, public AsyncSocket { |
// While an asynchronous read is pending, we save our user-buffer state. |
scoped_refptr<IOBuffer> pending_read_buf_; |
int pending_read_buf_len_; |
- CompletionCallback pending_connect_callback_; |
CompletionCallback pending_read_callback_; |
+ |
+ // Non-null when a ReadIfReady() is pending. |
+ CompletionCallback pending_read_if_ready_callback_; |
+ |
+ CompletionCallback pending_connect_callback_; |
CompletionCallback pending_write_callback_; |
bool was_used_to_convey_data_; |
+ bool enable_read_if_ready_; |
ConnectionAttempts connection_attempts_; |
@@ -690,6 +711,9 @@ class MockSSLClientSocket : public MockClientSocket, public AsyncSocket { |
int Read(IOBuffer* buf, |
int buf_len, |
const CompletionCallback& callback) override; |
+ int ReadIfReady(IOBuffer* buf, |
+ int buf_len, |
+ const CompletionCallback& callback) override; |
int Write(IOBuffer* buf, |
int buf_len, |
const CompletionCallback& callback) override; |