| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 52 socket_.reset(NULL); | 52 socket_.reset(); |
| 53 handle_ = NULL; | 53 handle_ = NULL; |
| 54 user_callback_ = NULL; | 54 user_callback_ = NULL; |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 void OnConnect(int rv) { | 59 void OnConnect(int rv) { |
| 60 if (!socket_.get()) | 60 if (!socket_.get()) |
| 61 return; | 61 return; |
| 62 if (rv == OK) | 62 if (rv == OK) |
| 63 handle_->set_socket(socket_.get()); | 63 handle_->set_socket(socket_.release()); |
| 64 else | 64 else |
| 65 socket_.reset(NULL); | 65 socket_.reset(); |
| 66 | 66 |
| 67 socket_.release(); | |
| 68 handle_ = NULL; | 67 handle_ = NULL; |
| 69 | 68 |
| 70 if (user_callback_) { | 69 if (user_callback_) { |
| 71 CompletionCallback* callback = user_callback_; | 70 CompletionCallback* callback = user_callback_; |
| 72 user_callback_ = NULL; | 71 user_callback_ = NULL; |
| 73 callback->Run(rv); | 72 callback->Run(rv); |
| 74 } | 73 } |
| 75 } | 74 } |
| 76 | 75 |
| 77 scoped_ptr<ClientSocket> socket_; | 76 scoped_ptr<ClientSocket> socket_; |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 | 364 |
| 366 requests_[0]->handle()->Reset(); | 365 requests_[0]->handle()->Reset(); |
| 367 requests_[1]->handle()->Reset(); | 366 requests_[1]->handle()->Reset(); |
| 368 } | 367 } |
| 369 | 368 |
| 370 // It would be nice to also test the timeouts in SOCKSClientSocketPool. | 369 // It would be nice to also test the timeouts in SOCKSClientSocketPool. |
| 371 | 370 |
| 372 } // namespace | 371 } // namespace |
| 373 | 372 |
| 374 } // namespace net | 373 } // namespace net |
| OLD | NEW |