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 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 : socket_(socket.Pass()), | 1974 : socket_(socket.Pass()), |
1975 handle_(handle), | 1975 handle_(handle), |
1976 user_callback_(callback) { | 1976 user_callback_(callback) { |
1977 } | 1977 } |
1978 | 1978 |
1979 MockTransportClientSocketPool::MockConnectJob::~MockConnectJob() {} | 1979 MockTransportClientSocketPool::MockConnectJob::~MockConnectJob() {} |
1980 | 1980 |
1981 int MockTransportClientSocketPool::MockConnectJob::Connect() { | 1981 int MockTransportClientSocketPool::MockConnectJob::Connect() { |
1982 int rv = socket_->Connect(base::Bind(&MockConnectJob::OnConnect, | 1982 int rv = socket_->Connect(base::Bind(&MockConnectJob::OnConnect, |
1983 base::Unretained(this))); | 1983 base::Unretained(this))); |
1984 if (rv == OK) { | 1984 if (rv != ERR_IO_PENDING) { |
1985 user_callback_.Reset(); | 1985 user_callback_.Reset(); |
1986 OnConnect(OK); | 1986 OnConnect(rv); |
1987 } | 1987 } |
1988 return rv; | 1988 return rv; |
1989 } | 1989 } |
1990 | 1990 |
1991 bool MockTransportClientSocketPool::MockConnectJob::CancelHandle( | 1991 bool MockTransportClientSocketPool::MockConnectJob::CancelHandle( |
1992 const ClientSocketHandle* handle) { | 1992 const ClientSocketHandle* handle) { |
1993 if (handle != handle_) | 1993 if (handle != handle_) |
1994 return false; | 1994 return false; |
1995 socket_.reset(); | 1995 socket_.reset(); |
1996 handle_ = NULL; | 1996 handle_ = NULL; |
(...skipping 11 matching lines...) Expand all Loading... |
2008 // sockets. | 2008 // sockets. |
2009 LoadTimingInfo::ConnectTiming connect_timing; | 2009 LoadTimingInfo::ConnectTiming connect_timing; |
2010 base::TimeTicks now = base::TimeTicks::Now(); | 2010 base::TimeTicks now = base::TimeTicks::Now(); |
2011 connect_timing.dns_start = now; | 2011 connect_timing.dns_start = now; |
2012 connect_timing.dns_end = now; | 2012 connect_timing.dns_end = now; |
2013 connect_timing.connect_start = now; | 2013 connect_timing.connect_start = now; |
2014 connect_timing.connect_end = now; | 2014 connect_timing.connect_end = now; |
2015 handle_->set_connect_timing(connect_timing); | 2015 handle_->set_connect_timing(connect_timing); |
2016 } else { | 2016 } else { |
2017 socket_.reset(); | 2017 socket_.reset(); |
| 2018 |
| 2019 // Needed to test copying of ConnectionAttempts in SSL ConnectJob. |
| 2020 ConnectionAttempts attempts; |
| 2021 attempts.push_back(ConnectionAttempt(IPEndPoint(), rv)); |
| 2022 handle_->set_connection_attempts(attempts); |
2018 } | 2023 } |
2019 | 2024 |
2020 handle_ = NULL; | 2025 handle_ = NULL; |
2021 | 2026 |
2022 if (!user_callback_.is_null()) { | 2027 if (!user_callback_.is_null()) { |
2023 CompletionCallback callback = user_callback_; | 2028 CompletionCallback callback = user_callback_; |
2024 user_callback_.Reset(); | 2029 user_callback_.Reset(); |
2025 callback.Run(rv); | 2030 callback.Run(rv); |
2026 } | 2031 } |
2027 } | 2032 } |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2204 | 2209 |
2205 const char kSOCKS5OkRequest[] = | 2210 const char kSOCKS5OkRequest[] = |
2206 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; | 2211 { 0x05, 0x01, 0x00, 0x03, 0x04, 'h', 'o', 's', 't', 0x00, 0x50 }; |
2207 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); | 2212 const int kSOCKS5OkRequestLength = arraysize(kSOCKS5OkRequest); |
2208 | 2213 |
2209 const char kSOCKS5OkResponse[] = | 2214 const char kSOCKS5OkResponse[] = |
2210 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; | 2215 { 0x05, 0x00, 0x00, 0x01, 127, 0, 0, 1, 0x00, 0x50 }; |
2211 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); | 2216 const int kSOCKS5OkResponseLength = arraysize(kSOCKS5OkResponse); |
2212 | 2217 |
2213 } // namespace net | 2218 } // namespace net |
OLD | NEW |