| 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/socket/client_socket_handle.h" | 5 #include "net/socket/client_socket_handle.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/socket/client_socket.h" | 10 #include "net/socket/client_socket.h" |
| 11 #include "net/socket/client_socket_pool.h" | 11 #include "net/socket/client_socket_pool.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 | 14 |
| 15 ClientSocketHandle::ClientSocketHandle(ClientSocketPool* pool) | 15 ClientSocketHandle::ClientSocketHandle(ClientSocketPool* pool) |
| 16 : pool_(pool), | 16 : pool_(pool), |
| 17 socket_(NULL), | 17 socket_(NULL), |
| 18 is_reused_(false), | 18 is_reused_(false), |
| 19 ALLOW_THIS_IN_INITIALIZER_LIST( | 19 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 20 callback_(this, &ClientSocketHandle::OnIOComplete)) {} | 20 callback_(this, &ClientSocketHandle::OnIOComplete)) {} |
| 21 | 21 |
| 22 ClientSocketHandle::~ClientSocketHandle() { | 22 ClientSocketHandle::~ClientSocketHandle() { |
| 23 Reset(); | 23 Reset(); |
| 24 } | 24 } |
| 25 | 25 |
| 26 int ClientSocketHandle::Init(const std::string& group_name, | 26 int ClientSocketHandle::Init(LoadLog* load_log, |
| 27 const std::string& group_name, |
| 27 const HostResolver::RequestInfo& resolve_info, | 28 const HostResolver::RequestInfo& resolve_info, |
| 28 int priority, | 29 int priority, |
| 29 CompletionCallback* callback) { | 30 CompletionCallback* callback) { |
| 30 CHECK(!group_name.empty()); | 31 CHECK(!group_name.empty()); |
| 31 ResetInternal(true); | 32 ResetInternal(true); |
| 32 group_name_ = group_name; | 33 group_name_ = group_name; |
| 33 int rv = pool_->RequestSocket( | 34 int rv = pool_->RequestSocket( |
| 34 group_name, resolve_info, priority, this, &callback_); | 35 load_log, group_name, resolve_info, priority, this, &callback_); |
| 35 if (rv == ERR_IO_PENDING) { | 36 if (rv == ERR_IO_PENDING) { |
| 36 user_callback_ = callback; | 37 user_callback_ = callback; |
| 37 } else { | 38 } else { |
| 38 HandleInitCompletion(rv); | 39 HandleInitCompletion(rv); |
| 39 } | 40 } |
| 40 return rv; | 41 return rv; |
| 41 } | 42 } |
| 42 | 43 |
| 43 void ClientSocketHandle::Reset() { | 44 void ClientSocketHandle::Reset() { |
| 44 ResetInternal(true); | 45 ResetInternal(true); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 74 callback->Run(result); | 75 callback->Run(result); |
| 75 } | 76 } |
| 76 | 77 |
| 77 void ClientSocketHandle::HandleInitCompletion(int result) { | 78 void ClientSocketHandle::HandleInitCompletion(int result) { |
| 78 CHECK(ERR_IO_PENDING != result); | 79 CHECK(ERR_IO_PENDING != result); |
| 79 if (result != OK) | 80 if (result != OK) |
| 80 ResetInternal(false); // The request failed, so there's nothing to cancel. | 81 ResetInternal(false); // The request failed, so there's nothing to cancel. |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace net | 84 } // namespace net |
| OLD | NEW |