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

Unified Diff: chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc

Issue 1117173004: Split cert reporter class into report building/serializing and sending (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: document parse/serialize return value Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc
diff --git a/chrome/browser/net/chrome_fraudulent_certificate_reporter.cc b/chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc
similarity index 61%
rename from chrome/browser/net/chrome_fraudulent_certificate_reporter.cc
rename to chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc
index 1c6dd486a5bccec9f0b10507beba7e8eb93d1f24..a4c7b9a062ed08057430ff43fd64b8534453c760 100644
--- a/chrome/browser/net/chrome_fraudulent_certificate_reporter.cc
+++ b/chrome/browser/ssl/chrome_fraudulent_certificate_reporter.cc
@@ -1,11 +1,12 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h"
+#include "chrome/browser/ssl/chrome_fraudulent_certificate_reporter.h"
#include "base/profiler/scoped_tracker.h"
#include "chrome/browser/net/certificate_error_reporter.h"
+#include "chrome/browser/ssl/certificate_error_report.h"
#include "net/ssl/ssl_info.h"
#include "net/url_request/url_request_context.h"
#include "url/gurl.h"
@@ -19,18 +20,19 @@ const char kFraudulentCertificateUploadEndpoint[] =
} // namespace
-namespace chrome_browser_net {
+namespace chrome_browser_ssl {
ChromeFraudulentCertificateReporter::ChromeFraudulentCertificateReporter(
net::URLRequestContext* request_context)
- : certificate_reporter_(new CertificateErrorReporter(
+ : certificate_reporter_(new chrome_browser_net::CertificateErrorReporter(
request_context,
GURL(kFraudulentCertificateUploadEndpoint),
- CertificateErrorReporter::DO_NOT_SEND_COOKIES)) {
+ chrome_browser_net::CertificateErrorReporter::DO_NOT_SEND_COOKIES)) {
}
ChromeFraudulentCertificateReporter::ChromeFraudulentCertificateReporter(
- scoped_ptr<CertificateErrorReporter> certificate_reporter)
+ scoped_ptr<chrome_browser_net::CertificateErrorReporter>
+ certificate_reporter)
: certificate_reporter_(certificate_reporter.Pass()) {
}
@@ -45,9 +47,16 @@ void ChromeFraudulentCertificateReporter::SendReport(
if (!net::TransportSecurityState::IsGooglePinnedProperty(hostname))
return;
- certificate_reporter_->SendReport(
- CertificateErrorReporter::REPORT_TYPE_PINNING_VIOLATION, hostname,
- ssl_info);
+ CertificateErrorReport report(hostname, ssl_info);
+ std::string serialized_report;
+ if (report.Serialize(&serialized_report)) {
+ certificate_reporter_->SendReport(
+ chrome_browser_net::CertificateErrorReporter::
+ REPORT_TYPE_PINNING_VIOLATION,
+ serialized_report);
+ } else {
+ LOG(ERROR) << "Failed to serialize pinning violation report.";
+ }
Ryan Sleevi 2015/05/13 01:02:12 In general, we prefer error handling first if (!r
estark 2015/05/13 01:44:49 Done.
}
-} // namespace chrome_browser_net
+} // namespace chrome_browser_ssl

Powered by Google App Engine
This is Rietveld 408576698