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

Side by Side Diff: chrome/browser/net/chrome_fraudulent_certificate_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: use URLRequestMockDataJob to avoid IO in unit test 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_ 5 #ifndef CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_
6 #define CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_ 6 #define CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h"
11 #include "net/url_request/fraudulent_certificate_reporter.h" 12 #include "net/url_request/fraudulent_certificate_reporter.h"
12 #include "net/url_request/url_request.h"
13 13
14 namespace net { 14 namespace net {
15 class URLRequestContext; 15 class URLRequestContext;
16 } 16 }
17 17
18 namespace chrome_browser_net { 18 namespace chrome_browser_net {
19 19
20 class CertificateErrorReporter;
21
20 class ChromeFraudulentCertificateReporter 22 class ChromeFraudulentCertificateReporter
21 : public net::FraudulentCertificateReporter, 23 : public net::FraudulentCertificateReporter {
22 public net::URLRequest::Delegate {
23 public: 24 public:
24 explicit ChromeFraudulentCertificateReporter( 25 explicit ChromeFraudulentCertificateReporter(
25 net::URLRequestContext* request_context); 26 net::URLRequestContext* request_context);
26 27
28 // Useful for tests to use a mock reporter.
29 explicit ChromeFraudulentCertificateReporter(
30 scoped_ptr<CertificateErrorReporter> certificate_reporter);
31
27 ~ChromeFraudulentCertificateReporter() override; 32 ~ChromeFraudulentCertificateReporter() override;
28 33
29 // Allows users of this class to override this and set their own URLRequest
30 // type. Used by SendReport.
31 virtual scoped_ptr<net::URLRequest> CreateURLRequest(
32 net::URLRequestContext* context);
33
34 // net::FraudulentCertificateReporter 34 // net::FraudulentCertificateReporter
35 void SendReport(const std::string& hostname, 35 void SendReport(const std::string& hostname,
36 const net::SSLInfo& ssl_info) override; 36 const net::SSLInfo& ssl_info) override;
37 37
38 // net::URLRequest::Delegate
39 void OnResponseStarted(net::URLRequest* request) override;
40 void OnReadCompleted(net::URLRequest* request, int bytes_read) override;
41
42 protected:
43 net::URLRequestContext* const request_context_;
44
45 private: 38 private:
46 // Performs post-report cleanup. 39 scoped_ptr<CertificateErrorReporter> certificate_reporter_;
47 void RequestComplete(net::URLRequest* request);
48
49 const GURL upload_url_;
50 // Owns the contained requests.
51 std::set<net::URLRequest*> inflight_requests_;
52 40
53 DISALLOW_COPY_AND_ASSIGN(ChromeFraudulentCertificateReporter); 41 DISALLOW_COPY_AND_ASSIGN(ChromeFraudulentCertificateReporter);
54 }; 42 };
55 43
56 } // namespace chrome_browser_net 44 } // namespace chrome_browser_net
57 45
58 #endif // CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_ 46 #endif // CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_
59
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698