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

Side by Side Diff: net/socket_stream/socket_stream_metrics.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) 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_stream_metrics.h" 5 #include "net/socket_stream/socket_stream_metrics.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 SocketStreamMetrics::SocketStreamMetrics(const GURL& url) 15 SocketStreamMetrics::SocketStreamMetrics(const GURL& url)
16 : received_bytes_(0), 16 : received_bytes_(0), received_counts_(0), sent_bytes_(0), sent_counts_(0) {
17 received_counts_(0),
18 sent_bytes_(0),
19 sent_counts_(0) {
20 ProtocolType protocol_type = PROTOCOL_UNKNOWN; 17 ProtocolType protocol_type = PROTOCOL_UNKNOWN;
21 if (url.SchemeIs("ws")) 18 if (url.SchemeIs("ws"))
22 protocol_type = PROTOCOL_WEBSOCKET; 19 protocol_type = PROTOCOL_WEBSOCKET;
23 else if (url.SchemeIs("wss")) 20 else if (url.SchemeIs("wss"))
24 protocol_type = PROTOCOL_WEBSOCKET_SECURE; 21 protocol_type = PROTOCOL_WEBSOCKET_SECURE;
25 22
26 UMA_HISTOGRAM_ENUMERATION("Net.SocketStream.ProtocolType", 23 UMA_HISTOGRAM_ENUMERATION(
27 protocol_type, NUM_PROTOCOL_TYPES); 24 "Net.SocketStream.ProtocolType", protocol_type, NUM_PROTOCOL_TYPES);
28 } 25 }
29 26
30 SocketStreamMetrics::~SocketStreamMetrics() {} 27 SocketStreamMetrics::~SocketStreamMetrics() {
28 }
31 29
32 void SocketStreamMetrics::OnWaitConnection() { 30 void SocketStreamMetrics::OnWaitConnection() {
33 wait_start_time_ = base::TimeTicks::Now(); 31 wait_start_time_ = base::TimeTicks::Now();
34 } 32 }
35 33
36 void SocketStreamMetrics::OnStartConnection() { 34 void SocketStreamMetrics::OnStartConnection() {
37 connect_start_time_ = base::TimeTicks::Now(); 35 connect_start_time_ = base::TimeTicks::Now();
38 if (!wait_start_time_.is_null()) 36 if (!wait_start_time_.is_null())
39 UMA_HISTOGRAM_TIMES("Net.SocketStream.ConnectionLatency", 37 UMA_HISTOGRAM_TIMES("Net.SocketStream.ConnectionLatency",
40 connect_start_time_ - wait_start_time_); 38 connect_start_time_ - wait_start_time_);
(...skipping 14 matching lines...) Expand all
55 void SocketStreamMetrics::OnWrite(int len) { 53 void SocketStreamMetrics::OnWrite(int len) {
56 sent_bytes_ += len; 54 sent_bytes_ += len;
57 ++sent_counts_; 55 ++sent_counts_;
58 } 56 }
59 57
60 void SocketStreamMetrics::OnClose() { 58 void SocketStreamMetrics::OnClose() {
61 base::TimeTicks closed_time = base::TimeTicks::Now(); 59 base::TimeTicks closed_time = base::TimeTicks::Now();
62 if (!connect_establish_time_.is_null()) { 60 if (!connect_establish_time_.is_null()) {
63 UMA_HISTOGRAM_LONG_TIMES("Net.SocketStream.Duration", 61 UMA_HISTOGRAM_LONG_TIMES("Net.SocketStream.Duration",
64 closed_time - connect_establish_time_); 62 closed_time - connect_establish_time_);
65 UMA_HISTOGRAM_COUNTS("Net.SocketStream.ReceivedBytes", 63 UMA_HISTOGRAM_COUNTS("Net.SocketStream.ReceivedBytes", received_bytes_);
66 received_bytes_); 64 UMA_HISTOGRAM_COUNTS("Net.SocketStream.ReceivedCounts", received_counts_);
67 UMA_HISTOGRAM_COUNTS("Net.SocketStream.ReceivedCounts", 65 UMA_HISTOGRAM_COUNTS("Net.SocketStream.SentBytes", sent_bytes_);
68 received_counts_); 66 UMA_HISTOGRAM_COUNTS("Net.SocketStream.SentCounts", sent_counts_);
69 UMA_HISTOGRAM_COUNTS("Net.SocketStream.SentBytes",
70 sent_bytes_);
71 UMA_HISTOGRAM_COUNTS("Net.SocketStream.SentCounts",
72 sent_counts_);
73 } 67 }
74 } 68 }
75 69
76 void SocketStreamMetrics::OnCountConnectionType(ConnectionType type) { 70 void SocketStreamMetrics::OnCountConnectionType(ConnectionType type) {
77 UMA_HISTOGRAM_ENUMERATION("Net.SocketStream.ConnectionType", type, 71 UMA_HISTOGRAM_ENUMERATION(
78 NUM_CONNECTION_TYPES); 72 "Net.SocketStream.ConnectionType", type, NUM_CONNECTION_TYPES);
79 } 73 }
80 74
81 void SocketStreamMetrics::OnCountWireProtocolType(WireProtocolType type) { 75 void SocketStreamMetrics::OnCountWireProtocolType(WireProtocolType type) {
82 UMA_HISTOGRAM_ENUMERATION("Net.SocketStream.WireProtocolType", type, 76 UMA_HISTOGRAM_ENUMERATION(
83 NUM_WIRE_PROTOCOL_TYPES); 77 "Net.SocketStream.WireProtocolType", type, NUM_WIRE_PROTOCOL_TYPES);
84 } 78 }
85 79
86 } // namespace net 80 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698