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

Side by Side Diff: net/socket/socket_test_util.cc

Issue 7251004: Deciding best connection to schedule requests on based on cwnd and idle time (Reopened after revert) (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Syncing to head Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/socket_test_util.h" 5 #include "net/socket/socket_test_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 10
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 callback->Run(result); 700 callback->Run(result);
701 } 701 }
702 702
703 MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses, 703 MockTCPClientSocket::MockTCPClientSocket(const net::AddressList& addresses,
704 net::NetLog* net_log, 704 net::NetLog* net_log,
705 net::SocketDataProvider* data) 705 net::SocketDataProvider* data)
706 : MockClientSocket(net_log), 706 : MockClientSocket(net_log),
707 addresses_(addresses), 707 addresses_(addresses),
708 data_(data), 708 data_(data),
709 read_offset_(0), 709 read_offset_(0),
710 num_bytes_read_(0),
710 read_data_(false, net::ERR_UNEXPECTED), 711 read_data_(false, net::ERR_UNEXPECTED),
711 need_read_data_(true), 712 need_read_data_(true),
712 peer_closed_connection_(false), 713 peer_closed_connection_(false),
713 pending_buf_(NULL), 714 pending_buf_(NULL),
714 pending_buf_len_(0), 715 pending_buf_len_(0),
715 pending_callback_(NULL), 716 pending_callback_(NULL),
716 was_used_to_convey_data_(false) { 717 was_used_to_convey_data_(false) {
717 DCHECK(data_); 718 DCHECK(data_);
718 data_->Reset(); 719 data_->Reset();
719 } 720 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 } 805 }
805 806
806 bool MockTCPClientSocket::WasEverUsed() const { 807 bool MockTCPClientSocket::WasEverUsed() const {
807 return was_used_to_convey_data_; 808 return was_used_to_convey_data_;
808 } 809 }
809 810
810 bool MockTCPClientSocket::UsingTCPFastOpen() const { 811 bool MockTCPClientSocket::UsingTCPFastOpen() const {
811 return false; 812 return false;
812 } 813 }
813 814
815 int64 MockTCPClientSocket::NumBytesRead() const {
816 return num_bytes_read_;
817 }
818
819 base::TimeDelta MockTCPClientSocket::GetConnectTimeMicros() const {
820 // Dummy value.
821 static const base::TimeDelta kTestingConnectTimeMicros =
822 base::TimeDelta::FromMicroseconds(20);
823 return kTestingConnectTimeMicros;
824 }
825
814 void MockTCPClientSocket::OnReadComplete(const MockRead& data) { 826 void MockTCPClientSocket::OnReadComplete(const MockRead& data) {
815 // There must be a read pending. 827 // There must be a read pending.
816 DCHECK(pending_buf_); 828 DCHECK(pending_buf_);
817 // You can't complete a read with another ERR_IO_PENDING status code. 829 // You can't complete a read with another ERR_IO_PENDING status code.
818 DCHECK_NE(ERR_IO_PENDING, data.result); 830 DCHECK_NE(ERR_IO_PENDING, data.result);
819 // Since we've been waiting for data, need_read_data_ should be true. 831 // Since we've been waiting for data, need_read_data_ should be true.
820 DCHECK(need_read_data_); 832 DCHECK(need_read_data_);
821 833
822 read_data_ = data; 834 read_data_ = data;
823 need_read_data_ = false; 835 need_read_data_ = false;
(...skipping 22 matching lines...) Expand all
846 pending_callback_ = NULL; 858 pending_callback_ = NULL;
847 859
848 int result = read_data_.result; 860 int result = read_data_.result;
849 DCHECK(result != ERR_IO_PENDING); 861 DCHECK(result != ERR_IO_PENDING);
850 862
851 if (read_data_.data) { 863 if (read_data_.data) {
852 if (read_data_.data_len - read_offset_ > 0) { 864 if (read_data_.data_len - read_offset_ > 0) {
853 result = std::min(buf_len, read_data_.data_len - read_offset_); 865 result = std::min(buf_len, read_data_.data_len - read_offset_);
854 memcpy(buf->data(), read_data_.data + read_offset_, result); 866 memcpy(buf->data(), read_data_.data + read_offset_, result);
855 read_offset_ += result; 867 read_offset_ += result;
868 num_bytes_read_ += result;
856 if (read_offset_ == read_data_.data_len) { 869 if (read_offset_ == read_data_.data_len) {
857 need_read_data_ = true; 870 need_read_data_ = true;
858 read_offset_ = 0; 871 read_offset_ = 0;
859 } 872 }
860 } else { 873 } else {
861 result = 0; // EOF 874 result = 0; // EOF
862 } 875 }
863 } 876 }
864 877
865 if (read_data_.async) { 878 if (read_data_.async) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 } 1007 }
995 1008
996 bool DeterministicMockTCPClientSocket::WasEverUsed() const { 1009 bool DeterministicMockTCPClientSocket::WasEverUsed() const {
997 return was_used_to_convey_data_; 1010 return was_used_to_convey_data_;
998 } 1011 }
999 1012
1000 bool DeterministicMockTCPClientSocket::UsingTCPFastOpen() const { 1013 bool DeterministicMockTCPClientSocket::UsingTCPFastOpen() const {
1001 return false; 1014 return false;
1002 } 1015 }
1003 1016
1017 int64 DeterministicMockTCPClientSocket::NumBytesRead() const {
1018 return -1;
1019 }
1020
1021 base::TimeDelta DeterministicMockTCPClientSocket::GetConnectTimeMicros() const {
1022 return base::TimeDelta::FromMicroseconds(-1);
1023 }
1024
1004 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {} 1025 void DeterministicMockTCPClientSocket::OnReadComplete(const MockRead& data) {}
1005 1026
1006 class MockSSLClientSocket::ConnectCallback 1027 class MockSSLClientSocket::ConnectCallback
1007 : public net::CompletionCallbackImpl<MockSSLClientSocket::ConnectCallback> { 1028 : public net::CompletionCallbackImpl<MockSSLClientSocket::ConnectCallback> {
1008 public: 1029 public:
1009 ConnectCallback(MockSSLClientSocket *ssl_client_socket, 1030 ConnectCallback(MockSSLClientSocket *ssl_client_socket,
1010 net::CompletionCallback* user_callback, 1031 net::CompletionCallback* user_callback,
1011 int rv) 1032 int rv)
1012 : ALLOW_THIS_IN_INITIALIZER_LIST( 1033 : ALLOW_THIS_IN_INITIALIZER_LIST(
1013 net::CompletionCallbackImpl<MockSSLClientSocket::ConnectCallback>( 1034 net::CompletionCallbackImpl<MockSSLClientSocket::ConnectCallback>(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 } 1108 }
1088 1109
1089 bool MockSSLClientSocket::WasEverUsed() const { 1110 bool MockSSLClientSocket::WasEverUsed() const {
1090 return transport_->socket()->WasEverUsed(); 1111 return transport_->socket()->WasEverUsed();
1091 } 1112 }
1092 1113
1093 bool MockSSLClientSocket::UsingTCPFastOpen() const { 1114 bool MockSSLClientSocket::UsingTCPFastOpen() const {
1094 return transport_->socket()->UsingTCPFastOpen(); 1115 return transport_->socket()->UsingTCPFastOpen();
1095 } 1116 }
1096 1117
1118 int64 MockSSLClientSocket::NumBytesRead() const {
1119 return -1;
1120 }
1121
1122 base::TimeDelta MockSSLClientSocket::GetConnectTimeMicros() const {
1123 return base::TimeDelta::FromMicroseconds(-1);
1124 }
1125
1097 void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) { 1126 void MockSSLClientSocket::GetSSLInfo(net::SSLInfo* ssl_info) {
1098 ssl_info->Reset(); 1127 ssl_info->Reset();
1099 ssl_info->cert = data_->cert_; 1128 ssl_info->cert = data_->cert_;
1100 } 1129 }
1101 1130
1102 void MockSSLClientSocket::GetSSLCertRequestInfo( 1131 void MockSSLClientSocket::GetSSLCertRequestInfo(
1103 net::SSLCertRequestInfo* cert_request_info) { 1132 net::SSLCertRequestInfo* cert_request_info) {
1104 DCHECK(cert_request_info); 1133 DCHECK(cert_request_info);
1105 if (data_->cert_request_info) { 1134 if (data_->cert_request_info) {
1106 cert_request_info->host_and_port = 1135 cert_request_info->host_and_port =
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1491 1520
1492 const char kSOCKS5OkRequest[] = 1521 const char kSOCKS5OkRequest[] =
1493 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; 1522 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 };
1494 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); 1523 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest);
1495 1524
1496 const char kSOCKS5OkResponse[] = 1525 const char kSOCKS5OkResponse[] =
1497 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; 1526 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 };
1498 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); 1527 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse);
1499 1528
1500 } // namespace net 1529 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698