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.h" | 5 #include "net/socket/client_socket.h" |
6 | 6 |
| 7 #include "base/field_trial.h" |
7 #include "base/histogram.h" | 8 #include "base/histogram.h" |
8 | 9 |
9 namespace net { | 10 namespace net { |
10 | 11 |
11 ClientSocket::ClientSocket() | 12 ClientSocket::ClientSocket() |
12 : was_ever_connected_(false), | 13 : was_ever_connected_(false), |
13 omnibox_speculation_(false), | 14 omnibox_speculation_(false), |
14 subresource_speculation_(false), | 15 subresource_speculation_(false), |
15 was_used_to_transmit_data_(false) {} | 16 was_used_to_transmit_data_(false) {} |
16 | 17 |
(...skipping 17 matching lines...) Expand all Loading... |
34 result = 2; | 35 result = 2; |
35 else if (was_ever_connected_) | 36 else if (was_ever_connected_) |
36 result = 1; | 37 result = 1; |
37 else | 38 else |
38 result = 0; // Never used, and not really connected. | 39 result = 0; // Never used, and not really connected. |
39 | 40 |
40 if (omnibox_speculation_) | 41 if (omnibox_speculation_) |
41 result += 3; | 42 result += 3; |
42 else if (subresource_speculation_) | 43 else if (subresource_speculation_) |
43 result += 6; | 44 result += 6; |
44 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization", result, 9); | 45 |
| 46 static const bool connect_backup_jobs_fieldtrial = |
| 47 FieldTrialList::Find("ConnnectBackupJobs") && |
| 48 !FieldTrialList::Find("ConnnectBackupJobs")->group_name().empty(); |
| 49 if (connect_backup_jobs_fieldtrial) { |
| 50 UMA_HISTOGRAM_ENUMERATION( |
| 51 FieldTrial::MakeName("Net.PreconnectUtilization", "ConnnectBackupJobs"), |
| 52 result, 9); |
| 53 } |
45 } | 54 } |
46 | 55 |
47 void ClientSocket::SetSubresourceSpeculation() { | 56 void ClientSocket::SetSubresourceSpeculation() { |
48 if (was_used_to_transmit_data_) | 57 if (was_used_to_transmit_data_) |
49 return; | 58 return; |
50 subresource_speculation_ = true; | 59 subresource_speculation_ = true; |
51 } | 60 } |
52 | 61 |
53 void ClientSocket::SetOmniboxSpeculation() { | 62 void ClientSocket::SetOmniboxSpeculation() { |
54 if (was_used_to_transmit_data_) | 63 if (was_used_to_transmit_data_) |
55 return; | 64 return; |
56 omnibox_speculation_ = true; | 65 omnibox_speculation_ = true; |
57 } | 66 } |
58 | 67 |
59 void ClientSocket::UpdateConnectivityState(bool is_reused) { | 68 void ClientSocket::UpdateConnectivityState(bool is_reused) { |
60 // Record if this connection has every actually connected successfully. | 69 // Record if this connection has every actually connected successfully. |
61 // Note that IsConnected() won't be defined at destruction time, so we need | 70 // Note that IsConnected() won't be defined at destruction time, so we need |
62 // to record this data now, while the derived class is present. | 71 // to record this data now, while the derived class is present. |
63 was_ever_connected_ |= IsConnected(); | 72 was_ever_connected_ |= IsConnected(); |
64 // A socket is_reused only after it has transmitted some data. | 73 // A socket is_reused only after it has transmitted some data. |
65 was_used_to_transmit_data_ |= is_reused; | 74 was_used_to_transmit_data_ |= is_reused; |
66 } | 75 } |
67 | 76 |
68 } // namespace net | 77 } // namespace net |
69 | 78 |
OLD | NEW |