OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/histogram.h" | 8 #include "base/histogram.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 void ClientSocketHandle::Reset() { | 26 void ClientSocketHandle::Reset() { |
27 ResetInternal(true); | 27 ResetInternal(true); |
28 } | 28 } |
29 | 29 |
30 void ClientSocketHandle::ResetInternal(bool cancel) { | 30 void ClientSocketHandle::ResetInternal(bool cancel) { |
31 if (group_name_.empty()) // Was Init called? | 31 if (group_name_.empty()) // Was Init called? |
32 return; | 32 return; |
33 if (socket_.get()) { | 33 if (socket_.get()) { |
34 // Because of http://crbug.com/37810 we may not have a pool, but have | 34 // Because of http://crbug.com/37810 we may not have a pool, but have |
35 // just a raw socket. | 35 // just a raw socket. |
| 36 socket_->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE, NULL); |
36 if (pool_) | 37 if (pool_) |
37 // If we've still got a socket, release it back to the ClientSocketPool so | 38 // If we've still got a socket, release it back to the ClientSocketPool so |
38 // it can be deleted or reused. | 39 // it can be deleted or reused. |
39 pool_->ReleaseSocket(group_name_, release_socket()); | 40 pool_->ReleaseSocket(group_name_, release_socket()); |
40 } else if (cancel) { | 41 } else if (cancel) { |
41 // If we did not get initialized yet, so we've got a socket request pending. | 42 // If we did not get initialized yet, so we've got a socket request pending. |
42 // Cancel it. | 43 // Cancel it. |
43 pool_->CancelRequest(group_name_, this); | 44 pool_->CancelRequest(group_name_, this); |
44 } | 45 } |
45 group_name_.clear(); | 46 group_name_.clear(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 case ClientSocketHandle::UNUSED_IDLE: | 86 case ClientSocketHandle::UNUSED_IDLE: |
86 histograms->AddUnusedIdleTime(idle_time()); | 87 histograms->AddUnusedIdleTime(idle_time()); |
87 break; | 88 break; |
88 case ClientSocketHandle::REUSED_IDLE: | 89 case ClientSocketHandle::REUSED_IDLE: |
89 histograms->AddReusedIdleTime(idle_time()); | 90 histograms->AddReusedIdleTime(idle_time()); |
90 break; | 91 break; |
91 default: | 92 default: |
92 NOTREACHED(); | 93 NOTREACHED(); |
93 break; | 94 break; |
94 } | 95 } |
| 96 |
| 97 // Broadcast that the socket has been acquired. |
| 98 // TODO(eroman): This logging is not complete, in particular set_socket() and |
| 99 // release() socket. It ends up working though, since those methods are being |
| 100 // used to layer sockets (and the destination sources are the same). |
| 101 DCHECK(socket_.get()); |
| 102 socket_->NetLog().BeginEvent( |
| 103 NetLog::TYPE_SOCKET_IN_USE, |
| 104 new NetLogSourceParameter("source_dependency", requesting_source_)); |
95 } | 105 } |
96 | 106 |
97 } // namespace net | 107 } // namespace net |
OLD | NEW |