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

Side by Side Diff: net/socket_stream/socket_stream.cc

Issue 355022: Minor fixes in SocketStream. (Closed)
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // TODO(ukai): code is similar with http_network_transaction.cc. We should 5 // TODO(ukai): code is similar with http_network_transaction.cc. We should
6 // think about ways to share code, if possible. 6 // think about ways to share code, if possible.
7 7
8 #include "net/socket_stream/socket_stream.h" 8 #include "net/socket_stream/socket_stream.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 return socket_->Connect(&io_callback_, NULL); 631 return socket_->Connect(&io_callback_, NULL);
632 } 632 }
633 633
634 int SocketStream::DoSOCKSConnectComplete(int result) { 634 int SocketStream::DoSOCKSConnectComplete(int result) {
635 DCHECK_EQ(kSOCKSProxy, proxy_mode_); 635 DCHECK_EQ(kSOCKSProxy, proxy_mode_);
636 636
637 if (result == OK) { 637 if (result == OK) {
638 if (is_secure()) 638 if (is_secure())
639 next_state_ = STATE_SSL_CONNECT; 639 next_state_ = STATE_SSL_CONNECT;
640 else 640 else
641 DidEstablishConnection(); 641 result = DidEstablishConnection();
642 } 642 }
643 return result; 643 return result;
644 } 644 }
645 645
646 int SocketStream::DoSSLConnect() { 646 int SocketStream::DoSSLConnect() {
647 DCHECK(factory_); 647 DCHECK(factory_);
648 socket_.reset(factory_->CreateSSLClientSocket( 648 socket_.reset(factory_->CreateSSLClientSocket(
649 socket_.release(), url_.HostNoBrackets(), ssl_config_)); 649 socket_.release(), url_.HostNoBrackets(), ssl_config_));
650 next_state_ = STATE_SSL_CONNECT_COMPLETE; 650 next_state_ = STATE_SSL_CONNECT_COMPLETE;
651 // TODO(willchan): Plumb LoadLog into SocketStream. 651 // TODO(willchan): Plumb LoadLog into SocketStream.
(...skipping 29 matching lines...) Expand all
681 result = socket_->Read(read_buf_, kReadBufferSize, &read_callback_); 681 result = socket_->Read(read_buf_, kReadBufferSize, &read_callback_);
682 if (result > 0) { 682 if (result > 0) {
683 DidReceiveData(result); 683 DidReceiveData(result);
684 return OK; 684 return OK;
685 } else if (result == 0) { 685 } else if (result == 0) {
686 // 0 indicates end-of-file, so socket was closed. 686 // 0 indicates end-of-file, so socket was closed.
687 next_state_ = STATE_CLOSE; 687 next_state_ = STATE_CLOSE;
688 return ERR_CONNECTION_CLOSED; 688 return ERR_CONNECTION_CLOSED;
689 } 689 }
690 // If read is pending, try write as well. 690 // If read is pending, try write as well.
691 // Otherwise, return the result and do next loop. 691 // Otherwise, return the result and do next loop (to close the connection).
692 if (result != ERR_IO_PENDING) { 692 if (result != ERR_IO_PENDING) {
693 next_state_ = STATE_CLOSE; 693 next_state_ = STATE_CLOSE;
694 return result; 694 return result;
695 } 695 }
696 } 696 }
697 // Read is pending. 697 // Read is pending.
698 DCHECK(read_buf_); 698 DCHECK(read_buf_);
699 699
700 if (write_buf_ && !current_write_buf_) { 700 if (write_buf_ && !current_write_buf_) {
701 // No write pending. 701 // No write pending.
702 current_write_buf_ = new DrainableIOBuffer(write_buf_, write_buf_size_); 702 current_write_buf_ = new DrainableIOBuffer(write_buf_, write_buf_size_);
703 current_write_buf_->SetOffset(write_buf_offset_); 703 current_write_buf_->SetOffset(write_buf_offset_);
704 result = socket_->Write(current_write_buf_, 704 result = socket_->Write(current_write_buf_,
705 current_write_buf_->BytesRemaining(), 705 current_write_buf_->BytesRemaining(),
706 &write_callback_); 706 &write_callback_);
707 if (result > 0) { 707 if (result > 0) {
708 DidSendData(result); 708 DidSendData(result);
709 return OK; 709 return OK;
710 } 710 }
711 // If write is not pending, return the result and do next loop (to close
712 // the connection).
713 if (result != 0 && result != ERR_IO_PENDING) {
714 next_state_ = STATE_CLOSE;
715 return result;
716 }
711 return result; 717 return result;
712 } 718 }
713 719
714 // We arrived here when both operation is pending. 720 // We arrived here when both operation is pending.
715 return ERR_IO_PENDING; 721 return ERR_IO_PENDING;
716 } 722 }
717 723
718 GURL SocketStream::ProxyAuthOrigin() const { 724 GURL SocketStream::ProxyAuthOrigin() const {
719 return GURL("http://" + proxy_info_.proxy_server().host_and_port()); 725 return GURL("http://" + proxy_info_.proxy_server().host_and_port());
720 } 726 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 815
810 SSLConfigService* SocketStream::ssl_config_service() const { 816 SSLConfigService* SocketStream::ssl_config_service() const {
811 return context_->ssl_config_service(); 817 return context_->ssl_config_service();
812 } 818 }
813 819
814 ProxyService* SocketStream::proxy_service() const { 820 ProxyService* SocketStream::proxy_service() const {
815 return context_->proxy_service(); 821 return context_->proxy_service();
816 } 822 }
817 823
818 } // namespace net 824 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698