| OLD | NEW |
| 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 "net/socket/buffered_write_stream_socket.h" | 5 #include "net/socket/buffered_write_stream_socket.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 NextProto BufferedWriteStreamSocket::GetNegotiatedProtocol() const { | 118 NextProto BufferedWriteStreamSocket::GetNegotiatedProtocol() const { |
| 119 return wrapped_socket_->GetNegotiatedProtocol(); | 119 return wrapped_socket_->GetNegotiatedProtocol(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 bool BufferedWriteStreamSocket::GetSSLInfo(SSLInfo* ssl_info) { | 122 bool BufferedWriteStreamSocket::GetSSLInfo(SSLInfo* ssl_info) { |
| 123 return wrapped_socket_->GetSSLInfo(ssl_info); | 123 return wrapped_socket_->GetSSLInfo(ssl_info); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void BufferedWriteStreamSocket::DoDelayedWrite() { | 126 void BufferedWriteStreamSocket::DoDelayedWrite() { |
| 127 int result = wrapped_socket_->Write( | 127 int result = wrapped_socket_->Write( |
| 128 io_buffer_, io_buffer_->RemainingCapacity(), | 128 io_buffer_.get(), |
| 129 io_buffer_->RemainingCapacity(), |
| 129 base::Bind(&BufferedWriteStreamSocket::OnIOComplete, | 130 base::Bind(&BufferedWriteStreamSocket::OnIOComplete, |
| 130 base::Unretained(this))); | 131 base::Unretained(this))); |
| 131 if (result == ERR_IO_PENDING) { | 132 if (result == ERR_IO_PENDING) { |
| 132 callback_pending_ = true; | 133 callback_pending_ = true; |
| 133 wrapped_write_in_progress_ = true; | 134 wrapped_write_in_progress_ = true; |
| 134 } else { | 135 } else { |
| 135 OnIOComplete(result); | 136 OnIOComplete(result); |
| 136 } | 137 } |
| 137 } | 138 } |
| 138 | 139 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 151 io_buffer_->set_offset(io_buffer_->offset() + result); | 152 io_buffer_->set_offset(io_buffer_->offset() + result); |
| 152 if (io_buffer_->RemainingCapacity()) { | 153 if (io_buffer_->RemainingCapacity()) { |
| 153 DoDelayedWrite(); | 154 DoDelayedWrite(); |
| 154 } else { | 155 } else { |
| 155 io_buffer_->SetCapacity(0); | 156 io_buffer_->SetCapacity(0); |
| 156 } | 157 } |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 | 160 |
| 160 } // namespace net | 161 } // namespace net |
| OLD | NEW |