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/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 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 : socket_(socket.Pass()), | 1935 : socket_(socket.Pass()), |
1936 handle_(handle), | 1936 handle_(handle), |
1937 user_callback_(callback) { | 1937 user_callback_(callback) { |
1938 } | 1938 } |
1939 | 1939 |
1940 MockTransportClientSocketPool::MockConnectJob::~MockConnectJob() {} | 1940 MockTransportClientSocketPool::MockConnectJob::~MockConnectJob() {} |
1941 | 1941 |
1942 int MockTransportClientSocketPool::MockConnectJob::Connect() { | 1942 int MockTransportClientSocketPool::MockConnectJob::Connect() { |
1943 int rv = socket_->Connect(base::Bind(&MockConnectJob::OnConnect, | 1943 int rv = socket_->Connect(base::Bind(&MockConnectJob::OnConnect, |
1944 base::Unretained(this))); | 1944 base::Unretained(this))); |
1945 if (rv == OK) { | 1945 if (rv != ERR_IO_PENDING) { |
1946 user_callback_.Reset(); | 1946 user_callback_.Reset(); |
1947 OnConnect(OK); | 1947 OnConnect(rv); |
1948 } | 1948 } |
1949 return rv; | 1949 return rv; |
1950 } | 1950 } |
1951 | 1951 |
1952 bool MockTransportClientSocketPool::MockConnectJob::CancelHandle( | 1952 bool MockTransportClientSocketPool::MockConnectJob::CancelHandle( |
1953 const ClientSocketHandle* handle) { | 1953 const ClientSocketHandle* handle) { |
1954 if (handle != handle_) | 1954 if (handle != handle_) |
1955 return false; | 1955 return false; |
1956 socket_.reset(); | 1956 socket_.reset(); |
1957 handle_ = NULL; | 1957 handle_ = NULL; |
(...skipping 11 matching lines...) Expand all Loading... |
1969 // sockets. | 1969 // sockets. |
1970 LoadTimingInfo::ConnectTiming connect_timing; | 1970 LoadTimingInfo::ConnectTiming connect_timing; |
1971 base::TimeTicks now = base::TimeTicks::Now(); | 1971 base::TimeTicks now = base::TimeTicks::Now(); |
1972 connect_timing.dns_start = now; | 1972 connect_timing.dns_start = now; |
1973 connect_timing.dns_end = now; | 1973 connect_timing.dns_end = now; |
1974 connect_timing.connect_start = now; | 1974 connect_timing.connect_start = now; |
1975 connect_timing.connect_end = now; | 1975 connect_timing.connect_end = now; |
1976 handle_->set_connect_timing(connect_timing); | 1976 handle_->set_connect_timing(connect_timing); |
1977 } else { | 1977 } else { |
1978 socket_.reset(); | 1978 socket_.reset(); |
| 1979 |
| 1980 // Needed to test copying of ConnectionAttempts in SSL ConnectJob. |
| 1981 ConnectionAttempts attempts; |
| 1982 attempts.push_back(ConnectionAttempt(IPEndPoint(), rv)); |
| 1983 handle_->set_connection_attempts(attempts); |
1979 } | 1984 } |
1980 | 1985 |
1981 handle_ = NULL; | 1986 handle_ = NULL; |
1982 | 1987 |
1983 if (!user_callback_.is_null()) { | 1988 if (!user_callback_.is_null()) { |
1984 CompletionCallback callback = user_callback_; | 1989 CompletionCallback callback = user_callback_; |
1985 user_callback_.Reset(); | 1990 user_callback_.Reset(); |
1986 callback.Run(rv); | 1991 callback.Run(rv); |
1987 } | 1992 } |
1988 } | 1993 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2165 | 2170 |
2166 const char kSOCKS5OkRequest[] = | 2171 const char kSOCKS5OkRequest[] = |
2167 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2172 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
2168 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2173 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
2169 | 2174 |
2170 const char kSOCKS5OkResponse[] = | 2175 const char kSOCKS5OkResponse[] = |
2171 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2176 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
2172 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2177 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
2173 | 2178 |
2174 } // namespace net | 2179 } // namespace net |
OLD | NEW |