OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chrome/browser/net/request_source_bandwidth_histograms.h" | 5 #include "chrome/browser/net/request_source_bandwidth_histograms.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
8 #include "content/public/browser/resource_request_info.h" | 10 #include "content/public/browser/resource_request_info.h" |
9 #include "content/public/common/process_type.h" | 11 #include "content/public/common/process_type.h" |
10 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
11 | 13 |
12 namespace { | 14 namespace { |
13 | 15 |
14 enum Bucket { | 16 enum Bucket { |
15 BUCKET_UNKNOWN, | 17 BUCKET_UNKNOWN, |
16 BUCKET_RENDERER, | 18 BUCKET_RENDERER, |
(...skipping 16 matching lines...) Expand all Loading... |
33 return BUCKET_RENDERER; | 35 return BUCKET_RENDERER; |
34 else | 36 else |
35 return BUCKET_UNKNOWN; | 37 return BUCKET_UNKNOWN; |
36 } | 38 } |
37 | 39 |
38 // Histogram response sizes in kilobytes, from 1 KB to 4 GB. | 40 // Histogram response sizes in kilobytes, from 1 KB to 4 GB. |
39 #define UMA_HISTOGRAM_RESPONSE_KB(bucket, sample) \ | 41 #define UMA_HISTOGRAM_RESPONSE_KB(bucket, sample) \ |
40 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.ResponseSizeByProcess." bucket, sample, \ | 42 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.ResponseSizeByProcess." bucket, sample, \ |
41 1, 4 * 1024 * 1024, 100) | 43 1, 4 * 1024 * 1024, 100) |
42 | 44 |
43 void LogRequest(Bucket bucket, int64 bytes) { | 45 void LogRequest(Bucket bucket, int64_t bytes) { |
44 int64 kilobytes = bytes / 1024; | 46 int64_t kilobytes = bytes / 1024; |
45 switch (bucket) { | 47 switch (bucket) { |
46 case BUCKET_UNKNOWN: | 48 case BUCKET_UNKNOWN: |
47 UMA_HISTOGRAM_RESPONSE_KB("Unknown", kilobytes); | 49 UMA_HISTOGRAM_RESPONSE_KB("Unknown", kilobytes); |
48 break; | 50 break; |
49 case BUCKET_RENDERER: | 51 case BUCKET_RENDERER: |
50 UMA_HISTOGRAM_RESPONSE_KB("Renderer", kilobytes); | 52 UMA_HISTOGRAM_RESPONSE_KB("Renderer", kilobytes); |
51 break; | 53 break; |
52 case BUCKET_BROWSER: | 54 case BUCKET_BROWSER: |
53 UMA_HISTOGRAM_RESPONSE_KB("Browser", kilobytes); | 55 UMA_HISTOGRAM_RESPONSE_KB("Browser", kilobytes); |
54 break; | 56 break; |
55 default: | 57 default: |
56 NOTREACHED(); | 58 NOTREACHED(); |
57 } | 59 } |
58 } | 60 } |
59 | 61 |
60 } // namespace | 62 } // namespace |
61 | 63 |
62 void RecordRequestSourceBandwidth(const net::URLRequest* request, | 64 void RecordRequestSourceBandwidth(const net::URLRequest* request, |
63 bool started) { | 65 bool started) { |
64 if (ShouldHistogramRequest(request, started)) | 66 if (ShouldHistogramRequest(request, started)) |
65 LogRequest(GetBucketForRequest(request), request->GetTotalReceivedBytes()); | 67 LogRequest(GetBucketForRequest(request), request->GetTotalReceivedBytes()); |
66 } | 68 } |
OLD | NEW |