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 "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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 pending_buf_len_(0), | 180 pending_buf_len_(0), |
181 pending_callback_(NULL) { | 181 pending_callback_(NULL) { |
182 DCHECK(data_); | 182 DCHECK(data_); |
183 data_->Reset(); | 183 data_->Reset(); |
184 } | 184 } |
185 | 185 |
186 int MockTCPClientSocket::Connect(net::CompletionCallback* callback) { | 186 int MockTCPClientSocket::Connect(net::CompletionCallback* callback) { |
187 if (connected_) | 187 if (connected_) |
188 return net::OK; | 188 return net::OK; |
189 connected_ = true; | 189 connected_ = true; |
| 190 peer_closed_connection_ = false; |
190 if (data_->connect_data().async) { | 191 if (data_->connect_data().async) { |
191 RunCallbackAsync(callback, data_->connect_data().result); | 192 RunCallbackAsync(callback, data_->connect_data().result); |
192 return net::ERR_IO_PENDING; | 193 return net::ERR_IO_PENDING; |
193 } | 194 } |
194 return data_->connect_data().result; | 195 return data_->connect_data().result; |
195 } | 196 } |
196 | 197 |
197 void MockTCPClientSocket::Disconnect() { | 198 void MockTCPClientSocket::Disconnect() { |
198 MockClientSocket::Disconnect(); | 199 MockClientSocket::Disconnect(); |
199 pending_callback_ = NULL; | 200 pending_callback_ = NULL; |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 return tcp_pool_->CancelRequest(group_name, handle); | 880 return tcp_pool_->CancelRequest(group_name, handle); |
880 } | 881 } |
881 | 882 |
882 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, | 883 void MockSOCKSClientSocketPool::ReleaseSocket(const std::string& group_name, |
883 ClientSocket* socket, int id) { | 884 ClientSocket* socket, int id) { |
884 return tcp_pool_->ReleaseSocket(group_name, socket, id); | 885 return tcp_pool_->ReleaseSocket(group_name, socket, id); |
885 } | 886 } |
886 | 887 |
887 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} | 888 MockSOCKSClientSocketPool::~MockSOCKSClientSocketPool() {} |
888 | 889 |
889 MockHttpAuthController::MockHttpAuthController() | |
890 : HttpAuthController(HttpAuth::AUTH_PROXY, GURL(), | |
891 scoped_refptr<HttpNetworkSession>(NULL)), | |
892 data_(NULL), | |
893 data_index_(0), | |
894 data_count_(0) { | |
895 } | |
896 | |
897 void MockHttpAuthController::SetMockAuthControllerData( | |
898 struct MockHttpAuthControllerData* data, size_t count) { | |
899 data_ = data; | |
900 data_count_ = count; | |
901 } | |
902 | |
903 int MockHttpAuthController::MaybeGenerateAuthToken( | |
904 const HttpRequestInfo* request, | |
905 CompletionCallback* callback, | |
906 const BoundNetLog& net_log) { | |
907 return OK; | |
908 } | |
909 | |
910 void MockHttpAuthController::AddAuthorizationHeader( | |
911 HttpRequestHeaders* authorization_headers) { | |
912 authorization_headers->AddHeadersFromString(CurrentData().auth_header); | |
913 } | |
914 | |
915 int MockHttpAuthController::HandleAuthChallenge( | |
916 scoped_refptr<HttpResponseHeaders> headers, | |
917 bool do_not_send_server_auth, | |
918 bool establishing_tunnel, | |
919 const BoundNetLog& net_log) { | |
920 return OK; | |
921 } | |
922 | |
923 void MockHttpAuthController::ResetAuth(const string16& username, | |
924 const string16& password) { | |
925 data_index_++; | |
926 } | |
927 | |
928 bool MockHttpAuthController::HaveAuth() const { | |
929 return CurrentData().auth_header.size() != 0; | |
930 } | |
931 | |
932 bool MockHttpAuthController::HaveAuthHandler() const { | |
933 return HaveAuth(); | |
934 } | |
935 | |
936 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; | 890 const char kSOCKS5GreetRequest[] = { 0x05, 0x01, 0x00 }; |
937 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); | 891 const int kSOCKS5GreetRequestLength = arraysize(kSOCKS5GreetRequest); |
938 | 892 |
939 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; | 893 const char kSOCKS5GreetResponse[] = { 0x05, 0x00 }; |
940 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); | 894 const int kSOCKS5GreetResponseLength = arraysize(kSOCKS5GreetResponse); |
941 | 895 |
942 const char kSOCKS5OkRequest[] = | 896 const char kSOCKS5OkRequest[] = |
943 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 897 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
944 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 898 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
945 | 899 |
946 const char kSOCKS5OkResponse[] = | 900 const char kSOCKS5OkResponse[] = |
947 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 901 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
948 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 902 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
949 | 903 |
950 } // namespace net | 904 } // namespace net |
OLD | NEW |