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

Side by Side Diff: net/socket_stream/socket_stream_metrics_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
OLDNEW
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_stream/socket_stream_metrics.h" 5 #include "net/socket_stream/socket_stream_metrics.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/metrics/histogram_samples.h" 10 #include "base/metrics/histogram_samples.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 SocketStreamMetrics metrics(GURL("ws://www.example.com/")); 65 SocketStreamMetrics metrics(GURL("ws://www.example.com/"));
66 for (int i = 0; i < 1; ++i) 66 for (int i = 0; i < 1; ++i)
67 metrics.OnStartConnection(); 67 metrics.OnStartConnection();
68 for (int i = 0; i < 2; ++i) 68 for (int i = 0; i < 2; ++i)
69 metrics.OnCountConnectionType(SocketStreamMetrics::TUNNEL_CONNECTION); 69 metrics.OnCountConnectionType(SocketStreamMetrics::TUNNEL_CONNECTION);
70 for (int i = 0; i < 3; ++i) 70 for (int i = 0; i < 3; ++i)
71 metrics.OnCountConnectionType(SocketStreamMetrics::SOCKS_CONNECTION); 71 metrics.OnCountConnectionType(SocketStreamMetrics::SOCKS_CONNECTION);
72 for (int i = 0; i < 4; ++i) 72 for (int i = 0; i < 4; ++i)
73 metrics.OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION); 73 metrics.OnCountConnectionType(SocketStreamMetrics::SSL_CONNECTION);
74 74
75
76 histogram = 75 histogram =
77 StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType"); 76 StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionType");
78 ASSERT_TRUE(histogram != NULL); 77 ASSERT_TRUE(histogram != NULL);
79 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 78 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
80 79
81 scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples()); 80 scoped_ptr<HistogramSamples> samples(histogram->SnapshotSamples());
82 if (original.get()) { 81 if (original.get()) {
83 samples->Subtract(*original); // Cancel the original values. 82 samples->Subtract(*original); // Cancel the original values.
84 } 83 }
85 EXPECT_EQ(1, samples->GetCount(SocketStreamMetrics::ALL_CONNECTIONS)); 84 EXPECT_EQ(1, samples->GetCount(SocketStreamMetrics::ALL_CONNECTIONS));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 if (histogram) { 130 if (histogram) {
132 original = histogram->SnapshotSamples(); 131 original = histogram->SnapshotSamples();
133 original_received_bytes = original->sum(); 132 original_received_bytes = original->sum();
134 } 133 }
135 histogram = 134 histogram =
136 StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts"); 135 StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts");
137 if (histogram) { 136 if (histogram) {
138 original = histogram->SnapshotSamples(); 137 original = histogram->SnapshotSamples();
139 original_received_counts = original->sum(); 138 original_received_counts = original->sum();
140 } 139 }
141 histogram = 140 histogram = StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
142 StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
143 if (histogram) { 141 if (histogram) {
144 original = histogram->SnapshotSamples(); 142 original = histogram->SnapshotSamples();
145 original_sent_bytes = original->sum(); 143 original_sent_bytes = original->sum();
146 } 144 }
147 histogram = 145 histogram = StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
148 StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
149 if (histogram) { 146 if (histogram) {
150 original = histogram->SnapshotSamples(); 147 original = histogram->SnapshotSamples();
151 original_sent_counts = original->sum(); 148 original_sent_counts = original->sum();
152 } 149 }
153 150
154 SocketStreamMetrics metrics(GURL("ws://www.example.com/")); 151 SocketStreamMetrics metrics(GURL("ws://www.example.com/"));
155 metrics.OnWaitConnection(); 152 metrics.OnWaitConnection();
156 metrics.OnStartConnection(); 153 metrics.OnStartConnection();
157 metrics.OnConnected(); 154 metrics.OnConnected();
158 metrics.OnRead(1); 155 metrics.OnRead(1);
(...skipping 13 matching lines...) Expand all
172 // We don't check the contents of the histogram as it's time sensitive. 169 // We don't check the contents of the histogram as it's time sensitive.
173 170
174 // ConnectionEstablish. 171 // ConnectionEstablish.
175 histogram = 172 histogram =
176 StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionEstablish"); 173 StatisticsRecorder::FindHistogram("Net.SocketStream.ConnectionEstablish");
177 ASSERT_TRUE(histogram != NULL); 174 ASSERT_TRUE(histogram != NULL);
178 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 175 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
179 // We don't check the contents of the histogram as it's time sensitive. 176 // We don't check the contents of the histogram as it's time sensitive.
180 177
181 // Duration. 178 // Duration.
182 histogram = 179 histogram = StatisticsRecorder::FindHistogram("Net.SocketStream.Duration");
183 StatisticsRecorder::FindHistogram("Net.SocketStream.Duration");
184 ASSERT_TRUE(histogram != NULL); 180 ASSERT_TRUE(histogram != NULL);
185 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 181 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
186 // We don't check the contents of the histogram as it's time sensitive. 182 // We don't check the contents of the histogram as it's time sensitive.
187 183
188 // ReceivedBytes. 184 // ReceivedBytes.
189 histogram = 185 histogram =
190 StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes"); 186 StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedBytes");
191 ASSERT_TRUE(histogram != NULL); 187 ASSERT_TRUE(histogram != NULL);
192 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 188 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
193 samples = histogram->SnapshotSamples(); 189 samples = histogram->SnapshotSamples();
194 EXPECT_EQ(11, samples->sum() - original_received_bytes); // 11 bytes read. 190 EXPECT_EQ(11, samples->sum() - original_received_bytes); // 11 bytes read.
195 191
196 // ReceivedCounts. 192 // ReceivedCounts.
197 histogram = 193 histogram =
198 StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts"); 194 StatisticsRecorder::FindHistogram("Net.SocketStream.ReceivedCounts");
199 ASSERT_TRUE(histogram != NULL); 195 ASSERT_TRUE(histogram != NULL);
200 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 196 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
201 samples = histogram->SnapshotSamples(); 197 samples = histogram->SnapshotSamples();
202 EXPECT_EQ(2, samples->sum() - original_received_counts); // 2 read requests. 198 EXPECT_EQ(2, samples->sum() - original_received_counts); // 2 read requests.
203 199
204 // SentBytes. 200 // SentBytes.
205 histogram = 201 histogram = StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
206 StatisticsRecorder::FindHistogram("Net.SocketStream.SentBytes");
207 ASSERT_TRUE(histogram != NULL); 202 ASSERT_TRUE(histogram != NULL);
208 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 203 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
209 samples = histogram->SnapshotSamples(); 204 samples = histogram->SnapshotSamples();
210 EXPECT_EQ(222, samples->sum() - original_sent_bytes); // 222 bytes sent. 205 EXPECT_EQ(222, samples->sum() - original_sent_bytes); // 222 bytes sent.
211 206
212 // SentCounts. 207 // SentCounts.
213 histogram = 208 histogram = StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
214 StatisticsRecorder::FindHistogram("Net.SocketStream.SentCounts");
215 ASSERT_TRUE(histogram != NULL); 209 ASSERT_TRUE(histogram != NULL);
216 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags()); 210 EXPECT_EQ(HistogramBase::kUmaTargetedHistogramFlag, histogram->flags());
217 samples = histogram->SnapshotSamples(); 211 samples = histogram->SnapshotSamples();
218 EXPECT_EQ(3, samples->sum() - original_sent_counts); // 3 write requests. 212 EXPECT_EQ(3, samples->sum() - original_sent_counts); // 3 write requests.
219 } 213 }
220 214
221 } // namespace net 215 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698