| 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/log/net_log_event_type.h" | 15 #include "net/log/net_log_event_type.h" |
| 16 #include "net/log/trace_constants.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), |
| 25 callback_(base::Bind(&ClientSocketHandle::OnIOComplete, | 26 callback_(base::Bind(&ClientSocketHandle::OnIOComplete, |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 133 |
| 133 load_timing_info->connect_timing = connect_timing_; | 134 load_timing_info->connect_timing = connect_timing_; |
| 134 return true; | 135 return true; |
| 135 } | 136 } |
| 136 | 137 |
| 137 void ClientSocketHandle::SetSocket(std::unique_ptr<StreamSocket> s) { | 138 void ClientSocketHandle::SetSocket(std::unique_ptr<StreamSocket> s) { |
| 138 socket_ = std::move(s); | 139 socket_ = std::move(s); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void ClientSocketHandle::OnIOComplete(int result) { | 142 void ClientSocketHandle::OnIOComplete(int result) { |
| 142 TRACE_EVENT0("net", "ClientSocketHandle::OnIOComplete"); | 143 TRACE_EVENT0(kNetTracingCategory, "ClientSocketHandle::OnIOComplete"); |
| 143 CompletionCallback callback = user_callback_; | 144 CompletionCallback callback = user_callback_; |
| 144 user_callback_.Reset(); | 145 user_callback_.Reset(); |
| 145 HandleInitCompletion(result); | 146 HandleInitCompletion(result); |
| 146 callback.Run(result); | 147 callback.Run(result); |
| 147 } | 148 } |
| 148 | 149 |
| 149 std::unique_ptr<StreamSocket> ClientSocketHandle::PassSocket() { | 150 std::unique_ptr<StreamSocket> ClientSocketHandle::PassSocket() { |
| 150 return std::move(socket_); | 151 return std::move(socket_); |
| 151 } | 152 } |
| 152 | 153 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 166 // Broadcast that the socket has been acquired. | 167 // Broadcast that the socket has been acquired. |
| 167 // TODO(eroman): This logging is not complete, in particular set_socket() and | 168 // 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 | 169 // release() socket. It ends up working though, since those methods are being |
| 169 // used to layer sockets (and the destination sources are the same). | 170 // used to layer sockets (and the destination sources are the same). |
| 170 DCHECK(socket_.get()); | 171 DCHECK(socket_.get()); |
| 171 socket_->NetLog().BeginEvent(NetLogEventType::SOCKET_IN_USE, | 172 socket_->NetLog().BeginEvent(NetLogEventType::SOCKET_IN_USE, |
| 172 requesting_source_.ToEventParametersCallback()); | 173 requesting_source_.ToEventParametersCallback()); |
| 173 } | 174 } |
| 174 | 175 |
| 175 } // namespace net | 176 } // namespace net |
| OLD | NEW |