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

Side by Side Diff: remoting/protocol/message_reader.cc

Issue 2757723002: Update ICE protocol to handle closed channel (Closed)
Patch Set: . Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/protocol/message_reader.h" 5 #include "remoting/protocol/message_reader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return; 78 return;
79 79
80 *read_succeeded = true; 80 *read_succeeded = true;
81 81
82 if (result > 0) { 82 if (result > 0) {
83 OnDataReceived(read_buffer_.get(), result); 83 OnDataReceived(read_buffer_.get(), result);
84 *read_succeeded = true; 84 *read_succeeded = true;
85 } else if (result == net::ERR_IO_PENDING) { 85 } else if (result == net::ERR_IO_PENDING) {
86 read_pending_ = true; 86 read_pending_ = true;
87 } else { 87 } else {
88 DCHECK_LT(result, 0);
89
90 // Stop reading after any error. 88 // Stop reading after any error.
91 closed_ = true; 89 closed_ = true;
92 *read_succeeded = false; 90 *read_succeeded = false;
93 91
94 LOG(ERROR) << "Read() returned error " << result; 92 LOG(ERROR) << "Read() returned error " << result;
95 read_failed_callback_.Run(result); 93 read_failed_callback_.Run(result);
96 } 94 }
97 } 95 }
98 96
99 void MessageReader::OnDataReceived(net::IOBuffer* data, int data_size) { 97 void MessageReader::OnDataReceived(net::IOBuffer* data, int data_size) {
(...skipping 14 matching lines...) Expand all
114 } 112 }
115 113
116 void MessageReader::RunCallback(std::unique_ptr<CompoundBuffer> message) { 114 void MessageReader::RunCallback(std::unique_ptr<CompoundBuffer> message) {
117 if (!message_received_callback_.is_null()) { 115 if (!message_received_callback_.is_null()) {
118 message_received_callback_.Run(std::move(message)); 116 message_received_callback_.Run(std::move(message));
119 } 117 }
120 } 118 }
121 119
122 } // namespace protocol 120 } // namespace protocol
123 } // namespace remoting 121 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/ice_connection_to_host.cc ('k') | remoting/protocol/message_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698