| 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 "components/metrics/file_metrics_provider.h" | 5 #include "components/metrics/file_metrics_provider.h" |
| 6 | 6 |
| 7 #include <functional> | 7 #include <functional> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/memory_mapped_file.h" | 10 #include "base/files/memory_mapped_file.h" |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 CreateMetricsFileWithHistograms( | 489 CreateMetricsFileWithHistograms( |
| 490 2, [](base::PersistentHistogramAllocator* allocator) { | 490 2, [](base::PersistentHistogramAllocator* allocator) { |
| 491 SystemProfileProto profile_proto; | 491 SystemProfileProto profile_proto; |
| 492 SystemProfileProto::FieldTrial* trial = profile_proto.add_field_trial(); | 492 SystemProfileProto::FieldTrial* trial = profile_proto.add_field_trial(); |
| 493 trial->set_name_id(123); | 493 trial->set_name_id(123); |
| 494 trial->set_group_id(456); | 494 trial->set_group_id(456); |
| 495 | 495 |
| 496 PersistentSystemProfile persistent_profile; | 496 PersistentSystemProfile persistent_profile; |
| 497 persistent_profile.RegisterPersistentAllocator( | 497 persistent_profile.RegisterPersistentAllocator( |
| 498 allocator->memory_allocator()); | 498 allocator->memory_allocator()); |
| 499 persistent_profile.SetSystemProfile(profile_proto); | 499 persistent_profile.SetSystemProfile(profile_proto, true); |
| 500 }); | 500 }); |
| 501 | 501 |
| 502 // Register the file and allow the "checker" task to run. | 502 // Register the file and allow the "checker" task to run. |
| 503 ASSERT_TRUE(PathExists(metrics_file())); | 503 ASSERT_TRUE(PathExists(metrics_file())); |
| 504 provider()->RegisterSource( | 504 provider()->RegisterSource( |
| 505 metrics_file(), FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, | 505 metrics_file(), FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, |
| 506 FileMetricsProvider::ASSOCIATE_INTERNAL_PROFILE, kMetricsName); | 506 FileMetricsProvider::ASSOCIATE_INTERNAL_PROFILE, kMetricsName); |
| 507 | 507 |
| 508 // Record embedded snapshots via snapshot-manager. | 508 // Record embedded snapshots via snapshot-manager. |
| 509 OnDidCreateMetricsLog(); | 509 OnDidCreateMetricsLog(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 CreateMetricsFileWithHistograms( | 560 CreateMetricsFileWithHistograms( |
| 561 2, [](base::PersistentHistogramAllocator* allocator) { | 561 2, [](base::PersistentHistogramAllocator* allocator) { |
| 562 SystemProfileProto profile_proto; | 562 SystemProfileProto profile_proto; |
| 563 SystemProfileProto::FieldTrial* trial = profile_proto.add_field_trial(); | 563 SystemProfileProto::FieldTrial* trial = profile_proto.add_field_trial(); |
| 564 trial->set_name_id(123); | 564 trial->set_name_id(123); |
| 565 trial->set_group_id(456); | 565 trial->set_group_id(456); |
| 566 | 566 |
| 567 PersistentSystemProfile persistent_profile; | 567 PersistentSystemProfile persistent_profile; |
| 568 persistent_profile.RegisterPersistentAllocator( | 568 persistent_profile.RegisterPersistentAllocator( |
| 569 allocator->memory_allocator()); | 569 allocator->memory_allocator()); |
| 570 persistent_profile.SetSystemProfile(profile_proto); | 570 persistent_profile.SetSystemProfile(profile_proto, true); |
| 571 }); | 571 }); |
| 572 | 572 |
| 573 // Register the file and allow the "checker" task to run. | 573 // Register the file and allow the "checker" task to run. |
| 574 ASSERT_TRUE(PathExists(metrics_file())); | 574 ASSERT_TRUE(PathExists(metrics_file())); |
| 575 provider()->RegisterSource( | 575 provider()->RegisterSource( |
| 576 metrics_file(), FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, | 576 metrics_file(), FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE, |
| 577 FileMetricsProvider::ASSOCIATE_INTERNAL_PROFILE_OR_PREVIOUS_RUN, | 577 FileMetricsProvider::ASSOCIATE_INTERNAL_PROFILE_OR_PREVIOUS_RUN, |
| 578 kMetricsName); | 578 kMetricsName); |
| 579 | 579 |
| 580 // Record embedded snapshots via snapshot-manager. | 580 // Record embedded snapshots via snapshot-manager. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 591 EXPECT_TRUE(ProvideIndependentMetrics(&profile, &snapshot_manager)); | 591 EXPECT_TRUE(ProvideIndependentMetrics(&profile, &snapshot_manager)); |
| 592 EXPECT_FALSE(ProvideIndependentMetrics(&profile, &snapshot_manager)); | 592 EXPECT_FALSE(ProvideIndependentMetrics(&profile, &snapshot_manager)); |
| 593 } | 593 } |
| 594 EXPECT_TRUE(base::PathExists(metrics_file())); | 594 EXPECT_TRUE(base::PathExists(metrics_file())); |
| 595 OnDidCreateMetricsLog(); | 595 OnDidCreateMetricsLog(); |
| 596 RunTasks(); | 596 RunTasks(); |
| 597 EXPECT_FALSE(base::PathExists(metrics_file())); | 597 EXPECT_FALSE(base::PathExists(metrics_file())); |
| 598 } | 598 } |
| 599 | 599 |
| 600 } // namespace metrics | 600 } // namespace metrics |
| OLD | NEW |