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 "base/time/default_clock.h" | 5 #include "base/time/default_clock.h" |
6 #include "chrome/browser/browser_process.h" | 6 #include "chrome/browser/browser_process.h" |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" | 8 #include "chrome/browser/safe_browsing/certificate_reporting_service.h" |
9 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" | 9 #include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h" |
10 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 10 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 void CertificateReportingServiceFactory::SetQueuedReportTTLForTesting( | 53 void CertificateReportingServiceFactory::SetQueuedReportTTLForTesting( |
54 base::TimeDelta queued_report_ttl) { | 54 base::TimeDelta queued_report_ttl) { |
55 queued_report_ttl_ = queued_report_ttl; | 55 queued_report_ttl_ = queued_report_ttl; |
56 } | 56 } |
57 | 57 |
58 void CertificateReportingServiceFactory::SetMaxQueuedReportCountForTesting( | 58 void CertificateReportingServiceFactory::SetMaxQueuedReportCountForTesting( |
59 size_t max_queued_report_count) { | 59 size_t max_queued_report_count) { |
60 max_queued_report_count_ = max_queued_report_count; | 60 max_queued_report_count_ = max_queued_report_count; |
61 } | 61 } |
62 | 62 |
| 63 void CertificateReportingServiceFactory::SetServiceResetCallback( |
| 64 const base::Callback<void()>& service_reset_callback) { |
| 65 service_reset_callback_ = service_reset_callback; |
| 66 } |
| 67 |
63 CertificateReportingServiceFactory::CertificateReportingServiceFactory() | 68 CertificateReportingServiceFactory::CertificateReportingServiceFactory() |
64 : BrowserContextKeyedServiceFactory( | 69 : BrowserContextKeyedServiceFactory( |
65 "cert_reporting::Factory", | 70 "cert_reporting::Factory", |
66 BrowserContextDependencyManager::GetInstance()), | 71 BrowserContextDependencyManager::GetInstance()), |
67 server_public_key_(nullptr), | 72 server_public_key_(nullptr), |
68 server_public_key_version_(0), | 73 server_public_key_version_(0), |
69 clock_(new base::DefaultClock()), | 74 clock_(new base::DefaultClock()), |
70 queued_report_ttl_(base::TimeDelta::FromSeconds(kMaxReportAgeInSeconds)), | 75 queued_report_ttl_(base::TimeDelta::FromSeconds(kMaxReportAgeInSeconds)), |
71 max_queued_report_count_(kMaxReportCountInQueue) {} | 76 max_queued_report_count_(kMaxReportCountInQueue), |
| 77 service_reset_callback_(base::Bind(&base::DoNothing)) {} |
72 | 78 |
73 CertificateReportingServiceFactory::~CertificateReportingServiceFactory() {} | 79 CertificateReportingServiceFactory::~CertificateReportingServiceFactory() {} |
74 | 80 |
75 KeyedService* CertificateReportingServiceFactory::BuildServiceInstanceFor( | 81 KeyedService* CertificateReportingServiceFactory::BuildServiceInstanceFor( |
76 content::BrowserContext* profile) const { | 82 content::BrowserContext* profile) const { |
77 safe_browsing::SafeBrowsingService* safe_browsing_service = | 83 safe_browsing::SafeBrowsingService* safe_browsing_service = |
78 g_browser_process->safe_browsing_service(); | 84 g_browser_process->safe_browsing_service(); |
79 return new CertificateReportingService( | 85 return new CertificateReportingService( |
80 safe_browsing_service, safe_browsing_service->url_request_context(), | 86 safe_browsing_service, safe_browsing_service->url_request_context(), |
81 static_cast<Profile*>(profile), server_public_key_, | 87 static_cast<Profile*>(profile), server_public_key_, |
82 server_public_key_version_, max_queued_report_count_, queued_report_ttl_, | 88 server_public_key_version_, max_queued_report_count_, queued_report_ttl_, |
83 clock_.get()); | 89 clock_.get(), service_reset_callback_); |
84 } | 90 } |
85 | 91 |
86 content::BrowserContext* | 92 content::BrowserContext* |
87 CertificateReportingServiceFactory::GetBrowserContextToUse( | 93 CertificateReportingServiceFactory::GetBrowserContextToUse( |
88 content::BrowserContext* context) const { | 94 content::BrowserContext* context) const { |
89 return context; | 95 return context; |
90 } | 96 } |
OLD | NEW |