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

Unified Diff: net/socket/socket_test_util.cc

Issue 2411033003: Drop buffers in idle SSLClientSockets (and SSLServerSockets). (Closed)
Patch Set: rsleevi comments Created 4 years, 2 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
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/ssl_client_socket_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/socket_test_util.cc
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 15c26f8c028cf0bbfe7faabed5c2ac480fae0108..ef21477adc6b9e7f54b0cdc032f16d34ef74427c 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -201,10 +201,16 @@ const MockWrite& StaticSocketDataHelper::AdvanceWrite() {
return writes_[write_index_++];
}
+void StaticSocketDataHelper::Reset() {
+ read_index_ = 0;
+ write_index_ = 0;
+}
+
bool StaticSocketDataHelper::VerifyWriteData(const std::string& data) {
CHECK(!AllWriteDataConsumed());
- // Check that what the actual data matches the expectations.
- const MockWrite& next_write = PeekWrite();
+ // Check that the actual data matches the expectations, skipping over any
+ // pause events.
+ const MockWrite& next_write = PeekRealWrite();
if (!next_write.data)
return true;
@@ -221,9 +227,14 @@ bool StaticSocketDataHelper::VerifyWriteData(const std::string& data) {
return expected_data == actual_data;
}
-void StaticSocketDataHelper::Reset() {
- read_index_ = 0;
- write_index_ = 0;
+const MockWrite& StaticSocketDataHelper::PeekRealWrite() const {
+ for (size_t i = write_index_; i < write_count_; i++) {
+ if (writes_[i].mode != ASYNC || writes_[i].result != ERR_IO_PENDING)
+ return writes_[i];
+ }
+
+ CHECK(false) << "No write data available.";
+ return writes_[0]; // Avoid warning about unreachable missing return.
}
StaticSocketDataProvider::StaticSocketDataProvider()
« no previous file with comments | « net/socket/socket_test_util.h ('k') | net/socket/ssl_client_socket_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698