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

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

Issue 2918533003: Send metrics with embedded system profiles after system startup. (Closed)
Patch Set: load profile from only the first found source Created 3 years, 6 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
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/metrics/persistent_system_profile.h"
23 #include "components/prefs/pref_registry_simple.h" 24 #include "components/prefs/pref_registry_simple.h"
24 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
25 26
26 namespace metrics { 27 namespace metrics {
27 28
28 namespace { 29 namespace {
29 30
30 // These structures provide values used to define how files are opened and 31 // These structures provide values used to define how files are opened and
31 // accessed. It obviates the need for multiple code-paths within several of 32 // accessed. It obviates the need for multiple code-paths within several of
32 // the methods. 33 // the methods.
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 // Clear any data for initial metrics since they're always reported 481 // Clear any data for initial metrics since they're always reported
481 // before the first call to this method. It couldn't be released after 482 // before the first call to this method. It couldn't be released after
482 // being reported in RecordInitialHistogramSnapshots because the data 483 // being reported in RecordInitialHistogramSnapshots because the data
483 // will continue to be used by the caller after that method returns. Once 484 // will continue to be used by the caller after that method returns. Once
484 // here, though, all actions to be done on the data have been completed. 485 // here, though, all actions to be done on the data have been completed.
485 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_) 486 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_)
486 DeleteFileAsync(source->path); 487 DeleteFileAsync(source->path);
487 sources_for_previous_run_.clear(); 488 sources_for_previous_run_.clear();
488 } 489 }
489 490
491 bool FileMetricsProvider::ProvideStabilitySystemProfile(
492 SystemProfileProto* system_profile_proto) {
493 for (const std::unique_ptr<SourceInfo>& source : sources_for_previous_run_) {
494 DCHECK(source->allocator);
495 if (PersistentSystemProfile::GetSystemProfile(
496 *source->allocator->memory_allocator(), system_profile_proto)) {
497 return true;
498 }
499 }
500 return false;
501 }
502
490 bool FileMetricsProvider::HasInitialStabilityMetrics() { 503 bool FileMetricsProvider::HasInitialStabilityMetrics() {
491 DCHECK(thread_checker_.CalledOnValidThread()); 504 DCHECK(thread_checker_.CalledOnValidThread());
492 505
493 // Measure the total time spent checking all sources as well as the time 506 // Measure the total time spent checking all sources as well as the time
494 // per individual file. This method is called during startup and thus blocks 507 // per individual file. This method is called during startup and thus blocks
495 // the initial showing of the browser window so it's important to know the 508 // the initial showing of the browser window so it's important to know the
496 // total delay. 509 // total delay.
497 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.Total"); 510 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.InitialCheckTime.Total");
498 511
499 // Check all sources for previous run to see if they need to be read. 512 // Check all sources for previous run to see if they need to be read.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 // important to know how much total "jank" may be introduced. 576 // important to know how much total "jank" may be introduced.
564 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.Total"); 577 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.Total");
565 578
566 for (std::unique_ptr<SourceInfo>& source : sources_mapped_) { 579 for (std::unique_ptr<SourceInfo>& source : sources_mapped_) {
567 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File"); 580 SCOPED_UMA_HISTOGRAM_TIMER("UMA.FileMetricsProvider.SnapshotTime.File");
568 MergeHistogramDeltasFromSource(source.get()); 581 MergeHistogramDeltasFromSource(source.get());
569 } 582 }
570 } 583 }
571 584
572 } // namespace metrics 585 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698