Index: chrome/browser/net/certificate_error_reporter.h |
diff --git a/chrome/browser/net/certificate_error_reporter.h b/chrome/browser/net/certificate_error_reporter.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9661805826d1a962b8dd97d0ee91814dcb2bdfad |
--- /dev/null |
+++ b/chrome/browser/net/certificate_error_reporter.h |
@@ -0,0 +1,77 @@ |
+// 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. |
+ |
+#ifndef CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ |
+#define CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ |
+ |
+#include <set> |
+#include <string> |
+ |
+#include "net/url_request/url_request.h" |
+ |
+namespace net { |
+class URLRequestContext; |
+} |
+ |
+namespace chrome_browser_net { |
+ |
+class CertLoggerRequest; |
+ |
+// Provides functionality for sending reports about invalid SSL |
+// certificate chains to a report collection server. |
+class CertificateErrorReporter : public net::URLRequest::Delegate { |
+ public: |
+ explicit CertificateErrorReporter(net::URLRequestContext* request_context, |
+ const GURL& upload_url); |
+ |
+ ~CertificateErrorReporter() override; |
+ |
+ enum ReportType { |
Ryan Sleevi
2015/03/06 00:21:32
STYLE: These go first ( http://google-styleguide.g
estark
2015/03/06 02:17:42
Done.
|
+ REPORT_TYPE_PINNING_VIOLATION, |
+ REPORT_TYPE_EXTENDED_REPORTING |
+ }; |
+ |
+ // Allows users of this class to override this and set their own URLRequest |
+ // type. Used by SendReport. |
Ryan Sleevi
2015/03/06 00:21:32
Documentation: From reading the header, I'm not re
estark
2015/03/06 02:17:42
Ok, this was actually a bit broken. CertificateErr
|
+ virtual scoped_ptr<net::URLRequest> CreateURLRequest( |
+ net::URLRequestContext* context); |
+ |
+ // Construct, serialize, and send a certificate reporter to the report |
+ // collection server containing the |ssl_info| associated with a |
+ // connection to |hostname|. |
+ virtual void SendReport(ReportType type, |
+ const std::string& hostname, |
+ const net::SSLInfo& ssl_info); |
+ |
+ // net::URLRequest::Delegate |
+ void OnResponseStarted(net::URLRequest* request) override; |
+ void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
+ |
+ protected: |
+ // Populate the CertLoggerRequest for a report. |
+ static void BuildReport(const std::string& hostname, |
Ryan Sleevi
2015/03/06 00:21:32
Why is this static protected?
It seems like these
estark
2015/03/06 02:17:41
Done.
(Were you also asking why is it static, not
|
+ const net::SSLInfo& ssl_info, |
+ CertLoggerRequest& out_request); |
+ |
+ // Serialize and send a CertLoggerRequest protobuf to the report |
+ // collection server. |
+ void SendCertLoggerRequest(CertLoggerRequest& request); |
+ |
+ net::URLRequestContext* const request_context_; |
Ryan Sleevi
2015/03/06 00:21:32
STYLE: Data members should be private ( http://goo
estark
2015/03/06 02:17:42
Done.
estark
2015/03/06 02:17:42
Done.
|
+ |
+ private: |
+ // Performs post-report cleanup. |
+ void RequestComplete(net::URLRequest* request); |
+ |
+ const GURL upload_url_; |
+ |
+ // Owns the contained requests. |
+ std::set<net::URLRequest*> inflight_requests_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter); |
+}; |
+ |
+} // namespace chrome_browser_net |
+ |
+#endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ |