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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 ResetInternal(true); | 33 ResetInternal(true); |
34 ResetErrorState(); | 34 ResetErrorState(); |
35 } | 35 } |
36 | 36 |
37 void ClientSocketHandle::ResetInternal(bool cancel) { | 37 void ClientSocketHandle::ResetInternal(bool cancel) { |
38 if (group_name_.empty()) // Was Init called? | 38 if (group_name_.empty()) // Was Init called? |
39 return; | 39 return; |
40 if (is_initialized()) { | 40 if (is_initialized()) { |
41 // Because of http://crbug.com/37810 we may not have a pool, but have | 41 // Because of http://crbug.com/37810 we may not have a pool, but have |
42 // just a raw socket. | 42 // just a raw socket. |
43 socket_->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE, NULL); | 43 socket_->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE); |
44 if (pool_) | 44 if (pool_) |
45 // If we've still got a socket, release it back to the ClientSocketPool so | 45 // If we've still got a socket, release it back to the ClientSocketPool so |
46 // it can be deleted or reused. | 46 // it can be deleted or reused. |
47 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); | 47 pool_->ReleaseSocket(group_name_, release_socket(), pool_id_); |
48 } else if (cancel) { | 48 } else if (cancel) { |
49 // If we did not get initialized yet, we've got a socket request pending. | 49 // If we did not get initialized yet, we've got a socket request pending. |
50 // Cancel it. | 50 // Cancel it. |
51 pool_->CancelRequest(group_name_, this); | 51 pool_->CancelRequest(group_name_, this); |
52 } | 52 } |
53 is_initialized_ = false; | 53 is_initialized_ = false; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 break; | 140 break; |
141 } | 141 } |
142 | 142 |
143 // Broadcast that the socket has been acquired. | 143 // Broadcast that the socket has been acquired. |
144 // TODO(eroman): This logging is not complete, in particular set_socket() and | 144 // TODO(eroman): This logging is not complete, in particular set_socket() and |
145 // release() socket. It ends up working though, since those methods are being | 145 // release() socket. It ends up working though, since those methods are being |
146 // used to layer sockets (and the destination sources are the same). | 146 // used to layer sockets (and the destination sources are the same). |
147 DCHECK(socket_.get()); | 147 DCHECK(socket_.get()); |
148 socket_->NetLog().BeginEvent( | 148 socket_->NetLog().BeginEvent( |
149 NetLog::TYPE_SOCKET_IN_USE, | 149 NetLog::TYPE_SOCKET_IN_USE, |
150 make_scoped_refptr(new NetLogSourceParameter( | 150 requesting_source_.ToEventParametersCallback()); |
151 "source_dependency", requesting_source_))); | |
152 } | 151 } |
153 | 152 |
154 } // namespace net | 153 } // namespace net |
OLD | NEW |