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 "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" | 5 #include "chrome/browser/safe_browsing/certificate_reporting_metrics_provider.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/profile_manager.h" | 8 #include "chrome/browser/profiles/profile_manager.h" |
9 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" | 9 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
10 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" | 10 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" |
11 | 11 |
12 CertificateReportingMetricsProvider::CertificateReportingMetricsProvider() {} | 12 CertificateReportingMetricsProvider::CertificateReportingMetricsProvider() {} |
13 | 13 |
14 CertificateReportingMetricsProvider::~CertificateReportingMetricsProvider() {} | 14 CertificateReportingMetricsProvider::~CertificateReportingMetricsProvider() {} |
15 | 15 |
16 void CertificateReportingMetricsProvider::ProvideGeneralMetrics( | 16 void CertificateReportingMetricsProvider::ProvideGeneralMetrics( |
17 metrics::ChromeUserMetricsExtension* unused) {} | 17 metrics::ChromeUserMetricsExtension* unused) { |
| 18 // When ProvideGeneralMetrics is called, this class is being asked to provide |
| 19 // metrics to the metrics service. It doesn't provide any metrics though, |
| 20 // instead it tells CertificateReportingService to upload any pending reports. |
| 21 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 22 if (!profile_manager) |
| 23 return; |
| 24 |
| 25 // Do not try to create profile here if it does not exist, because this method |
| 26 // can be called during browser shutdown. |
| 27 Profile* profile = profile_manager->GetProfileByPath( |
| 28 profile_manager->GetLastUsedProfileDir(profile_manager->user_data_dir())); |
| 29 if (!profile) |
| 30 return; |
| 31 |
| 32 CertificateReportingService* service = |
| 33 CertificateReportingServiceFactory::GetForBrowserContext(profile); |
| 34 if (service) |
| 35 service->SendPending(); |
| 36 } |
OLD | NEW |