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

Unified Diff: chrome/browser/safe_browsing/certificate_reporting_service_factory.cc

Issue 2503243003: Wire up CertificateReportingService to handle report uploads (Closed)
Patch Set: Rebase Created 4 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/certificate_reporting_service_factory.cc
diff --git a/chrome/browser/safe_browsing/certificate_reporting_service_factory.cc b/chrome/browser/safe_browsing/certificate_reporting_service_factory.cc
index fc1eab154ee65d1b082936cdde0f3e04c19357f8..606e05e7ee7c7c6d07a2f742bec04d901bff95ad 100644
--- a/chrome/browser/safe_browsing/certificate_reporting_service_factory.cc
+++ b/chrome/browser/safe_browsing/certificate_reporting_service_factory.cc
@@ -2,10 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/time/default_clock.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/certificate_reporting_service.h"
#include "chrome/browser/safe_browsing/certificate_reporting_service_factory.h"
+#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
+namespace {
+
+// Maximum age in seconds until a report is dropped from the retry list.
+// By default, reports older than a day are ignored and never retried again.
+static const uint64_t kMaxReportAgeInSeconds = 86400;
+
+// Maximum number of reports to be kept in the report retry list. If an incoming
+// report has a more recent creation date than the oldest report in the list,
+// the oldest report is removed from the list and the incoming report is added.
+// Otherwise, the incoming report is ignored.
+const size_t kMaxReportCountInQueue = 5;
+
+} // namespace
+
// static
CertificateReportingServiceFactory*
CertificateReportingServiceFactory::GetInstance() {
@@ -20,17 +38,49 @@ CertificateReportingServiceFactory::GetForBrowserContext(
GetInstance()->GetServiceForBrowserContext(context, true));
}
+void CertificateReportingServiceFactory::SetReportEncryptionParamsForTesting(
+ uint8_t* server_public_key,
+ uint32_t server_public_key_version) {
+ server_public_key_ = server_public_key;
+ server_public_key_version_ = server_public_key_version;
+}
+
+void CertificateReportingServiceFactory::SetClockForTesting(
+ std::unique_ptr<base::Clock> clock) {
+ clock_ = std::move(clock);
+}
+
+void CertificateReportingServiceFactory::SetQueuedReportTTLForTesting(
+ base::TimeDelta queued_report_ttl) {
+ queued_report_ttl_ = queued_report_ttl;
+}
+
+void CertificateReportingServiceFactory::SetMaxQueuedReportCountForTesting(
+ size_t max_queued_report_count) {
+ max_queued_report_count_ = max_queued_report_count;
+}
+
CertificateReportingServiceFactory::CertificateReportingServiceFactory()
: BrowserContextKeyedServiceFactory(
"cert_reporting::Factory",
- BrowserContextDependencyManager::GetInstance()) {}
+ BrowserContextDependencyManager::GetInstance()),
+ server_public_key_(nullptr),
+ server_public_key_version_(0),
+ clock_(new base::DefaultClock()),
+ queued_report_ttl_(base::TimeDelta::FromSeconds(kMaxReportAgeInSeconds)),
+ max_queued_report_count_(kMaxReportCountInQueue) {}
CertificateReportingServiceFactory::~CertificateReportingServiceFactory() {}
KeyedService* CertificateReportingServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* profile) const {
- // TODO(crbug.com/554323): Create a real CertificateReportingService here.
- return nullptr;
+ safe_browsing::SafeBrowsingService* safe_browsing_service =
+ g_browser_process->safe_browsing_service();
+ return new CertificateReportingService(
+ safe_browsing_service, safe_browsing_service->url_request_context(),
+ static_cast<Profile*>(profile), server_public_key_,
+ server_public_key_version_, max_queued_report_count_, queued_report_ttl_,
+ clock_.get());
}
content::BrowserContext*

Powered by Google App Engine
This is Rietveld 408576698