OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/buffered_socket_writer.h" | 5 #include "remoting/protocol/buffered_socket_writer.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 int result = socket_->Write(current_packet, current_packet_size, | 96 int result = socket_->Write(current_packet, current_packet_size, |
97 &written_callback_); | 97 &written_callback_); |
98 if (result >= 0) { | 98 if (result >= 0) { |
99 AutoLock auto_lock(lock_); | 99 AutoLock auto_lock(lock_); |
100 AdvanceBufferPosition_Locked(result); | 100 AdvanceBufferPosition_Locked(result); |
101 } else { | 101 } else { |
102 if (result == net::ERR_IO_PENDING) { | 102 if (result == net::ERR_IO_PENDING) { |
103 write_pending_ = true; | 103 write_pending_ = true; |
104 } else { | 104 } else { |
105 HandleError(result); | 105 HandleError(result); |
106 if (write_failed_callback_.get()) | |
107 write_failed_callback_->Run(result); | |
108 } | 106 } |
109 return; | 107 return; |
110 } | 108 } |
111 } | 109 } |
112 } | 110 } |
113 | 111 |
114 void BufferedSocketWriterBase::OnWritten(int result) { | 112 void BufferedSocketWriterBase::OnWritten(int result) { |
115 DCHECK_EQ(message_loop_, MessageLoop::current()); | 113 DCHECK_EQ(message_loop_, MessageLoop::current()); |
116 write_pending_ = false; | 114 write_pending_ = false; |
117 | 115 |
118 if (result < 0) { | 116 if (result < 0) { |
119 HandleError(result); | 117 HandleError(result); |
120 if (write_failed_callback_.get()) | |
121 write_failed_callback_->Run(result); | |
122 return; | 118 return; |
123 } | 119 } |
124 | 120 |
125 { | 121 { |
126 AutoLock auto_lock(lock_); | 122 AutoLock auto_lock(lock_); |
127 AdvanceBufferPosition_Locked(result); | 123 AdvanceBufferPosition_Locked(result); |
128 } | 124 } |
129 | 125 |
130 // Schedule next write. | 126 // Schedule next write. |
131 message_loop_->PostTask( | 127 message_loop_->PostTask( |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 buffer_size_ -= queue_.front()->data()->size(); | 211 buffer_size_ -= queue_.front()->data()->size(); |
216 PopQueue(); | 212 PopQueue(); |
217 } | 213 } |
218 | 214 |
219 void BufferedDatagramWriter::OnError_Locked(int result) { | 215 void BufferedDatagramWriter::OnError_Locked(int result) { |
220 // Nothing to do here. | 216 // Nothing to do here. |
221 } | 217 } |
222 | 218 |
223 } // namespace protocol | 219 } // namespace protocol |
224 } // namespace remoting | 220 } // namespace remoting |
OLD | NEW |