| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/base/client_socket_handle.h" | 5 #include "net/base/client_socket_handle.h" |
| 6 | 6 |
| 7 #include "net/base/client_socket.h" | 7 #include "net/base/client_socket.h" |
| 8 #include "net/base/client_socket_pool.h" | 8 #include "net/base/client_socket_pool.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| 11 | 11 |
| 12 ClientSocketHandle::ClientSocketHandle(ClientSocketPool* pool) | 12 ClientSocketHandle::ClientSocketHandle(ClientSocketPool* pool) |
| 13 : pool_(pool), socket_(NULL) { | 13 : pool_(pool), socket_(NULL) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 ClientSocketHandle::~ClientSocketHandle() { | 16 ClientSocketHandle::~ClientSocketHandle() { |
| 17 Reset(); | 17 Reset(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 int ClientSocketHandle::Init(const std::string& group_name, | 20 int ClientSocketHandle::Init(const std::string& group_name, |
| 21 int priority, |
| 21 CompletionCallback* callback) { | 22 CompletionCallback* callback) { |
| 22 Reset(); | 23 Reset(); |
| 23 group_name_ = group_name; | 24 group_name_ = group_name; |
| 24 return pool_->RequestSocket(this, callback); | 25 return pool_->RequestSocket(this, priority, callback); |
| 25 } | 26 } |
| 26 | 27 |
| 27 void ClientSocketHandle::Reset() { | 28 void ClientSocketHandle::Reset() { |
| 28 if (group_name_.empty()) // Was Init called? | 29 if (group_name_.empty()) // Was Init called? |
| 29 return; | 30 return; |
| 30 if (socket_) { | 31 if (socket_) { |
| 31 pool_->ReleaseSocket(this); | 32 pool_->ReleaseSocket(this); |
| 32 socket_ = NULL; | 33 socket_ = NULL; |
| 33 } else { | 34 } else { |
| 34 pool_->CancelRequest(this); | 35 pool_->CancelRequest(this); |
| 35 } | 36 } |
| 36 group_name_.clear(); | 37 group_name_.clear(); |
| 37 } | 38 } |
| 38 | 39 |
| 39 } // namespace net | 40 } // namespace net |
| OLD | NEW |