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 "components/data_use_measurement/core/data_use_measurement.h" | 5 #include "components/data_use_measurement/core/data_use_measurement.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 : DataUseUserData::AUDIO); | 438 : DataUseUserData::AUDIO); |
439 } else if (content_type == DataUseUserData::VIDEO) { | 439 } else if (content_type == DataUseUserData::VIDEO) { |
440 content_type = app_state != DataUseUserData::FOREGROUND | 440 content_type = app_state != DataUseUserData::FOREGROUND |
441 ? DataUseUserData::VIDEO_APPBACKGROUND | 441 ? DataUseUserData::VIDEO_APPBACKGROUND |
442 : (!is_tab_visible ? DataUseUserData::VIDEO_TABBACKGROUND | 442 : (!is_tab_visible ? DataUseUserData::VIDEO_TABBACKGROUND |
443 : DataUseUserData::VIDEO); | 443 : DataUseUserData::VIDEO); |
444 } | 444 } |
445 // Use the more primitive STATIC_HISTOGRAM_POINTER_BLOCK macro because the | 445 // Use the more primitive STATIC_HISTOGRAM_POINTER_BLOCK macro because the |
446 // simple UMA_HISTOGRAM_ENUMERATION macros don't expose 'AddCount'. | 446 // simple UMA_HISTOGRAM_ENUMERATION macros don't expose 'AddCount'. |
447 if (is_user_traffic) { | 447 if (is_user_traffic) { |
448 user_traffic_content_type_bytes_[content_type] += bytes; | |
RyanSturm
2017/05/01 18:49:44
You might want to capture the foreground/backgroun
Raj
2017/05/01 20:57:58
This CL only changes the UMA DataUse.ContentType.U
RyanSturm
2017/05/01 21:05:24
Thanks for the clarification.
| |
448 STATIC_HISTOGRAM_POINTER_BLOCK( | 449 STATIC_HISTOGRAM_POINTER_BLOCK( |
449 "DataUse.ContentType.UserTraffic", AddCount(content_type, bytes), | 450 "DataUse.ContentType.UserTrafficKB", |
451 AddCount(content_type, | |
452 user_traffic_content_type_bytes_[content_type] / 1024), | |
450 base::LinearHistogram::FactoryGet( | 453 base::LinearHistogram::FactoryGet( |
451 "DataUse.ContentType.UserTraffic", 1, DataUseUserData::TYPE_MAX, | 454 "DataUse.ContentType.UserTrafficKB", 1, DataUseUserData::TYPE_MAX, |
452 DataUseUserData::TYPE_MAX + 1, | 455 DataUseUserData::TYPE_MAX + 1, |
453 base::HistogramBase::kUmaTargetedHistogramFlag)); | 456 base::HistogramBase::kUmaTargetedHistogramFlag)); |
457 user_traffic_content_type_bytes_[content_type] %= 1024; | |
454 } else { | 458 } else { |
455 STATIC_HISTOGRAM_POINTER_BLOCK( | 459 STATIC_HISTOGRAM_POINTER_BLOCK( |
456 "DataUse.ContentType.Services", AddCount(content_type, bytes), | 460 "DataUse.ContentType.Services", AddCount(content_type, bytes), |
457 base::LinearHistogram::FactoryGet( | 461 base::LinearHistogram::FactoryGet( |
458 "DataUse.ContentType.Services", 1, DataUseUserData::TYPE_MAX, | 462 "DataUse.ContentType.Services", 1, DataUseUserData::TYPE_MAX, |
459 DataUseUserData::TYPE_MAX + 1, | 463 DataUseUserData::TYPE_MAX + 1, |
460 base::HistogramBase::kUmaTargetedHistogramFlag)); | 464 base::HistogramBase::kUmaTargetedHistogramFlag)); |
461 } | 465 } |
462 } | 466 } |
463 | 467 |
464 void DataUseMeasurement::RecordPageTransitionUMA( | 468 void DataUseMeasurement::RecordPageTransitionUMA( |
465 const net::URLRequest& request) const { | 469 const net::URLRequest& request) const { |
466 if (!url_request_classifier_->IsUserRequest(request)) | 470 if (!url_request_classifier_->IsUserRequest(request)) |
467 return; | 471 return; |
468 | 472 |
469 const DataUseRecorder* recorder = ascriber_->GetDataUseRecorder(request); | 473 const DataUseRecorder* recorder = ascriber_->GetDataUseRecorder(request); |
470 if (recorder) { | 474 if (recorder) { |
471 url_request_classifier_->RecordPageTransitionUMA( | 475 url_request_classifier_->RecordPageTransitionUMA( |
472 recorder->page_transition(), request.GetTotalReceivedBytes()); | 476 recorder->page_transition(), request.GetTotalReceivedBytes()); |
473 } | 477 } |
474 } | 478 } |
475 | 479 |
476 } // namespace data_use_measurement | 480 } // namespace data_use_measurement |
OLD | NEW |