| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(), net_log.net_log()); | 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 handle->set_pool_id(1); |
| 109 return job->Connect(); | 110 return job->Connect(); |
| 110 } | 111 } |
| 111 | 112 |
| 112 virtual void CancelRequest(const std::string& group_name, | 113 virtual void CancelRequest(const std::string& group_name, |
| 113 const ClientSocketHandle* handle) { | 114 const ClientSocketHandle* handle) { |
| 114 std::vector<MockConnectJob*>::iterator i; | 115 std::vector<MockConnectJob*>::iterator i; |
| 115 for (i = job_list_.begin(); i != job_list_.end(); ++i) { | 116 for (i = job_list_.begin(); i != job_list_.end(); ++i) { |
| 116 if ((*i)->CancelHandle(handle)) { | 117 if ((*i)->CancelHandle(handle)) { |
| 117 cancel_count_++; | 118 cancel_count_++; |
| 118 break; | 119 break; |
| 119 } | 120 } |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 | 123 |
| 123 virtual void ReleaseSocket(const std::string& group_name, | 124 virtual void ReleaseSocket(const std::string& group_name, |
| 124 ClientSocket* socket) { | 125 ClientSocket* socket, |
| 126 int id) { |
| 127 EXPECT_EQ(1, id); |
| 125 release_count_++; | 128 release_count_++; |
| 126 delete socket; | 129 delete socket; |
| 127 } | 130 } |
| 128 | 131 |
| 129 protected: | 132 protected: |
| 130 virtual ~MockTCPClientSocketPool() {} | 133 virtual ~MockTCPClientSocketPool() {} |
| 131 | 134 |
| 132 private: | 135 private: |
| 133 ClientSocketFactory* client_socket_factory_; | 136 ClientSocketFactory* client_socket_factory_; |
| 134 int release_count_; | 137 int release_count_; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 372 |
| 370 requests_[0]->handle()->Reset(); | 373 requests_[0]->handle()->Reset(); |
| 371 requests_[1]->handle()->Reset(); | 374 requests_[1]->handle()->Reset(); |
| 372 } | 375 } |
| 373 | 376 |
| 374 // It would be nice to also test the timeouts in SOCKSClientSocketPool. | 377 // It would be nice to also test the timeouts in SOCKSClientSocketPool. |
| 375 | 378 |
| 376 } // namespace | 379 } // namespace |
| 377 | 380 |
| 378 } // namespace net | 381 } // namespace net |
| OLD | NEW |