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