| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ukm/ukm_service.h" | 5 #include "components/ukm/ukm_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 if (persisted_logs_.empty()) { | 271 if (persisted_logs_.empty()) { |
| 272 // No logs to send, so early out and schedule the next rotation. | 272 // No logs to send, so early out and schedule the next rotation. |
| 273 scheduler_->UploadFinished(true, /* has_unsent_logs */ false); | 273 scheduler_->UploadFinished(true, /* has_unsent_logs */ false); |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 if (!persisted_logs_.has_staged_log()) | 276 if (!persisted_logs_.has_staged_log()) |
| 277 persisted_logs_.StageLog(); | 277 persisted_logs_.StageLog(); |
| 278 // TODO(holte): Handle data usage on cellular, etc. | 278 // TODO(holte): Handle data usage on cellular, etc. |
| 279 if (!log_uploader_) { | 279 if (!log_uploader_) { |
| 280 log_uploader_ = client_->CreateUploader( | 280 log_uploader_ = client_->CreateUploader( |
| 281 GetServerUrl(), kMimeType, base::Bind(&UkmService::OnLogUploadComplete, | 281 GetServerUrl(), kMimeType, metrics::MetricsLogUploader::UKM, |
| 282 self_ptr_factory_.GetWeakPtr())); | 282 base::Bind(&UkmService::OnLogUploadComplete, |
| 283 self_ptr_factory_.GetWeakPtr())); |
| 283 } | 284 } |
| 284 log_upload_in_progress_ = true; | 285 log_upload_in_progress_ = true; |
| 285 | 286 |
| 286 const std::string hash = | 287 const std::string hash = |
| 287 base::HexEncode(persisted_logs_.staged_log_hash().data(), | 288 base::HexEncode(persisted_logs_.staged_log_hash().data(), |
| 288 persisted_logs_.staged_log_hash().size()); | 289 persisted_logs_.staged_log_hash().size()); |
| 289 log_uploader_->UploadLog(persisted_logs_.staged_log(), hash); | 290 log_uploader_->UploadLog(persisted_logs_.staged_log(), hash); |
| 290 } | 291 } |
| 291 | 292 |
| 292 void UkmService::OnLogUploadComplete(int response_code) { | 293 void UkmService::OnLogUploadComplete(int response_code) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 329 } |
| 329 if (sources_.size() >= kMaxSources) { | 330 if (sources_.size() >= kMaxSources) { |
| 330 RecordDroppedSource(DroppedSourceReason::MAX_SOURCES_HIT); | 331 RecordDroppedSource(DroppedSourceReason::MAX_SOURCES_HIT); |
| 331 return; | 332 return; |
| 332 } | 333 } |
| 333 | 334 |
| 334 sources_.push_back(std::move(source)); | 335 sources_.push_back(std::move(source)); |
| 335 } | 336 } |
| 336 | 337 |
| 337 } // namespace ukm | 338 } // namespace ukm |
| OLD | NEW |