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

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

Issue 2308763002: Integrate Crashpad UMA (Closed)
Patch Set: . Created 4 years, 3 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 <vector> 9 #include <vector>
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h " 103 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h "
104 #include "components/signin/core/browser/signin_status_metrics_provider.h" 104 #include "components/signin/core/browser/signin_status_metrics_provider.h"
105 #endif // !defined(OS_CHROMEOS) 105 #endif // !defined(OS_CHROMEOS)
106 106
107 namespace { 107 namespace {
108 108
109 // This specifies the amount of time to wait for all renderers to send their 109 // This specifies the amount of time to wait for all renderers to send their
110 // data. 110 // data.
111 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds. 111 const int kMaxHistogramGatheringWaitDuration = 60000; // 60 seconds.
112 112
113 // Needs to be kept in sync with the writer in
114 // third_party/crashpad/crashpad/handler/handler_main.cc.
115 const char kCrashpadHistogramAllocatorName[] = "CrashpadMetrics";
116
113 // Checks whether it is the first time that cellular uploads logic should be 117 // Checks whether it is the first time that cellular uploads logic should be
114 // enabled based on whether the the preference for that logic is initialized. 118 // enabled based on whether the the preference for that logic is initialized.
115 // This should happen only once as the used preference will be initialized 119 // This should happen only once as the used preference will be initialized
116 // afterwards in |UmaSessionStats.java|. 120 // afterwards in |UmaSessionStats.java|.
117 bool ShouldClearSavedMetrics() { 121 bool ShouldClearSavedMetrics() {
118 #if BUILDFLAG(ANDROID_JAVA_UI) 122 #if BUILDFLAG(ANDROID_JAVA_UI)
119 PrefService* local_state = g_browser_process->local_state(); 123 PrefService* local_state = g_browser_process->local_state();
120 return !local_state->HasPrefPath(metrics::prefs::kMetricsReportingEnabled) && 124 return !local_state->HasPrefPath(metrics::prefs::kMetricsReportingEnabled) &&
121 metrics::IsCellularLogicEnabled(); 125 metrics::IsCellularLogicEnabled();
122 #else 126 #else
123 return false; 127 return false;
124 #endif 128 #endif
125 } 129 }
126 130
127 void RegisterInstallerFileMetricsPreferences(PrefRegistrySimple* registry) { 131 void RegisterInstallerFileMetricsPreferences(PrefRegistrySimple* registry) {
bcwhite 2016/09/13 14:27:48 How about changing the name of this function while
scottmg 2016/09/13 19:15:32 Done.
128 metrics::FileMetricsProvider::RegisterPrefs( 132 metrics::FileMetricsProvider::RegisterPrefs(
129 registry, ChromeMetricsServiceClient::kBrowserMetricsName); 133 registry, ChromeMetricsServiceClient::kBrowserMetricsName);
130 134
131 #if defined(OS_WIN) 135 #if defined(OS_WIN)
132 metrics::FileMetricsProvider::RegisterPrefs( 136 metrics::FileMetricsProvider::RegisterPrefs(
133 registry, installer::kSetupHistogramAllocatorName); 137 registry, installer::kSetupHistogramAllocatorName);
134 #endif 138 #endif
139
140 metrics::FileMetricsProvider::RegisterPrefs(registry,
bcwhite 2016/09/13 14:27:48 Move above the windows-specific stuff.
scottmg 2016/09/13 19:15:32 Done.
141 kCrashpadHistogramAllocatorName);
135 } 142 }
136 143
137 std::unique_ptr<metrics::FileMetricsProvider> 144 std::unique_ptr<metrics::FileMetricsProvider>
138 CreateInstallerFileMetricsProvider(bool metrics_reporting_enabled) { 145 CreateInstallerFileMetricsProvider(bool metrics_reporting_enabled) {
bcwhite 2016/09/13 14:27:48 How about changing the name of this function while
scottmg 2016/09/13 19:15:32 Done.
139 // Fetch a worker-pool for performing I/O tasks that are not allowed on 146 // Fetch a worker-pool for performing I/O tasks that are not allowed on
140 // the main UI thread. 147 // the main UI thread.
141 scoped_refptr<base::TaskRunner> task_runner = 148 scoped_refptr<base::TaskRunner> task_runner =
142 content::BrowserThread::GetBlockingPool() 149 content::BrowserThread::GetBlockingPool()
143 ->GetTaskRunnerWithShutdownBehavior( 150 ->GetTaskRunnerWithShutdownBehavior(
144 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN); 151 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN);
145 152
146 // Create an object to monitor files of metrics and include them in reports. 153 // Create an object to monitor files of metrics and include them in reports.
147 std::unique_ptr<metrics::FileMetricsProvider> file_metrics_provider( 154 std::unique_ptr<metrics::FileMetricsProvider> file_metrics_provider(
148 new metrics::FileMetricsProvider(task_runner, 155 new metrics::FileMetricsProvider(task_runner,
(...skipping 27 matching lines...) Expand all
176 // Read metrics file from setup.exe. 183 // Read metrics file from setup.exe.
177 base::FilePath program_dir; 184 base::FilePath program_dir;
178 base::PathService::Get(base::DIR_EXE, &program_dir); 185 base::PathService::Get(base::DIR_EXE, &program_dir);
179 file_metrics_provider->RegisterSource( 186 file_metrics_provider->RegisterSource(
180 program_dir.AppendASCII(installer::kSetupHistogramAllocatorName), 187 program_dir.AppendASCII(installer::kSetupHistogramAllocatorName),
181 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_DIR, 188 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_DIR,
182 metrics::FileMetricsProvider::ASSOCIATE_CURRENT_RUN, 189 metrics::FileMetricsProvider::ASSOCIATE_CURRENT_RUN,
183 installer::kSetupHistogramAllocatorName); 190 installer::kSetupHistogramAllocatorName);
184 #endif 191 #endif
185 192
193 // Read the Crashpad metrics file.
bcwhite 2016/09/13 14:27:48 Move above the windows-specific stuff.
scottmg 2016/09/13 19:15:32 Done.
194 base::FilePath crashpad_metrics_file;
195 if (base::PathService::Get(chrome::DIR_CRASH_DUMPS, &crashpad_metrics_file)) {
196 crashpad_metrics_file =
197 crashpad_metrics_file.AppendASCII(kCrashpadHistogramAllocatorName)
198 .AddExtension(base::PersistentMemoryAllocator::kFileExtension);
199 if (metrics_reporting_enabled) {
200 file_metrics_provider->RegisterSource(
201 crashpad_metrics_file,
202 metrics::FileMetricsProvider::SOURCE_HISTOGRAMS_ATOMIC_FILE,
203 metrics::FileMetricsProvider::ASSOCIATE_PREVIOUS_RUN,
204 kCrashpadHistogramAllocatorName);
205 } else {
206 task_runner->PostTask(
207 FROM_HERE, base::Bind(base::IgnoreResult(&base::DeleteFile),
208 crashpad_metrics_file, /*recursive=*/false));
209 }
210 }
211
186 return file_metrics_provider; 212 return file_metrics_provider;
187 } 213 }
188 214
189 // If there is a global metrics file being updated on disk, mark it to be 215 // If there is a global metrics file being updated on disk, mark it to be
190 // deleted when the process exits. A normal shutdown is almost complete 216 // deleted when the process exits. A normal shutdown is almost complete
191 // so there is no benefit in keeping a file with no new data to be processed 217 // so there is no benefit in keeping a file with no new data to be processed
192 // during the next startup sequence. Deleting the file during shutdown adds 218 // during the next startup sequence. Deleting the file during shutdown adds
193 // an extra disk-access or two to shutdown but eliminates the unnecessary 219 // an extra disk-access or two to shutdown but eliminates the unnecessary
194 // processing of the contents during startup only to find nothing. 220 // processing of the contents during startup only to find nothing.
195 void CleanUpGlobalPersistentHistogramStorage() { 221 void CleanUpGlobalPersistentHistogramStorage() {
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 811 }
786 } 812 }
787 813
788 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { 814 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) {
789 metrics_service_->OnApplicationNotIdle(); 815 metrics_service_->OnApplicationNotIdle();
790 } 816 }
791 817
792 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { 818 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() {
793 return metrics::IsCellularLogicEnabled(); 819 return metrics::IsCellularLogicEnabled();
794 } 820 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698