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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 is_reused_ = false; | 55 is_reused_ = false; |
56 user_callback_.Reset(); | 56 user_callback_.Reset(); |
57 if (layered_pool_) { | 57 if (layered_pool_) { |
58 pool_->RemoveLayeredPool(layered_pool_); | 58 pool_->RemoveLayeredPool(layered_pool_); |
59 layered_pool_ = NULL; | 59 layered_pool_ = NULL; |
60 } | 60 } |
61 pool_ = NULL; | 61 pool_ = NULL; |
62 idle_time_ = base::TimeDelta(); | 62 idle_time_ = base::TimeDelta(); |
63 init_time_ = base::TimeTicks(); | 63 init_time_ = base::TimeTicks(); |
64 setup_time_ = base::TimeDelta(); | 64 setup_time_ = base::TimeDelta(); |
| 65 connect_timing_ = LoadTimingInfo::ConnectTiming(); |
65 pool_id_ = -1; | 66 pool_id_ = -1; |
66 } | 67 } |
67 | 68 |
68 void ClientSocketHandle::ResetErrorState() { | 69 void ClientSocketHandle::ResetErrorState() { |
69 is_ssl_error_ = false; | 70 is_ssl_error_ = false; |
70 ssl_error_response_info_ = HttpResponseInfo(); | 71 ssl_error_response_info_ = HttpResponseInfo(); |
71 pending_http_proxy_connection_.reset(); | 72 pending_http_proxy_connection_.reset(); |
72 } | 73 } |
73 | 74 |
74 LoadState ClientSocketHandle::GetLoadState() const { | 75 LoadState ClientSocketHandle::GetLoadState() const { |
(...skipping 21 matching lines...) Expand all Loading... |
96 | 97 |
97 void ClientSocketHandle::RemoveLayeredPool(LayeredPool* layered_pool) { | 98 void ClientSocketHandle::RemoveLayeredPool(LayeredPool* layered_pool) { |
98 CHECK(layered_pool); | 99 CHECK(layered_pool); |
99 CHECK(layered_pool_); | 100 CHECK(layered_pool_); |
100 if (pool_) { | 101 if (pool_) { |
101 pool_->RemoveLayeredPool(layered_pool); | 102 pool_->RemoveLayeredPool(layered_pool); |
102 layered_pool_ = NULL; | 103 layered_pool_ = NULL; |
103 } | 104 } |
104 } | 105 } |
105 | 106 |
| 107 bool ClientSocketHandle::GetLoadTimingInfo( |
| 108 bool is_reused, |
| 109 LoadTimingInfo* load_timing_info) const { |
| 110 // Only return load timing information when there's a socket. |
| 111 if (!socket_) |
| 112 return false; |
| 113 |
| 114 load_timing_info->socket_log_id = socket_->NetLog().source().id; |
| 115 load_timing_info->socket_reused = is_reused; |
| 116 |
| 117 // No times if the socket is reused. |
| 118 if (is_reused) |
| 119 return true; |
| 120 |
| 121 load_timing_info->connect_timing = connect_timing_; |
| 122 return true; |
| 123 } |
| 124 |
106 void ClientSocketHandle::OnIOComplete(int result) { | 125 void ClientSocketHandle::OnIOComplete(int result) { |
107 CompletionCallback callback = user_callback_; | 126 CompletionCallback callback = user_callback_; |
108 user_callback_.Reset(); | 127 user_callback_.Reset(); |
109 HandleInitCompletion(result); | 128 HandleInitCompletion(result); |
110 callback.Run(result); | 129 callback.Run(result); |
111 } | 130 } |
112 | 131 |
113 void ClientSocketHandle::HandleInitCompletion(int result) { | 132 void ClientSocketHandle::HandleInitCompletion(int result) { |
114 CHECK_NE(ERR_IO_PENDING, result); | 133 CHECK_NE(ERR_IO_PENDING, result); |
115 if (result != OK) { | 134 if (result != OK) { |
(...skipping 28 matching lines...) Expand all Loading... |
144 // TODO(eroman): This logging is not complete, in particular set_socket() and | 163 // 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 | 164 // release() socket. It ends up working though, since those methods are being |
146 // used to layer sockets (and the destination sources are the same). | 165 // used to layer sockets (and the destination sources are the same). |
147 DCHECK(socket_.get()); | 166 DCHECK(socket_.get()); |
148 socket_->NetLog().BeginEvent( | 167 socket_->NetLog().BeginEvent( |
149 NetLog::TYPE_SOCKET_IN_USE, | 168 NetLog::TYPE_SOCKET_IN_USE, |
150 requesting_source_.ToEventParametersCallback()); | 169 requesting_source_.ToEventParametersCallback()); |
151 } | 170 } |
152 | 171 |
153 } // namespace net | 172 } // namespace net |
OLD | NEW |