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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "net/base/load_timing_info.h" | |
12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
13 #include "net/socket/client_socket_pool.h" | 14 #include "net/socket/client_socket_pool.h" |
14 #include "net/socket/client_socket_pool_histograms.h" | 15 #include "net/socket/client_socket_pool_histograms.h" |
15 | 16 |
16 namespace net { | 17 namespace net { |
17 | 18 |
18 ClientSocketHandle::ClientSocketHandle() | 19 ClientSocketHandle::ClientSocketHandle() |
19 : is_initialized_(false), | 20 : is_initialized_(false), |
20 pool_(NULL), | 21 pool_(NULL), |
21 layered_pool_(NULL), | 22 layered_pool_(NULL), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 is_reused_ = false; | 56 is_reused_ = false; |
56 user_callback_.Reset(); | 57 user_callback_.Reset(); |
57 if (layered_pool_) { | 58 if (layered_pool_) { |
58 pool_->RemoveLayeredPool(layered_pool_); | 59 pool_->RemoveLayeredPool(layered_pool_); |
59 layered_pool_ = NULL; | 60 layered_pool_ = NULL; |
60 } | 61 } |
61 pool_ = NULL; | 62 pool_ = NULL; |
62 idle_time_ = base::TimeDelta(); | 63 idle_time_ = base::TimeDelta(); |
63 init_time_ = base::TimeTicks(); | 64 init_time_ = base::TimeTicks(); |
64 setup_time_ = base::TimeDelta(); | 65 setup_time_ = base::TimeDelta(); |
66 connect_timing_ = ConnectTiming(); | |
mmenke
2012/12/14 01:15:18
This will result in a URLRequest not giving correc
eroman
2012/12/14 04:08:34
I suggest additionally dumping these timings into
mmenke
2012/12/14 13:36:12
Where are you thinking of dumping them? With in-p
| |
65 pool_id_ = -1; | 67 pool_id_ = -1; |
66 } | 68 } |
67 | 69 |
68 void ClientSocketHandle::ResetErrorState() { | 70 void ClientSocketHandle::ResetErrorState() { |
69 is_ssl_error_ = false; | 71 is_ssl_error_ = false; |
70 ssl_error_response_info_ = HttpResponseInfo(); | 72 ssl_error_response_info_ = HttpResponseInfo(); |
71 pending_http_proxy_connection_.reset(); | 73 pending_http_proxy_connection_.reset(); |
72 } | 74 } |
73 | 75 |
74 LoadState ClientSocketHandle::GetLoadState() const { | 76 LoadState ClientSocketHandle::GetLoadState() const { |
(...skipping 21 matching lines...) Expand all Loading... | |
96 | 98 |
97 void ClientSocketHandle::RemoveLayeredPool(LayeredPool* layered_pool) { | 99 void ClientSocketHandle::RemoveLayeredPool(LayeredPool* layered_pool) { |
98 CHECK(layered_pool); | 100 CHECK(layered_pool); |
99 CHECK(layered_pool_); | 101 CHECK(layered_pool_); |
100 if (pool_) { | 102 if (pool_) { |
101 pool_->RemoveLayeredPool(layered_pool); | 103 pool_->RemoveLayeredPool(layered_pool); |
102 layered_pool_ = NULL; | 104 layered_pool_ = NULL; |
103 } | 105 } |
104 } | 106 } |
105 | 107 |
108 bool ClientSocketHandle::GetLoadTimingInfo( | |
109 bool is_reused, | |
110 LoadTimingInfo* load_timing_info) const { | |
111 // Only return load timing information when there's a socket. | |
112 if (!socket_) | |
113 return false; | |
114 | |
115 load_timing_info->socket_log_id = socket_->NetLog().source().id; | |
116 load_timing_info->socket_reused = is_reused; | |
117 | |
118 // No times if the socket is reused. | |
119 if (is_reused) | |
120 return true; | |
121 | |
122 load_timing_info->dns_start = connect_timing_.dns_start; | |
123 load_timing_info->dns_end = connect_timing_.dns_end; | |
124 load_timing_info->connect_start = connect_timing_.connect_start; | |
125 load_timing_info->connect_end = connect_timing_.connect_end; | |
126 load_timing_info->ssl_start = connect_timing_.ssl_start; | |
127 load_timing_info->ssl_end = connect_timing_.ssl_end; | |
128 return true; | |
129 } | |
130 | |
106 void ClientSocketHandle::OnIOComplete(int result) { | 131 void ClientSocketHandle::OnIOComplete(int result) { |
107 CompletionCallback callback = user_callback_; | 132 CompletionCallback callback = user_callback_; |
108 user_callback_.Reset(); | 133 user_callback_.Reset(); |
109 HandleInitCompletion(result); | 134 HandleInitCompletion(result); |
110 callback.Run(result); | 135 callback.Run(result); |
111 } | 136 } |
112 | 137 |
113 void ClientSocketHandle::HandleInitCompletion(int result) { | 138 void ClientSocketHandle::HandleInitCompletion(int result) { |
114 CHECK_NE(ERR_IO_PENDING, result); | 139 CHECK_NE(ERR_IO_PENDING, result); |
115 if (result != OK) { | 140 if (result != OK) { |
(...skipping 28 matching lines...) Expand all Loading... | |
144 // TODO(eroman): This logging is not complete, in particular set_socket() and | 169 // 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 | 170 // release() socket. It ends up working though, since those methods are being |
146 // used to layer sockets (and the destination sources are the same). | 171 // used to layer sockets (and the destination sources are the same). |
147 DCHECK(socket_.get()); | 172 DCHECK(socket_.get()); |
148 socket_->NetLog().BeginEvent( | 173 socket_->NetLog().BeginEvent( |
149 NetLog::TYPE_SOCKET_IN_USE, | 174 NetLog::TYPE_SOCKET_IN_USE, |
150 requesting_source_.ToEventParametersCallback()); | 175 requesting_source_.ToEventParametersCallback()); |
151 } | 176 } |
152 | 177 |
153 } // namespace net | 178 } // namespace net |
OLD | NEW |