| 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/socks_client_socket_pool.h" | 5 #include "net/socket/socks_client_socket_pool.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 class MockConnectJob { | 30 class MockConnectJob { |
| 31 public: | 31 public: |
| 32 MockConnectJob(ClientSocket* socket, ClientSocketHandle* handle, | 32 MockConnectJob(ClientSocket* socket, ClientSocketHandle* handle, |
| 33 CompletionCallback* callback) | 33 CompletionCallback* callback) |
| 34 : socket_(socket), | 34 : socket_(socket), |
| 35 handle_(handle), | 35 handle_(handle), |
| 36 user_callback_(callback), | 36 user_callback_(callback), |
| 37 ALLOW_THIS_IN_INITIALIZER_LIST( | 37 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 38 connect_callback_(this, &MockConnectJob::OnConnect)) {} | 38 connect_callback_(this, &MockConnectJob::OnConnect)) {} |
| 39 | 39 |
| 40 int Connect(const BoundNetLog& net_log) { | 40 int Connect() { |
| 41 int rv = socket_->Connect(&connect_callback_, net_log); | 41 int rv = socket_->Connect(&connect_callback_); |
| 42 if (rv == OK) { | 42 if (rv == OK) { |
| 43 user_callback_ = NULL; | 43 user_callback_ = NULL; |
| 44 OnConnect(OK); | 44 OnConnect(OK); |
| 45 } | 45 } |
| 46 return rv; | 46 return rv; |
| 47 } | 47 } |
| 48 | 48 |
| 49 bool CancelHandle(const ClientSocketHandle* handle) { | 49 bool CancelHandle(const ClientSocketHandle* handle) { |
| 50 if (handle != handle_) | 50 if (handle != handle_) |
| 51 return false; | 51 return false; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 int cancel_count() { return cancel_count_; }; | 96 int cancel_count() { return cancel_count_; }; |
| 97 | 97 |
| 98 // TCPClientSocketPool methods. | 98 // TCPClientSocketPool methods. |
| 99 virtual int RequestSocket(const std::string& group_name, | 99 virtual int RequestSocket(const std::string& group_name, |
| 100 const void* socket_params, | 100 const void* socket_params, |
| 101 RequestPriority priority, | 101 RequestPriority priority, |
| 102 ClientSocketHandle* handle, | 102 ClientSocketHandle* handle, |
| 103 CompletionCallback* callback, | 103 CompletionCallback* callback, |
| 104 const BoundNetLog& net_log) { | 104 const BoundNetLog& net_log) { |
| 105 ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket( | 105 ClientSocket* socket = client_socket_factory_->CreateTCPClientSocket( |
| 106 AddressList()); | 106 AddressList(), net_log.net_log()); |
| 107 MockConnectJob* job = new MockConnectJob(socket, handle, callback); | 107 MockConnectJob* job = new MockConnectJob(socket, handle, callback); |
| 108 job_list_.push_back(job); | 108 job_list_.push_back(job); |
| 109 return job->Connect(net_log); | 109 return job->Connect(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual void CancelRequest(const std::string& group_name, | 112 virtual void CancelRequest(const std::string& group_name, |
| 113 const ClientSocketHandle* handle) { | 113 const ClientSocketHandle* handle) { |
| 114 std::vector<MockConnectJob*>::iterator i; | 114 std::vector<MockConnectJob*>::iterator i; |
| 115 for (i = job_list_.begin(); i != job_list_.end(); ++i) { | 115 for (i = job_list_.begin(); i != job_list_.end(); ++i) { |
| 116 if ((*i)->CancelHandle(handle)) { | 116 if ((*i)->CancelHandle(handle)) { |
| 117 cancel_count_++; | 117 cancel_count_++; |
| 118 break; | 118 break; |
| 119 } | 119 } |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 359 |
| 360 requests_[0]->handle()->Reset(); | 360 requests_[0]->handle()->Reset(); |
| 361 requests_[1]->handle()->Reset(); | 361 requests_[1]->handle()->Reset(); |
| 362 } | 362 } |
| 363 | 363 |
| 364 // It would be nice to also test the timeouts in SOCKSClientSocketPool. | 364 // It would be nice to also test the timeouts in SOCKSClientSocketPool. |
| 365 | 365 |
| 366 } // namespace | 366 } // namespace |
| 367 | 367 |
| 368 } // namespace net | 368 } // namespace net |
| OLD | NEW |