Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Side by Side Diff: net/socket/client_socket.cc

Issue 6339012: More net/ method ordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More done while waiting for previous patch to clear Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | net/socket/client_socket_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/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/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 } 59 }
60 60
61 void ClientSocket::UseHistory::Reset() { 61 void ClientSocket::UseHistory::Reset() {
62 EmitPreconnectionHistograms(); 62 EmitPreconnectionHistograms();
63 was_ever_connected_ = false; 63 was_ever_connected_ = false;
64 was_used_to_convey_data_ = false; 64 was_used_to_convey_data_ = false;
65 // omnibox_speculation_ and subresource_speculation_ values 65 // omnibox_speculation_ and subresource_speculation_ values
66 // are intentionally preserved. 66 // are intentionally preserved.
67 } 67 }
68 68
69 void ClientSocket::UseHistory::EmitPreconnectionHistograms() const {
70 DCHECK(!subresource_speculation_ || !omnibox_speculation_);
71 // 0 ==> non-speculative, never connected.
72 // 1 ==> non-speculative never used (but connected).
73 // 2 ==> non-speculative and used.
74 // 3 ==> omnibox_speculative never connected.
75 // 4 ==> omnibox_speculative never used (but connected).
76 // 5 ==> omnibox_speculative and used.
77 // 6 ==> subresource_speculative never connected.
78 // 7 ==> subresource_speculative never used (but connected).
79 // 8 ==> subresource_speculative and used.
80 int result;
81 if (was_used_to_convey_data_)
82 result = 2;
83 else if (was_ever_connected_)
84 result = 1;
85 else
86 result = 0; // Never used, and not really connected.
87
88 if (omnibox_speculation_)
89 result += 3;
90 else if (subresource_speculation_)
91 result += 6;
92 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization2", result, 9);
93
94 static const bool connect_backup_jobs_fieldtrial =
95 base::FieldTrialList::Find("ConnnectBackupJobs") &&
96 !base::FieldTrialList::Find("ConnnectBackupJobs")->group_name().empty();
97 if (connect_backup_jobs_fieldtrial) {
98 UMA_HISTOGRAM_ENUMERATION(
99 base::FieldTrial::MakeName("Net.PreconnectUtilization2",
100 "ConnnectBackupJobs"),
101 result, 9);
102 }
103 }
104
105 void ClientSocket::UseHistory::set_was_ever_connected() { 69 void ClientSocket::UseHistory::set_was_ever_connected() {
106 DCHECK(!was_used_to_convey_data_); 70 DCHECK(!was_used_to_convey_data_);
107 was_ever_connected_ = true; 71 was_ever_connected_ = true;
108 } 72 }
109 73
110 void ClientSocket::UseHistory::set_was_used_to_convey_data() { 74 void ClientSocket::UseHistory::set_was_used_to_convey_data() {
111 DCHECK(was_ever_connected_); 75 DCHECK(was_ever_connected_);
112 was_used_to_convey_data_ = true; 76 was_used_to_convey_data_ = true;
113 } 77 }
114 78
(...skipping 22 matching lines...) Expand all
137 if (was_used_to_convey_data_) 101 if (was_used_to_convey_data_)
138 return; 102 return;
139 omnibox_speculation_ = true; 103 omnibox_speculation_ = true;
140 } 104 }
141 105
142 bool ClientSocket::UseHistory::was_used_to_convey_data() const { 106 bool ClientSocket::UseHistory::was_used_to_convey_data() const {
143 DCHECK(!was_used_to_convey_data_ || was_ever_connected_); 107 DCHECK(!was_used_to_convey_data_ || was_ever_connected_);
144 return was_used_to_convey_data_; 108 return was_used_to_convey_data_;
145 } 109 }
146 110
111 void ClientSocket::UseHistory::EmitPreconnectionHistograms() const {
112 DCHECK(!subresource_speculation_ || !omnibox_speculation_);
113 // 0 ==> non-speculative, never connected.
114 // 1 ==> non-speculative never used (but connected).
115 // 2 ==> non-speculative and used.
116 // 3 ==> omnibox_speculative never connected.
117 // 4 ==> omnibox_speculative never used (but connected).
118 // 5 ==> omnibox_speculative and used.
119 // 6 ==> subresource_speculative never connected.
120 // 7 ==> subresource_speculative never used (but connected).
121 // 8 ==> subresource_speculative and used.
122 int result;
123 if (was_used_to_convey_data_)
124 result = 2;
125 else if (was_ever_connected_)
126 result = 1;
127 else
128 result = 0; // Never used, and not really connected.
129
130 if (omnibox_speculation_)
131 result += 3;
132 else if (subresource_speculation_)
133 result += 6;
134 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectUtilization2", result, 9);
135
136 static const bool connect_backup_jobs_fieldtrial =
137 base::FieldTrialList::Find("ConnnectBackupJobs") &&
138 !base::FieldTrialList::Find("ConnnectBackupJobs")->group_name().empty();
139 if (connect_backup_jobs_fieldtrial) {
140 UMA_HISTOGRAM_ENUMERATION(
141 base::FieldTrial::MakeName("Net.PreconnectUtilization2",
142 "ConnnectBackupJobs"),
143 result, 9);
144 }
145 }
146
147 void ClientSocket::LogByteTransfer(const BoundNetLog& net_log, 147 void ClientSocket::LogByteTransfer(const BoundNetLog& net_log,
148 NetLog::EventType event_type, 148 NetLog::EventType event_type,
149 int byte_count, 149 int byte_count,
150 char* bytes) const { 150 char* bytes) const {
151 scoped_refptr<NetLog::EventParameters> params; 151 scoped_refptr<NetLog::EventParameters> params;
152 if (net_log.IsLoggingBytes()) { 152 if (net_log.IsLoggingBytes()) {
153 params = new NetLogBytesTransferredParameter(byte_count, bytes); 153 params = new NetLogBytesTransferredParameter(byte_count, bytes);
154 } else { 154 } else {
155 params = new NetLogBytesTransferredParameter(byte_count, NULL); 155 params = new NetLogBytesTransferredParameter(byte_count, NULL);
156 } 156 }
157 net_log.AddEvent(event_type, params); 157 net_log.AddEvent(event_type, params);
158 } 158 }
159 159
160 } // namespace net 160 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_list.cc ('k') | net/socket/client_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698