OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/stream_socket.h" | 5 #include "net/socket/stream_socket.h" |
6 | 6 |
7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 void StreamSocket::UseHistory::set_was_ever_connected() { | 33 void StreamSocket::UseHistory::set_was_ever_connected() { |
34 DCHECK(!was_used_to_convey_data_); | 34 DCHECK(!was_used_to_convey_data_); |
35 was_ever_connected_ = true; | 35 was_ever_connected_ = true; |
36 } | 36 } |
37 | 37 |
38 void StreamSocket::UseHistory::set_was_used_to_convey_data() { | 38 void StreamSocket::UseHistory::set_was_used_to_convey_data() { |
39 DCHECK(was_ever_connected_); | 39 DCHECK(was_ever_connected_); |
40 was_used_to_convey_data_ = true; | 40 was_used_to_convey_data_ = true; |
41 } | 41 } |
42 | 42 |
43 | |
44 void StreamSocket::UseHistory::set_subresource_speculation() { | 43 void StreamSocket::UseHistory::set_subresource_speculation() { |
45 DCHECK(was_ever_connected_); | 44 DCHECK(was_ever_connected_); |
46 // TODO(jar): We should transition to marking a socket (or stream) at | 45 // TODO(jar): We should transition to marking a socket (or stream) at |
47 // construction time as being created for speculative reasons. This current | 46 // construction time as being created for speculative reasons. This current |
48 // approach of trying to track use of a socket to convey data can make | 47 // approach of trying to track use of a socket to convey data can make |
49 // mistakes when other sockets (such as ones sitting in the pool for a long | 48 // mistakes when other sockets (such as ones sitting in the pool for a long |
50 // time) are issued. Unused sockets can be left over when a when a set of | 49 // time) are issued. Unused sockets can be left over when a when a set of |
51 // connections to a host are made, and one is "unlucky" and takes so long to | 50 // connections to a host are made, and one is "unlucky" and takes so long to |
52 // complete a connection, that another socket is used, and recycled before a | 51 // complete a connection, that another socket is used, and recycled before a |
53 // second connection comes available. Similarly, re-try connections can leave | 52 // second connection comes available. Similarly, re-try connections can leave |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 result = 0; // Never used, and not really connected. | 91 result = 0; // Never used, and not really connected. |
93 | 92 |
94 if (omnibox_speculation_) | 93 if (omnibox_speculation_) |
95 result += 3; | 94 result += 3; |
96 else if (subresource_speculation_) | 95 else if (subresource_speculation_) |
97 result += 6; | 96 result += 6; |
98 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization2", result, 9); | 97 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization2", result, 9); |
99 } | 98 } |
100 | 99 |
101 } // namespace net | 100 } // namespace net |
OLD | NEW |