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

Side by Side Diff: chrome/browser/net/certificate_error_reporter.h

Issue 979893003: Refactor ChromeFraudulentCertReporter for code reuse by SSL reporting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rsleevi's comments + fix CreateURLRequest confusion Created 5 years, 9 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 unified diff | Download patch
OLDNEW
(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/gtest_prod_util.h"
12 #include "net/url_request/url_request.h"
13
14 namespace net {
15 class URLRequestContext;
16 }
17
18 namespace chrome_browser_net {
19
20 class CertLoggerRequest;
21
22 // Provides functionality for sending reports about invalid SSL
23 // certificate chains to a report collection server.
24 class CertificateErrorReporter : public net::URLRequest::Delegate {
25 public:
26 enum ReportType {
27 REPORT_TYPE_PINNING_VIOLATION,
28 REPORT_TYPE_EXTENDED_REPORTING
29 };
30
31 explicit CertificateErrorReporter(net::URLRequestContext* request_context,
Ryan Sleevi 2015/03/06 19:23:13 You don't need explicit here because it's a two-ar
estark 2015/03/06 20:10:02 Done.
32 const GURL& upload_url);
33
34 ~CertificateErrorReporter() override;
35
36 // Construct, serialize, and send a certificate reporter to the report
37 // collection server containing the |ssl_info| associated with a
38 // connection to |hostname|.
39 virtual void SendReport(ReportType type,
40 const std::string& hostname,
41 const net::SSLInfo& ssl_info);
42
43 // net::URLRequest::Delegate
44 void OnResponseStarted(net::URLRequest* request) override;
45 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
46
47 private:
48 // Allow tests to access private data members.
49 FRIEND_TEST_ALL_PREFIXES(CertificateErrorReporterTest,
50 ReportIsBuiltCorrectly);
51
52 // Create a URLRequest with which to send a certificate report to the
53 // server.
54 virtual scoped_ptr<net::URLRequest> CreateURLRequest(
55 net::URLRequestContext* context);
56
57 // Serialize and send a CertLoggerRequest protobuf to the report
58 // collection server.
59 void SendCertLoggerRequest(CertLoggerRequest& request);
60
61 // Populate the CertLoggerRequest for a report.
62 static void BuildReport(const std::string& hostname,
63 const net::SSLInfo& ssl_info,
64 CertLoggerRequest& out_request);
65
66 // Performs post-report cleanup.
67 void RequestComplete(net::URLRequest* request);
68
69 net::URLRequestContext* const request_context_;
70 const GURL upload_url_;
71
72 // Owns the contained requests.
73 std::set<net::URLRequest*> inflight_requests_;
74
75 DISALLOW_COPY_AND_ASSIGN(CertificateErrorReporter);
76 };
77
78 } // namespace chrome_browser_net
79
80 #endif // CHROME_BROWSER_NET_CERTIFICATE_ERROR_REPORTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698