Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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/ssl_client_socket_mac.h" | 5 #include "net/socket/ssl_client_socket_mac.h" |
| 6 | 6 |
| 7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 SSLClientSocketMac* us = | 729 SSLClientSocketMac* us = |
| 730 const_cast<SSLClientSocketMac*>( | 730 const_cast<SSLClientSocketMac*>( |
| 731 static_cast<const SSLClientSocketMac*>(connection)); | 731 static_cast<const SSLClientSocketMac*>(connection)); |
| 732 | 732 |
| 733 if (us->pending_send_error_ != OK) { | 733 if (us->pending_send_error_ != OK) { |
| 734 OSStatus status = OSStatusFromNetError(us->pending_send_error_); | 734 OSStatus status = OSStatusFromNetError(us->pending_send_error_); |
| 735 us->pending_send_error_ = OK; | 735 us->pending_send_error_ = OK; |
| 736 return status; | 736 return status; |
| 737 } | 737 } |
| 738 | 738 |
| 739 bool send_pending = !us->send_buffer_.empty(); | |
| 740 | |
| 739 if (data) | 741 if (data) |
| 740 us->send_buffer_.insert(us->send_buffer_.end(), | 742 us->send_buffer_.insert(us->send_buffer_.end(), |
| 741 static_cast<const char*>(data), | 743 static_cast<const char*>(data), |
| 742 static_cast<const char*>(data) + *data_length); | 744 static_cast<const char*>(data) + *data_length); |
| 745 | |
| 746 if (send_pending) { | |
| 747 // If we have I/O in flight, just add the data to the end of the buffer and | |
| 748 // return to our caller. The existing callback will trigger the write of the | |
| 749 // new data when it sees that data remains in the buffer after removing the | |
| 750 // sent data. | |
| 751 return noErr; | |
|
wtc
2009/07/29 18:05:17
Perhaps you can reproduce the "always lie to our c
Avi (use Gerrit)
2009/07/29 18:22:41
Sure.
We can't return would-block. The caller wan
| |
| 752 } | |
| 753 | |
| 743 int rv; | 754 int rv; |
| 744 do { | 755 do { |
| 745 scoped_refptr<IOBuffer> buffer = new IOBuffer(us->send_buffer_.size()); | 756 scoped_refptr<IOBuffer> buffer = new IOBuffer(us->send_buffer_.size()); |
| 746 memcpy(buffer->data(), &us->send_buffer_[0], us->send_buffer_.size()); | 757 memcpy(buffer->data(), &us->send_buffer_[0], us->send_buffer_.size()); |
| 747 rv = us->transport_->Write(buffer, | 758 rv = us->transport_->Write(buffer, |
| 748 us->send_buffer_.size(), | 759 us->send_buffer_.size(), |
| 749 &us->write_callback_); | 760 &us->write_callback_); |
| 750 if (rv > 0) { | 761 if (rv > 0) { |
| 751 us->send_buffer_.erase(us->send_buffer_.begin(), | 762 us->send_buffer_.erase(us->send_buffer_.begin(), |
| 752 us->send_buffer_.begin() + rv); | 763 us->send_buffer_.begin() + rv); |
| 753 } | 764 } |
| 754 } while (rv > 0 && !us->send_buffer_.empty()); | 765 } while (rv > 0 && !us->send_buffer_.empty()); |
| 755 | 766 |
| 756 if (rv < 0 && rv != ERR_IO_PENDING) { | 767 if (rv < 0 && rv != ERR_IO_PENDING) { |
| 757 return OSStatusFromNetError(rv); | 768 return OSStatusFromNetError(rv); |
| 758 } | 769 } |
| 759 | 770 |
| 760 // always lie to our caller | 771 // always lie to our caller |
| 761 return noErr; | 772 return noErr; |
| 762 } | 773 } |
| 763 | 774 |
| 764 } // namespace net | 775 } // namespace net |
| OLD | NEW |