| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/socket/client_socket_pool.h" | 14 #include "net/socket/client_socket_pool.h" |
| 15 | 15 |
| 16 #include "base/trace_event/trace_event.h" |
| 17 |
| 16 namespace net { | 18 namespace net { |
| 17 | 19 |
| 18 ClientSocketHandle::ClientSocketHandle() | 20 ClientSocketHandle::ClientSocketHandle() |
| 19 : is_initialized_(false), | 21 : is_initialized_(false), |
| 20 pool_(NULL), | 22 pool_(NULL), |
| 21 higher_pool_(NULL), | 23 higher_pool_(NULL), |
| 22 reuse_type_(ClientSocketHandle::UNUSED), | 24 reuse_type_(ClientSocketHandle::UNUSED), |
| 23 callback_(base::Bind(&ClientSocketHandle::OnIOComplete, | 25 callback_(base::Bind(&ClientSocketHandle::OnIOComplete, |
| 24 base::Unretained(this))), | 26 base::Unretained(this))), |
| 25 is_ssl_error_(false), | 27 is_ssl_error_(false), |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 135 |
| 134 load_timing_info->connect_timing = connect_timing_; | 136 load_timing_info->connect_timing = connect_timing_; |
| 135 return true; | 137 return true; |
| 136 } | 138 } |
| 137 | 139 |
| 138 void ClientSocketHandle::SetSocket(scoped_ptr<StreamSocket> s) { | 140 void ClientSocketHandle::SetSocket(scoped_ptr<StreamSocket> s) { |
| 139 socket_ = std::move(s); | 141 socket_ = std::move(s); |
| 140 } | 142 } |
| 141 | 143 |
| 142 void ClientSocketHandle::OnIOComplete(int result) { | 144 void ClientSocketHandle::OnIOComplete(int result) { |
| 145 TRACE_EVENT0("net", "net::ClientSocketHandle::OnIOComplete"); |
| 143 CompletionCallback callback = user_callback_; | 146 CompletionCallback callback = user_callback_; |
| 144 user_callback_.Reset(); | 147 user_callback_.Reset(); |
| 145 HandleInitCompletion(result); | 148 HandleInitCompletion(result); |
| 146 callback.Run(result); | 149 callback.Run(result); |
| 147 } | 150 } |
| 148 | 151 |
| 149 scoped_ptr<StreamSocket> ClientSocketHandle::PassSocket() { | 152 scoped_ptr<StreamSocket> ClientSocketHandle::PassSocket() { |
| 150 return std::move(socket_); | 153 return std::move(socket_); |
| 151 } | 154 } |
| 152 | 155 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 167 // TODO(eroman): This logging is not complete, in particular set_socket() and | 170 // TODO(eroman): This logging is not complete, in particular set_socket() and |
| 168 // release() socket. It ends up working though, since those methods are being | 171 // release() socket. It ends up working though, since those methods are being |
| 169 // used to layer sockets (and the destination sources are the same). | 172 // used to layer sockets (and the destination sources are the same). |
| 170 DCHECK(socket_.get()); | 173 DCHECK(socket_.get()); |
| 171 socket_->NetLog().BeginEvent( | 174 socket_->NetLog().BeginEvent( |
| 172 NetLog::TYPE_SOCKET_IN_USE, | 175 NetLog::TYPE_SOCKET_IN_USE, |
| 173 requesting_source_.ToEventParametersCallback()); | 176 requesting_source_.ToEventParametersCallback()); |
| 174 } | 177 } |
| 175 | 178 |
| 176 } // namespace net | 179 } // namespace net |
| OLD | NEW |