| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 CompletionCallback callback() { | 99 CompletionCallback callback() { |
| 100 return base::Bind(&ReentrantHelper::OnIOComplete, base::Unretained(this)); | 100 return base::Bind(&ReentrantHelper::OnIOComplete, base::Unretained(this)); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Retuns the buffer where data is expected to have been written, | 103 // Retuns the buffer where data is expected to have been written, |
| 104 // when checked by SetExpectRead() | 104 // when checked by SetExpectRead() |
| 105 scoped_refptr<IOBuffer> read_buf() { return first_read_buf_; } | 105 scoped_refptr<IOBuffer> read_buf() { return first_read_buf_; } |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 void OnIOComplete(int rv) { | 108 void OnIOComplete(int rv) { |
| 109 CHECK_NE(-1, first_len_) << "Expectation not set."; | 109 // Expectation not set. |
| 110 CHECK_NE(-1, second_len_) << "Invocation not set."; | 110 CHECK_NE(-1, first_len_); |
| 111 // Invocation not set. |
| 112 CHECK_NE(-1, second_len_); |
| 111 ASSERT_EQ(first_len_, rv); | 113 ASSERT_EQ(first_len_, rv); |
| 112 if (verify_read_) { | 114 if (verify_read_) { |
| 113 ASSERT_EQ(std::string(first_read_data_, first_len_), | 115 ASSERT_EQ(std::string(first_read_data_, first_len_), |
| 114 std::string(first_read_buf_->data(), rv)); | 116 std::string(first_read_buf_->data(), rv)); |
| 115 } | 117 } |
| 116 | 118 |
| 117 if (second_read_) { | 119 if (second_read_) { |
| 118 ASSERT_EQ(second_rv_, socket_->Read(second_read_buf_.get(), second_len_, | 120 ASSERT_EQ(second_rv_, socket_->Read(second_read_buf_.get(), second_len_, |
| 119 second_callback_)); | 121 second_callback_)); |
| 120 } else { | 122 } else { |
| (...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 | 1250 |
| 1249 Resume(); | 1251 Resume(); |
| 1250 ASSERT_FALSE(IsPaused()); | 1252 ASSERT_FALSE(IsPaused()); |
| 1251 ASSERT_TRUE(write_callback_.have_result()); | 1253 ASSERT_TRUE(write_callback_.have_result()); |
| 1252 ASSERT_EQ(kLen2, write_callback_.WaitForResult()); | 1254 ASSERT_EQ(kLen2, write_callback_.WaitForResult()); |
| 1253 } | 1255 } |
| 1254 | 1256 |
| 1255 } // namespace | 1257 } // namespace |
| 1256 | 1258 |
| 1257 } // namespace net | 1259 } // namespace net |
| OLD | NEW |