Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: components/metrics/file_metrics_provider.cc

Issue 2790753002: Disable sending persistent histograms from last session by default. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_enumerator.h" 9 #include "base/files/file_enumerator.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/files/memory_mapped_file.h" 11 #include "base/files/memory_mapped_file.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/metrics/histogram_base.h" 14 #include "base/metrics/histogram_base.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/metrics/persistent_histogram_allocator.h" 16 #include "base/metrics/persistent_histogram_allocator.h"
17 #include "base/metrics/persistent_memory_allocator.h" 17 #include "base/metrics/persistent_memory_allocator.h"
18 #include "base/strings/string_piece.h" 18 #include "base/strings/string_piece.h"
19 #include "base/task_runner.h" 19 #include "base/task_runner.h"
20 #include "base/time/time.h" 20 #include "base/time/time.h"
21 #include "components/metrics/metrics_pref_names.h" 21 #include "components/metrics/metrics_pref_names.h"
22 #include "components/metrics/metrics_service.h" 22 #include "components/metrics/metrics_service.h"
23 #include "components/prefs/pref_registry_simple.h" 23 #include "components/prefs/pref_registry_simple.h"
24 #include "components/prefs/pref_service.h" 24 #include "components/prefs/pref_service.h"
25 #include "components/variations/variations_associated_data.h"
26 25
27 namespace metrics { 26 namespace metrics {
28 27
29 namespace { 28 namespace {
30 29
31 // These structures provide values used to define how files are opened and 30 // These structures provide values used to define how files are opened and
32 // accessed. It obviates the need for multiple code-paths within several of 31 // accessed. It obviates the need for multiple code-paths within several of
33 // the methods. 32 // the methods.
34 struct SourceOptions { 33 struct SourceOptions {
35 // The flags to be used to open a file on disk. 34 // The flags to be used to open a file on disk.
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // will continue to be used by the caller after that method returns. Once 473 // will continue to be used by the caller after that method returns. Once
475 // here, though, all actions to be done on the data have been completed. 474 // here, though, all actions to be done on the data have been completed.
476 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_) 475 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_)
477 DeleteFileAsync(source->path); 476 DeleteFileAsync(source->path);
478 sources_for_previous_run_.clear(); 477 sources_for_previous_run_.clear();
479 } 478 }
480 479
481 bool FileMetricsProvider::HasInitialStabilityMetrics() { 480 bool FileMetricsProvider::HasInitialStabilityMetrics() {
482 DCHECK(thread_checker_.CalledOnValidThread()); 481 DCHECK(thread_checker_.CalledOnValidThread());
483 482
484 // Check if there is an experiment that disables stability metrics.
485 std::string unreported = variations::GetVariationParamValueByFeature(
486 base::kPersistentHistogramsFeature, "send_unreported_metrics");
487 if (unreported == "no")
488 sources_for_previous_run_.clear();
489
490 // Measure the total time spent checking all sources as well as the time 483 // Measure the total time spent checking all sources as well as the time
491 // per individual file. This method is called during startup and thus blocks 484 // per individual file. This method is called during startup and thus blocks
492 // the initial showing of the browser window so it's important to know the 485 // the initial showing of the browser window so it's important to know the
493 // total delay. 486 // total delay.
494 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.Total"); 487 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.Total");
495 488
496 // Check all sources for previous run to see if they need to be read. 489 // Check all sources for previous run to see if they need to be read.
497 for (auto iter = sources_for_previous_run_.begin(); 490 for (auto iter = sources_for_previous_run_.begin();
498 iter != sources_for_previous_run_.end();) { 491 iter != sources_for_previous_run_.end();) {
499 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.File"); 492 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.File");
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 // important to know how much total "jank" may be introduced. 553 // important to know how much total "jank" may be introduced.
561 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.Total"); 554 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.Total");
562 555
563 for (std::unique_ptr<SourceInfo>& source : sources_mapped_) { 556 for (std::unique_ptr<SourceInfo>& source : sources_mapped_) {
564 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File"); 557 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File");
565 MergeHistogramDeltasFromSource(source.get()); 558 MergeHistogramDeltasFromSource(source.get());
566 } 559 }
567 } 560 }
568 561
569 } // namespace metrics 562 } // namespace metrics
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698