| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 return; | 381 return; |
| 382 } | 382 } |
| 383 | 383 |
| 384 // Update the pre-existing source if there is any. This happens when the | 384 // Update the pre-existing source if there is any. This happens when the |
| 385 // initial URL is different from the committed URL for the same source, e.g., | 385 // initial URL is different from the committed URL for the same source, e.g., |
| 386 // when there is redirection. | 386 // when there is redirection. |
| 387 for (auto& source : sources_) { | 387 for (auto& source : sources_) { |
| 388 if (source_id != source->id()) | 388 if (source_id != source->id()) |
| 389 continue; | 389 continue; |
| 390 | 390 |
| 391 source->set_committed_url(url); | 391 source->set_url(url); |
| 392 return; | 392 return; |
| 393 } | 393 } |
| 394 | 394 |
| 395 if (sources_.size() >= kMaxSources) { | 395 if (sources_.size() >= kMaxSources) { |
| 396 RecordDroppedSource(DroppedDataReason::MAX_HIT); | 396 RecordDroppedSource(DroppedDataReason::MAX_HIT); |
| 397 return; | 397 return; |
| 398 } | 398 } |
| 399 std::unique_ptr<UkmSource> source = base::MakeUnique<UkmSource>(); | 399 std::unique_ptr<UkmSource> source = base::MakeUnique<UkmSource>(); |
| 400 source->set_id(source_id); | 400 source->set_id(source_id); |
| 401 source->set_committed_url(url); | 401 source->set_url(url); |
| 402 sources_.push_back(std::move(source)); | 402 sources_.push_back(std::move(source)); |
| 403 } | 403 } |
| 404 | 404 |
| 405 void UkmService::AddEntry(std::unique_ptr<UkmEntry> entry) { | 405 void UkmService::AddEntry(std::unique_ptr<UkmEntry> entry) { |
| 406 DCHECK(thread_checker_.CalledOnValidThread()); | 406 DCHECK(thread_checker_.CalledOnValidThread()); |
| 407 | 407 |
| 408 if (!recording_enabled_) { | 408 if (!recording_enabled_) { |
| 409 RecordDroppedEntry(DroppedDataReason::RECORDING_DISABLED); | 409 RecordDroppedEntry(DroppedDataReason::RECORDING_DISABLED); |
| 410 return; | 410 return; |
| 411 } | 411 } |
| 412 if (entries_.size() >= kMaxEntries) { | 412 if (entries_.size() >= kMaxEntries) { |
| 413 RecordDroppedEntry(DroppedDataReason::MAX_HIT); | 413 RecordDroppedEntry(DroppedDataReason::MAX_HIT); |
| 414 return; | 414 return; |
| 415 } | 415 } |
| 416 | 416 |
| 417 entries_.push_back(std::move(entry)); | 417 entries_.push_back(std::move(entry)); |
| 418 } | 418 } |
| 419 | 419 |
| 420 } // namespace ukm | 420 } // namespace ukm |
| OLD | NEW |