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

Side by Side Diff: chrome/browser/metrics/chrome_metrics_service_client.cc

Issue 2658163002: Merge histograms from providers into StatisticsRecorder for display. (Closed)
Patch Set: rebased Created 3 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/metrics/chrome_metrics_service_client.h" 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/bind.h" 13 #include "base/bind.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/files/file_path.h" 16 #include "base/files/file_path.h"
17 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
18 #include "base/lazy_instance.h" 18 #include "base/lazy_instance.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/memory/ptr_util.h" 20 #include "base/memory/ptr_util.h"
21 #include "base/metrics/histogram_macros.h" 21 #include "base/metrics/histogram_macros.h"
22 #include "base/metrics/persistent_histogram_allocator.h" 22 #include "base/metrics/persistent_histogram_allocator.h"
23 #include "base/metrics/statistics_recorder.h"
23 #include "base/path_service.h" 24 #include "base/path_service.h"
24 #include "base/rand_util.h" 25 #include "base/rand_util.h"
25 #include "base/strings/string16.h" 26 #include "base/strings/string16.h"
26 #include "base/threading/platform_thread.h" 27 #include "base/threading/platform_thread.h"
27 #include "base/threading/thread_task_runner_handle.h" 28 #include "base/threading/thread_task_runner_handle.h"
28 #include "build/build_config.h" 29 #include "build/build_config.h"
29 #include "chrome/browser/browser_process.h" 30 #include "chrome/browser/browser_process.h"
30 #include "chrome/browser/chrome_notification_types.h" 31 #include "chrome/browser/chrome_notification_types.h"
31 #include "chrome/browser/google/google_brand.h" 32 #include "chrome/browser/google/google_brand.h"
32 #include "chrome/browser/history/history_service_factory.h" 33 #include "chrome/browser/history/history_service_factory.h"
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 759
759 base::Closure callback = 760 base::Closure callback =
760 base::Bind(&ChromeMetricsServiceClient::OnMemoryDetailCollectionDone, 761 base::Bind(&ChromeMetricsServiceClient::OnMemoryDetailCollectionDone,
761 weak_ptr_factory_.GetWeakPtr()); 762 weak_ptr_factory_.GetWeakPtr());
762 763
763 scoped_refptr<MetricsMemoryDetails> details( 764 scoped_refptr<MetricsMemoryDetails> details(
764 new MetricsMemoryDetails(callback, &memory_growth_tracker_)); 765 new MetricsMemoryDetails(callback, &memory_growth_tracker_));
765 details->StartFetch(); 766 details->StartFetch();
766 } 767 }
767 768
768 void ChromeMetricsServiceClient::MergeHistogramDeltas() {
769 DCHECK(GetMetricsService());
770 GetMetricsService()->MergeHistogramDeltas();
771 }
772
773 void ChromeMetricsServiceClient::OnMemoryDetailCollectionDone() { 769 void ChromeMetricsServiceClient::OnMemoryDetailCollectionDone() {
774 DCHECK(thread_checker_.CalledOnValidThread()); 770 DCHECK(thread_checker_.CalledOnValidThread());
775 771
776 // This function should only be called as the callback from an ansynchronous 772 // This function should only be called as the callback from an ansynchronous
777 // step. 773 // step.
778 DCHECK(waiting_for_collect_final_metrics_step_); 774 DCHECK(waiting_for_collect_final_metrics_step_);
779 775
780 // Create a callback_task for OnHistogramSynchronizationDone. 776 // Create a callback_task for OnHistogramSynchronizationDone.
781 base::Closure callback = base::Bind( 777 base::Closure callback = base::Bind(
782 &ChromeMetricsServiceClient::OnHistogramSynchronizationDone, 778 &ChromeMetricsServiceClient::OnHistogramSynchronizationDone,
(...skipping 14 matching lines...) Expand all
797 // |GetHistograms()|. 793 // |GetHistograms()|.
798 DCHECK_EQ(num_async_histogram_fetches_in_progress_, 3); 794 DCHECK_EQ(num_async_histogram_fetches_in_progress_, 3);
799 // Assign |num_async_histogram_fetches_in_progress_| above and decrement it 795 // Assign |num_async_histogram_fetches_in_progress_| above and decrement it
800 // here to make code work even if |GetHistograms()| fired |callback|. 796 // here to make code work even if |GetHistograms()| fired |callback|.
801 --num_async_histogram_fetches_in_progress_; 797 --num_async_histogram_fetches_in_progress_;
802 } 798 }
803 #endif // !ENABLE_PRINT_PREVIEW 799 #endif // !ENABLE_PRINT_PREVIEW
804 800
805 // Merge histograms from metrics providers into StatisticsRecorder. 801 // Merge histograms from metrics providers into StatisticsRecorder.
806 content::BrowserThread::PostTaskAndReply( 802 content::BrowserThread::PostTaskAndReply(
807 content::BrowserThread::UI, 803 content::BrowserThread::UI, FROM_HERE,
808 FROM_HERE, 804 base::Bind(&base::StatisticsRecorder::ImportProvidedHistograms),
809 base::Bind(&ChromeMetricsServiceClient::MergeHistogramDeltas,
810 weak_ptr_factory_.GetWeakPtr()),
811 callback); 805 callback);
812 806
813 // Set up the callback task to call after we receive histograms from all 807 // Set up the callback task to call after we receive histograms from all
814 // child processes. |timeout| specifies how long to wait before absolutely 808 // child processes. |timeout| specifies how long to wait before absolutely
815 // calling us back on the task. 809 // calling us back on the task.
816 content::FetchHistogramsAsynchronously(base::ThreadTaskRunnerHandle::Get(), 810 content::FetchHistogramsAsynchronously(base::ThreadTaskRunnerHandle::Get(),
817 callback, timeout); 811 callback, timeout);
818 } 812 }
819 813
820 void ChromeMetricsServiceClient::OnHistogramSynchronizationDone() { 814 void ChromeMetricsServiceClient::OnHistogramSynchronizationDone() {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 } 920 }
927 921
928 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { 922 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() {
929 return metrics::IsCellularLogicEnabled(); 923 return metrics::IsCellularLogicEnabled();
930 } 924 }
931 925
932 void ChromeMetricsServiceClient::OnHistoryDeleted() { 926 void ChromeMetricsServiceClient::OnHistoryDeleted() {
933 if (ukm_service_) 927 if (ukm_service_)
934 ukm_service_->Purge(); 928 ukm_service_->Purge();
935 } 929 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/chrome_metrics_service_client.h ('k') | chrome/browser/metrics/subprocess_metrics_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698