summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrch <rch@chromium.org>2015-05-15 11:29:43 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-15 18:29:59 +0000
commit1f1b299125a49be4f4c5a514d3fe4eee13dc904b (patch)
treeb15d96566f49ece0e8903e2dc42c566a1ed29181
parent4fbdae9877d2b4775efa0dffdaa9c16ed6689c75 (diff)
downloadchromium_src-1f1b299125a49be4f4c5a514d3fe4eee13dc904b.zip
chromium_src-1f1b299125a49be4f4c5a514d3fe4eee13dc904b.tar.gz
chromium_src-1f1b299125a49be4f4c5a514d3fe4eee13dc904b.tar.bz2
Add AllReadDataConsumed and AllWriteDataConsumed methods to SocketDataProvider
so that all provider subclasses can have their state verified. Committed: https://crrev.com/bce10d97d6fc5233071427cf622aaad7abde9e19 Cr-Commit-Position: refs/heads/master@{#328154} Committed: https://crrev.com/269875cf0d23881a7ad119bae730ff54fdd4dd0b Cr-Commit-Position: refs/heads/master@{#328351} Committed: https://crrev.com/d833a674a5e4f3b4e47f229b3d5411a8d509c2c0 Cr-Commit-Position: refs/heads/master@{#328909} Committed: https://crrev.com/1d6f67fe72b4a9ae94fcb0a6e051d803a180bde1 Cr-Commit-Position: refs/heads/master@{#329003} Review URL: https://codereview.chromium.org/1114383003 Cr-Commit-Position: refs/heads/master@{#330139}
-rw-r--r--jingle/glue/chrome_async_socket_unittest.cc8
-rw-r--r--net/ftp/ftp_network_transaction_unittest.cc4
-rw-r--r--net/socket/socket_test_util.cc16
-rw-r--r--net/socket/socket_test_util.h6
-rw-r--r--remoting/base/buffered_socket_writer_unittest.cc8
-rw-r--r--remoting/signaling/xmpp_signal_strategy_unittest.cc8
6 files changed, 50 insertions, 0 deletions
diff --git a/jingle/glue/chrome_async_socket_unittest.cc b/jingle/glue/chrome_async_socket_unittest.cc
index 78b07a6..a785553 100644
--- a/jingle/glue/chrome_async_socket_unittest.cc
+++ b/jingle/glue/chrome_async_socket_unittest.cc
@@ -93,6 +93,14 @@ class AsyncSocketDataProvider : public net::SocketDataProvider {
writes_.push_back(mock_write);
}
+ bool AllReadDataConsumed() const override {
+ return reads_.empty();
+ }
+
+ bool AllWriteDataConsumed() const override {
+ return writes_.empty();
+ }
+
private:
std::deque<net::MockRead> reads_;
bool has_pending_read_;
diff --git a/net/ftp/ftp_network_transaction_unittest.cc b/net/ftp/ftp_network_transaction_unittest.cc
index 79e1687..c242658 100644
--- a/net/ftp/ftp_network_transaction_unittest.cc
+++ b/net/ftp/ftp_network_transaction_unittest.cc
@@ -128,6 +128,10 @@ class FtpSocketDataProvider : public DynamicSocketDataProvider {
Init();
}
+ bool AllReadDataConsumed() const override { return state_ == QUIT; }
+
+ bool AllWriteDataConsumed() const override { return state_ == QUIT; }
+
void set_multiline_welcome(bool multiline) { multiline_welcome_ = multiline; }
bool use_epsv() const { return use_epsv_; }
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index c5861faa..92bd1c9 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -248,6 +248,14 @@ void StaticSocketDataProvider::Reset() {
helper_.Reset();
}
+bool StaticSocketDataProvider::AllReadDataConsumed() const {
+ return helper_.at_read_eof();
+}
+
+bool StaticSocketDataProvider::AllWriteDataConsumed() const {
+ return helper_.at_write_eof();
+}
+
DynamicSocketDataProvider::DynamicSocketDataProvider()
: short_read_limit_(0),
allow_unconsumed_reads_(false) {
@@ -600,6 +608,14 @@ void SequencedSocketData::Reset() {
weak_factory_.InvalidateWeakPtrs();
}
+bool SequencedSocketData::AllReadDataConsumed() const {
+ return helper_.at_read_eof();
+}
+
+bool SequencedSocketData::AllWriteDataConsumed() const {
+ return helper_.at_write_eof();
+}
+
bool SequencedSocketData::at_read_eof() const {
return helper_.at_read_eof();
}
diff --git a/net/socket/socket_test_util.h b/net/socket/socket_test_util.h
index b7d090e..f7aaee9 100644
--- a/net/socket/socket_test_util.h
+++ b/net/socket/socket_test_util.h
@@ -198,6 +198,8 @@ class SocketDataProvider {
virtual MockRead OnRead() = 0;
virtual MockWriteResult OnWrite(const std::string& data) = 0;
virtual void Reset() = 0;
+ virtual bool AllReadDataConsumed() const = 0;
+ virtual bool AllWriteDataConsumed() const = 0;
// Accessor for the socket which is using the SocketDataProvider.
AsyncSocket* socket() { return socket_; }
@@ -294,6 +296,8 @@ class StaticSocketDataProvider : public SocketDataProvider {
MockRead OnRead() override;
MockWriteResult OnWrite(const std::string& data) override;
void Reset() override;
+ bool AllReadDataConsumed() const override;
+ bool AllWriteDataConsumed() const override;
size_t read_index() const { return helper_.read_index(); }
size_t write_index() const { return helper_.write_index(); }
@@ -499,6 +503,8 @@ class SequencedSocketData : public SocketDataProvider {
MockRead OnRead() override;
MockWriteResult OnWrite(const std::string& data) override;
void Reset() override;
+ bool AllReadDataConsumed() const override;
+ bool AllWriteDataConsumed() const override;
// Returns true if all data has been read.
bool at_read_eof() const;
diff --git a/remoting/base/buffered_socket_writer_unittest.cc b/remoting/base/buffered_socket_writer_unittest.cc
index 0c74044..07bb2ec 100644
--- a/remoting/base/buffered_socket_writer_unittest.cc
+++ b/remoting/base/buffered_socket_writer_unittest.cc
@@ -45,6 +45,14 @@ class SocketDataProvider: public net::SocketDataProvider {
size);
}
+ bool AllReadDataConsumed() const override {
+ return true;
+ }
+
+ bool AllWriteDataConsumed() const override {
+ return true;
+ }
+
void Reset() override {}
std::string written_data() { return written_data_; }
diff --git a/remoting/signaling/xmpp_signal_strategy_unittest.cc b/remoting/signaling/xmpp_signal_strategy_unittest.cc
index b4c4a53..2193982 100644
--- a/remoting/signaling/xmpp_signal_strategy_unittest.cc
+++ b/remoting/signaling/xmpp_signal_strategy_unittest.cc
@@ -29,6 +29,14 @@ class XmppSocketDataProvider: public net::SocketDataProvider {
void Reset() override {}
+ bool AllReadDataConsumed() const override {
+ return true;
+ }
+
+ bool AllWriteDataConsumed() const override {
+ return true;
+ }
+
void ReceiveData(const std::string& text) {
socket()->OnReadComplete(
net::MockRead(net::ASYNC, text.data(), text.size()));