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

Side by Side Diff: chrome/browser/android/data_usage/external_data_use_reporter.cc

Issue 2169773002: Batch data use objects in ExternalDataUseObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/android/data_usage/external_data_use_reporter.h" 5 #include "chrome/browser/android/data_usage/external_data_use_reporter.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/metrics/histogram_base.h" 10 #include "base/metrics/histogram_base.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 app_state_listener_.reset(new base::android::ApplicationStatusListener( 123 app_state_listener_.reset(new base::android::ApplicationStatusListener(
124 base::Bind(&ExternalDataUseReporter::OnApplicationStateChange, 124 base::Bind(&ExternalDataUseReporter::OnApplicationStateChange,
125 base::Unretained(this)))); 125 base::Unretained(this))));
126 #endif 126 #endif
127 } 127 }
128 128
129 ExternalDataUseReporter::~ExternalDataUseReporter() { 129 ExternalDataUseReporter::~ExternalDataUseReporter() {
130 DCHECK(thread_checker_.CalledOnValidThread()); 130 DCHECK(thread_checker_.CalledOnValidThread());
131 } 131 }
132 132
133 void ExternalDataUseReporter::OnDataUse(const data_usage::DataUse& data_use) { 133 void ExternalDataUseReporter::OnDataUse(
134 std::unique_ptr<std::deque<const data_usage::DataUse>> data_use_list) {
134 DCHECK(thread_checker_.CalledOnValidThread()); 135 DCHECK(thread_checker_.CalledOnValidThread());
136 DCHECK(data_use_list);
135 137
136 const base::Time now_time = base::Time::Now(); 138 const base::Time now_time = base::Time::Now();
137 DataUseTabModel::TrackingInfo tracking_info; 139 DataUseTabModel::TrackingInfo tracking_info;
138 140
139 if (!data_use_tab_model_->GetTrackingInfoForTabAtTime( 141 for (auto data_use : *data_use_list) {
tbansal1 2016/07/21 04:57:11 ALso this should be const auto & Otherwise, a copy
Raj 2016/07/21 05:58:22 Done.
140 data_use.tab_id, data_use.request_start, &tracking_info)) { 142 if (!data_use_tab_model_->GetTrackingInfoForTabAtTime(
141 return; 143 data_use.tab_id, data_use.request_start, &tracking_info)) {
144 continue;
145 }
146
147 BufferDataUseReport(data_use, tracking_info.label, tracking_info.tag,
148 previous_report_time_, now_time);
149 SubmitBufferedDataUseReport(false);
150 previous_report_time_ = now_time;
tbansal1 2016/07/21 04:40:30 Move this outside the for loop so that it is not m
Raj 2016/07/21 05:58:22 Done.
142 } 151 }
143
144 BufferDataUseReport(data_use, tracking_info.label, tracking_info.tag,
145 previous_report_time_, now_time);
146 SubmitBufferedDataUseReport(false);
147 previous_report_time_ = now_time;
148 } 152 }
149 153
150 void ExternalDataUseReporter::OnReportDataUseDone(bool success) { 154 void ExternalDataUseReporter::OnReportDataUseDone(bool success) {
151 DCHECK(thread_checker_.CalledOnValidThread()); 155 DCHECK(thread_checker_.CalledOnValidThread());
152 DCHECK(!last_data_report_submitted_ticks_.is_null()); 156 DCHECK(!last_data_report_submitted_ticks_.is_null());
153 157
154 if (success) { 158 if (success) {
155 RecordDataUsageReportSubmission(DATAUSAGE_REPORT_SUBMISSION_SUCCESSFUL, 159 RecordDataUsageReportSubmission(DATAUSAGE_REPORT_SUBMISSION_SUCCESSFUL,
156 pending_report_bytes_); 160 pending_report_bytes_);
157 } else { 161 } else {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 hash = hash * 23 + hash_function(k.label); 325 hash = hash * 23 + hash_function(k.label);
322 hash = hash * 31 + hash_function(k.tag); 326 hash = hash * 31 + hash_function(k.tag);
323 hash = hash * 43 + k.connection_type; 327 hash = hash * 43 + k.connection_type;
324 hash = hash * 83 + hash_function(k.mcc_mnc); 328 hash = hash * 83 + hash_function(k.mcc_mnc);
325 return hash; 329 return hash;
326 } 330 }
327 331
328 } // namespace android 332 } // namespace android
329 333
330 } // namespace chrome 334 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698