OLD | NEW |
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 Loading... |
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<const std::deque<const data_usage::DataUse>> |
| 135 data_use_list) { |
134 DCHECK(thread_checker_.CalledOnValidThread()); | 136 DCHECK(thread_checker_.CalledOnValidThread()); |
| 137 DCHECK(data_use_list); |
135 | 138 |
136 const base::Time now_time = base::Time::Now(); | 139 const base::Time now_time = base::Time::Now(); |
137 DataUseTabModel::TrackingInfo tracking_info; | 140 DataUseTabModel::TrackingInfo tracking_info; |
138 | 141 |
139 if (!data_use_tab_model_->GetTrackingInfoForTabAtTime( | 142 for (const auto& data_use : *data_use_list) { |
140 data_use.tab_id, data_use.request_start, &tracking_info)) { | 143 if (!data_use_tab_model_->GetTrackingInfoForTabAtTime( |
141 return; | 144 data_use.tab_id, data_use.request_start, &tracking_info)) { |
| 145 continue; |
| 146 } |
| 147 |
| 148 BufferDataUseReport(data_use, tracking_info.label, tracking_info.tag, |
| 149 previous_report_time_, now_time); |
| 150 SubmitBufferedDataUseReport(false); |
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; | 152 previous_report_time_ = now_time; |
148 } | 153 } |
149 | 154 |
150 void ExternalDataUseReporter::OnReportDataUseDone(bool success) { | 155 void ExternalDataUseReporter::OnReportDataUseDone(bool success) { |
151 DCHECK(thread_checker_.CalledOnValidThread()); | 156 DCHECK(thread_checker_.CalledOnValidThread()); |
152 DCHECK(!last_data_report_submitted_ticks_.is_null()); | 157 DCHECK(!last_data_report_submitted_ticks_.is_null()); |
153 | 158 |
154 if (success) { | 159 if (success) { |
155 RecordDataUsageReportSubmission(DATAUSAGE_REPORT_SUBMISSION_SUCCESSFUL, | 160 RecordDataUsageReportSubmission(DATAUSAGE_REPORT_SUBMISSION_SUCCESSFUL, |
156 pending_report_bytes_); | 161 pending_report_bytes_); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 hash = hash * 23 + hash_function(k.label); | 326 hash = hash * 23 + hash_function(k.label); |
322 hash = hash * 31 + hash_function(k.tag); | 327 hash = hash * 31 + hash_function(k.tag); |
323 hash = hash * 43 + k.connection_type; | 328 hash = hash * 43 + k.connection_type; |
324 hash = hash * 83 + hash_function(k.mcc_mnc); | 329 hash = hash * 83 + hash_function(k.mcc_mnc); |
325 return hash; | 330 return hash; |
326 } | 331 } |
327 | 332 |
328 } // namespace android | 333 } // namespace android |
329 | 334 |
330 } // namespace chrome | 335 } // namespace chrome |
OLD | NEW |