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

Unified Diff: remoting/protocol/fake_session.cc

Issue 10703159: Fix MessageReader to handle errors properly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
Index: remoting/protocol/fake_session.cc
diff --git a/remoting/protocol/fake_session.cc b/remoting/protocol/fake_session.cc
index 30a6ddb54ad4944b4ed7cc00fab2eb97f5755e3d..4915dce8c26ec4e0596759069082e3b543ab8ade 100644
--- a/remoting/protocol/fake_session.cc
+++ b/remoting/protocol/fake_session.cc
@@ -18,7 +18,8 @@ namespace protocol {
const char kTestJid[] = "host1@gmail.com/chromoting123";
FakeSocket::FakeSocket()
- : read_pending_(false),
+ : next_read_error_(net::OK),
+ read_pending_(false),
read_buffer_size_(0),
input_pos_(0),
message_loop_(MessageLoop::current()),
@@ -55,6 +56,13 @@ void FakeSocket::PairWith(FakeSocket* peer_socket) {
int FakeSocket::Read(net::IOBuffer* buf, int buf_len,
const net::CompletionCallback& callback) {
EXPECT_EQ(message_loop_, MessageLoop::current());
+
+ if (next_read_error_ != net::OK) {
+ int r = next_read_error_;
+ next_read_error_ = net::OK;
+ return r;
+ }
+
if (input_pos_ < static_cast<int>(input_data_.size())) {
int result = std::min(buf_len,
static_cast<int>(input_data_.size()) - input_pos_);

Powered by Google App Engine
This is Rietveld 408576698