Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ | |
| 6 #define CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ | |
| 7 | |
| 8 #include <set> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "net/url_request/url_request.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace net { | |
| 17 class URLRequestContext; | |
| 18 class SSLInfo; | |
| 19 } | |
| 20 | |
| 21 namespace chrome_browser_net { | |
| 22 | |
| 23 class CertLoggerRequest; | |
| 24 | |
| 25 // Provides functionality for sending reports about invalid SSL | |
| 26 // certificate chains to a report collection server. | |
| 27 class CertificateErrorReporter : public net::URLRequest::Delegate { | |
| 28 public: | |
| 29 enum ReportType { | |
| 30 REPORT_TYPE_PINNING_VIOLATION, | |
| 31 REPORT_TYPE_EXTENDED_REPORTING | |
| 32 }; | |
|
Ryan Sleevi
2015/03/12 05:15:05
Enhance. Enhance.
(With documentation)
estark
2015/03/12 14:21:48
Done.
| |
| 33 | |
| 34 CertificateErrorReporter(net::URLRequestContext* request_context, | |
|
Ryan Sleevi
2015/03/12 05:15:05
Document
// Create a certificate error reporter t
estark
2015/03/12 14:21:48
Done.
| |
| 35 const GURL& upload_url); | |
| 36 | |
| 37 ~CertificateErrorReporter() override; | |
| 38 | |
| 39 // Construct, serialize, and send a certificate reporter to the report | |
| 40 // collection server containing the |ssl_info| associated with a | |
| 41 // connection to |hostname|. | |
| 42 virtual void SendReport(ReportType type, | |
| 43 const std::string& hostname, | |
| 44 const net::SSLInfo& ssl_info); | |
| 45 | |
| 46 // net::URLRequest::Delegate | |
| 47 void OnResponseStarted(net::URLRequest* request) override; | |
| 48 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | |
| 49 | |
| 50 private: | |
| 51 // Create a URLRequest with which to send a certificate report to the | |
| 52 // server. | |
| 53 virtual scoped_ptr<net::URLRequest> CreateURLRequest( | |
| 54 net::URLRequestContext* context); | |
| 55 | |
| 56 // Serialize and send a CertLoggerRequest protobuf to the report | |
| 57 // collection server. | |
| 58 void SendCertLoggerRequest(const CertLoggerRequest& request); | |
| 59 | |
| 60 // Populate the CertLoggerRequest for a report. | |
| 61 static void BuildReport(const std::string& hostname, | |
| 62 const net::SSLInfo& ssl_info, | |
| 63 CertLoggerRequest* out_request); | |
| 64 | |
| 65 // Performs post-report cleanup. | |
| 66 void RequestComplete(net::URLRequest* request); | |
| 67 | |
| 68 net::URLRequestContext* const request_context_; | |
| 69 const GURL upload_url_; | |
| 70 | |
| 71 // Owns the contained requests. | |
| 72 std::set<net::URLRequest*> inflight_requests_; | |
| 73 | |
| 74 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter); | |
| 75 }; | |
| 76 | |
| 77 } // namespace chrome_browser_net | |
| 78 | |
| 79 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ | |
| OLD | NEW |