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/memory/scoped_ptr.h" | |
12 #include "net/url_request/url_request.h" | |
13 #include "url/gurl.h" | |
14 | |
15 namespace net { | |
16 class URLRequestContext; | |
17 class SSLInfo; | |
18 } | |
19 | |
20 namespace chrome_browser_net { | |
21 | |
22 class CertLoggerRequest; | |
23 | |
24 // Provides functionality for sending reports about invalid SSL | |
25 // certificate chains to a report collection server. | |
26 class CertificateErrorReporter : public net::URLRequest::Delegate { | |
27 public: | |
28 enum ReportType { | |
29 REPORT_TYPE_PINNING_VIOLATION, | |
30 REPORT_TYPE_EXTENDED_REPORTING | |
31 }; | |
32 | |
33 CertificateErrorReporter(net::URLRequestContext* request_context, | |
34 const GURL& upload_url); | |
35 | |
36 ~CertificateErrorReporter() override; | |
37 | |
38 // Construct, serialize, and send a certificate reporter to the report | |
39 // collection server containing the |ssl_info| associated with a | |
40 // connection to |hostname|. | |
41 virtual void SendReport(ReportType type, | |
42 const std::string& hostname, | |
43 const net::SSLInfo& ssl_info); | |
44 | |
45 // net::URLRequest::Delegate | |
46 void OnResponseStarted(net::URLRequest* request) override; | |
47 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | |
48 | |
49 private: | |
50 // Create a URLRequest with which to send a certificate report to the | |
51 // server. | |
52 virtual scoped_ptr<net::URLRequest> CreateURLRequest( | |
53 net::URLRequestContext* context); | |
54 | |
55 // Serialize and send a CertLoggerRequest protobuf to the report | |
56 // collection server. | |
57 void SendCertLoggerRequest(const CertLoggerRequest& request); | |
58 | |
59 // Populate the CertLoggerRequest for a report. | |
60 static void BuildReport(const std::string& hostname, | |
61 const net::SSLInfo& ssl_info, | |
62 CertLoggerRequest* out_request); | |
63 | |
64 // Performs post-report cleanup. | |
65 void RequestComplete(net::URLRequest* request); | |
66 | |
67 net::URLRequestContext* const request_context_; | |
68 const GURL upload_url_; | |
69 | |
70 // Owns the contained requests. | |
71 std::set<net::URLRequest*> inflight_requests_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter); | |
mmenke
2015/03/11 15:34:28
nit: Include macros.h for DISALLOW_COPY_AND_ASSIG
estark
2015/03/11 22:19:10
Done.
| |
74 }; | |
75 | |
76 } // namespace chrome_browser_net | |
77 | |
78 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_ | |
OLD | NEW |