| 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 "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 14 #include "net/base/net_errors.h" | 14 #include "net/base/net_errors.h" |
| 15 #include "net/base/trace_constants.h" |
| 15 #include "net/log/net_log_event_type.h" | 16 #include "net/log/net_log_event_type.h" |
| 16 #include "net/socket/client_socket_pool.h" | 17 #include "net/socket/client_socket_pool.h" |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 ClientSocketHandle::ClientSocketHandle() | 21 ClientSocketHandle::ClientSocketHandle() |
| 21 : is_initialized_(false), | 22 : is_initialized_(false), |
| 22 pool_(NULL), | 23 pool_(NULL), |
| 23 higher_pool_(NULL), | 24 higher_pool_(NULL), |
| 24 reuse_type_(ClientSocketHandle::UNUSED), | 25 reuse_type_(ClientSocketHandle::UNUSED), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 131 |
| 131 load_timing_info->connect_timing = connect_timing_; | 132 load_timing_info->connect_timing = connect_timing_; |
| 132 return true; | 133 return true; |
| 133 } | 134 } |
| 134 | 135 |
| 135 void ClientSocketHandle::SetSocket(std::unique_ptr<StreamSocket> s) { | 136 void ClientSocketHandle::SetSocket(std::unique_ptr<StreamSocket> s) { |
| 136 socket_ = std::move(s); | 137 socket_ = std::move(s); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void ClientSocketHandle::OnIOComplete(int result) { | 140 void ClientSocketHandle::OnIOComplete(int result) { |
| 140 TRACE_EVENT0("net", "ClientSocketHandle::OnIOComplete"); | 141 TRACE_EVENT0(kNetTracingCategory, "ClientSocketHandle::OnIOComplete"); |
| 141 CompletionCallback callback = user_callback_; | 142 CompletionCallback callback = user_callback_; |
| 142 user_callback_.Reset(); | 143 user_callback_.Reset(); |
| 143 HandleInitCompletion(result); | 144 HandleInitCompletion(result); |
| 144 callback.Run(result); | 145 callback.Run(result); |
| 145 } | 146 } |
| 146 | 147 |
| 147 std::unique_ptr<StreamSocket> ClientSocketHandle::PassSocket() { | 148 std::unique_ptr<StreamSocket> ClientSocketHandle::PassSocket() { |
| 148 return std::move(socket_); | 149 return std::move(socket_); |
| 149 } | 150 } |
| 150 | 151 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 163 // Broadcast that the socket has been acquired. | 164 // Broadcast that the socket has been acquired. |
| 164 // TODO(eroman): This logging is not complete, in particular set_socket() and | 165 // TODO(eroman): This logging is not complete, in particular set_socket() and |
| 165 // release() socket. It ends up working though, since those methods are being | 166 // release() socket. It ends up working though, since those methods are being |
| 166 // used to layer sockets (and the destination sources are the same). | 167 // used to layer sockets (and the destination sources are the same). |
| 167 DCHECK(socket_.get()); | 168 DCHECK(socket_.get()); |
| 168 socket_->NetLog().BeginEvent(NetLogEventType::SOCKET_IN_USE, | 169 socket_->NetLog().BeginEvent(NetLogEventType::SOCKET_IN_USE, |
| 169 requesting_source_.ToEventParametersCallback()); | 170 requesting_source_.ToEventParametersCallback()); |
| 170 } | 171 } |
| 171 | 172 |
| 172 } // namespace net | 173 } // namespace net |
| OLD | NEW |