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

Side by Side Diff: components/data_use_measurement/core/data_use_measurement.cc

Issue 2614203002: Record data use of user traffic by different core page transition types (Closed)
Patch Set: rebased Created 3 years, 9 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
OLDNEW
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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 bytes_transferred_since_last_traffic_stats_query_ += bytes_sent; 162 bytes_transferred_since_last_traffic_stats_query_ += bytes_sent;
163 #endif 163 #endif
164 } 164 }
165 165
166 void DataUseMeasurement::OnCompleted(const net::URLRequest& request, 166 void DataUseMeasurement::OnCompleted(const net::URLRequest& request,
167 bool started) { 167 bool started) {
168 // TODO(amohammadkhan): Verify that there is no double recording in data use 168 // TODO(amohammadkhan): Verify that there is no double recording in data use
169 // of redirected requests. 169 // of redirected requests.
170 UpdateDataUsePrefs(request); 170 UpdateDataUsePrefs(request);
171 ReportServicesMessageSizeUMA(request); 171 ReportServicesMessageSizeUMA(request);
172 RecordPageTransitionUMA(request);
172 #if defined(OS_ANDROID) 173 #if defined(OS_ANDROID)
173 MaybeRecordNetworkBytesOS(); 174 MaybeRecordNetworkBytesOS();
174 #endif 175 #endif
175 } 176 }
176 177
177 void DataUseMeasurement::ReportDataUseUMA(const net::URLRequest& request, 178 void DataUseMeasurement::ReportDataUseUMA(const net::URLRequest& request,
178 TrafficDirection dir, 179 TrafficDirection dir,
179 int64_t bytes) { 180 int64_t bytes) {
180 bool is_user_traffic = url_request_classifier_->IsUserRequest(request); 181 bool is_user_traffic = url_request_classifier_->IsUserRequest(request);
181 bool is_connection_cellular = 182 bool is_connection_cellular =
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 IncreaseSparseHistogramByValue("DataUse.AllServices.Background", service, 386 IncreaseSparseHistogramByValue("DataUse.AllServices.Background", service,
386 message_size); 387 message_size);
387 } 388 }
388 } 389 }
389 } 390 }
390 391
391 void DataUseMeasurement::RecordTabStateHistogram( 392 void DataUseMeasurement::RecordTabStateHistogram(
392 TrafficDirection dir, 393 TrafficDirection dir,
393 DataUseUserData::AppState app_state, 394 DataUseUserData::AppState app_state,
394 bool is_tab_visible, 395 bool is_tab_visible,
395 int64_t bytes) { 396 int64_t bytes) const {
396 if (app_state == DataUseUserData::UNKNOWN) 397 if (app_state == DataUseUserData::UNKNOWN)
397 return; 398 return;
398 399
399 std::string histogram_name = "DataUse.AppTabState."; 400 std::string histogram_name = "DataUse.AppTabState.";
400 histogram_name.append(dir == UPSTREAM ? "Upstream." : "Downstream."); 401 histogram_name.append(dir == UPSTREAM ? "Upstream." : "Downstream.");
401 if (app_state == DataUseUserData::BACKGROUND) { 402 if (app_state == DataUseUserData::BACKGROUND) {
402 histogram_name.append("AppBackground"); 403 histogram_name.append("AppBackground");
403 } else if (is_tab_visible) { 404 } else if (is_tab_visible) {
404 histogram_name.append("AppForeground.TabForeground"); 405 histogram_name.append("AppForeground.TabForeground");
405 } else { 406 } else {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } else { 438 } else {
438 STATIC_HISTOGRAM_POINTER_BLOCK( 439 STATIC_HISTOGRAM_POINTER_BLOCK(
439 "DataUse.ContentType.Services", AddCount(content_type, bytes), 440 "DataUse.ContentType.Services", AddCount(content_type, bytes),
440 base::LinearHistogram::FactoryGet( 441 base::LinearHistogram::FactoryGet(
441 "DataUse.ContentType.Services", 1, DataUseUserData::TYPE_MAX, 442 "DataUse.ContentType.Services", 1, DataUseUserData::TYPE_MAX,
442 DataUseUserData::TYPE_MAX + 1, 443 DataUseUserData::TYPE_MAX + 1,
443 base::HistogramBase::kUmaTargetedHistogramFlag)); 444 base::HistogramBase::kUmaTargetedHistogramFlag));
444 } 445 }
445 } 446 }
446 447
448 void DataUseMeasurement::RecordPageTransitionUMA(
449 const net::URLRequest& request) const {
450 if (!url_request_classifier_->IsUserRequest(request))
451 return;
452
453 const DataUseRecorder* recorder = ascriber_->GetDataUseRecorder(request);
454 if (recorder) {
455 url_request_classifier_->RecordPageTransitionUMA(
456 recorder->page_transition(), request.GetTotalReceivedBytes());
457 }
458 }
459
447 } // namespace data_use_measurement 460 } // namespace data_use_measurement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698