Chromium Code Reviews| 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_pool_base.h" | 5 #include "net/socket/client_socket_pool_base.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram_macros.h" | |
| 14 #include "base/single_thread_task_runner.h" | 15 #include "base/single_thread_task_runner.h" |
| 15 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "base/trace_event/trace_event.h" | 20 #include "base/trace_event/trace_event.h" |
| 20 #include "base/values.h" | 21 #include "base/values.h" |
| 21 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
| 22 #include "net/log/net_log.h" | 23 #include "net/log/net_log.h" |
| 23 | 24 |
| (...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 base::TimeDelta idle_time, | 969 base::TimeDelta idle_time, |
| 969 Group* group, | 970 Group* group, |
| 970 const BoundNetLog& net_log) { | 971 const BoundNetLog& net_log) { |
| 971 DCHECK(socket); | 972 DCHECK(socket); |
| 972 handle->SetSocket(std::move(socket)); | 973 handle->SetSocket(std::move(socket)); |
| 973 handle->set_reuse_type(reuse_type); | 974 handle->set_reuse_type(reuse_type); |
| 974 handle->set_idle_time(idle_time); | 975 handle->set_idle_time(idle_time); |
| 975 handle->set_pool_id(pool_generation_number_); | 976 handle->set_pool_id(pool_generation_number_); |
| 976 handle->set_connect_timing(connect_timing); | 977 handle->set_connect_timing(connect_timing); |
| 977 | 978 |
| 978 if (handle->is_reused()) { | 979 if (reuse_type == ClientSocketHandle::REUSED_IDLE) { |
|
mmenke
2016/06/21 21:08:32
This is the same as before, just switched to be co
| |
| 979 net_log.AddEvent( | 980 net_log.AddEvent( |
| 980 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, | 981 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, |
| 981 NetLog::IntCallback("idle_ms", | 982 NetLog::IntCallback("idle_ms", |
| 982 static_cast<int>(idle_time.InMilliseconds()))); | 983 static_cast<int>(idle_time.InMilliseconds()))); |
| 984 | |
| 985 UMA_HISTOGRAM_COUNTS_1000("Net.Socket.IdleSocketReuseTime", | |
|
Charlie Harrison
2016/06/21 21:23:20
Any reason not to do this in milliseconds? Seems l
mmenke
2016/06/21 21:34:45
Mostly to make it more readable. "28" is more rea
Charlie Harrison
2016/06/21 21:40:20
Gotcha, thanks for the clarification. Keeping in s
| |
| 986 idle_time.InSeconds()); | |
| 983 } | 987 } |
| 984 | 988 |
| 985 net_log.AddEvent( | 989 if (reuse_type != ClientSocketHandle::UNUSED) { |
|
Charlie Harrison
2016/06/21 21:23:20
Why remove this?
mmenke
2016/06/21 21:34:45
Thanks for catching that! Mistake due to repeated
| |
| 986 NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, | 990 // The socket being handed out is no longer considered idle, but was |
| 987 handle->socket()->NetLog().source().ToEventParametersCallback()); | 991 // considered idle until just before this method was called. |
| 992 UMA_HISTOGRAM_COUNTS_100("Net.Socket.NumIdleSockets", | |
|
Charlie Harrison
2016/06/21 21:23:20
suggestion: Consider bumping this from 100 to some
mmenke
2016/06/21 21:34:45
If we really have 100 idle sockets around, I don't
Charlie Harrison
2016/06/21 21:40:20
Yeah my comment was mostly due to your observation
mmenke
2016/06/21 21:44:46
I suspect we'll see it, but I suspect if we have t
Charlie Harrison
2016/06/21 21:52:07
Good point, though we would like to see what the e
| |
| 993 idle_socket_count() + 1); | |
| 994 } | |
| 988 | 995 |
| 989 handed_out_socket_count_++; | 996 handed_out_socket_count_++; |
| 990 group->IncrementActiveSocketCount(); | 997 group->IncrementActiveSocketCount(); |
| 991 } | 998 } |
| 992 | 999 |
| 993 void ClientSocketPoolBaseHelper::AddIdleSocket( | 1000 void ClientSocketPoolBaseHelper::AddIdleSocket( |
| 994 std::unique_ptr<StreamSocket> socket, | 1001 std::unique_ptr<StreamSocket> socket, |
| 995 Group* group) { | 1002 Group* group) { |
| 996 DCHECK(socket); | 1003 DCHECK(socket); |
| 997 IdleSocket idle_socket; | 1004 IdleSocket idle_socket; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1309 // If there are no more requests, kill the backup timer. | 1316 // If there are no more requests, kill the backup timer. |
| 1310 if (pending_requests_.empty()) | 1317 if (pending_requests_.empty()) |
| 1311 backup_job_timer_.Stop(); | 1318 backup_job_timer_.Stop(); |
| 1312 request->CrashIfInvalid(); | 1319 request->CrashIfInvalid(); |
| 1313 return request; | 1320 return request; |
| 1314 } | 1321 } |
| 1315 | 1322 |
| 1316 } // namespace internal | 1323 } // namespace internal |
| 1317 | 1324 |
| 1318 } // namespace net | 1325 } // namespace net |
| OLD | NEW |