summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/chrome_fraudulent_certificate_reporter.h
blob: e49c173382be5b6a9646f1d8d00e63d7b3838df9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2011 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_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_
#define CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_
#pragma once

#include <set>
#include <string>

#include "net/url_request/fraudulent_certificate_reporter.h"
#include "net/url_request/url_request.h"

namespace chrome_browser_net {

class ChromeFraudulentCertificateReporter
    : public net::FraudulentCertificateReporter,
      public net::URLRequest::Delegate {
 public:
  explicit ChromeFraudulentCertificateReporter(
      net::URLRequestContext* request_context);

  virtual ~ChromeFraudulentCertificateReporter();

  // Allows users of this class to override this and set their own URLRequest
  // type. Used by SendReport.
  virtual net::URLRequest* CreateURLRequest();

  // net::FraudulentCertificateReporter
  virtual void SendReport(const std::string& hostname,
                          const net::SSLInfo& ssl_info,
                          bool sni_available) OVERRIDE;

  // net::URLRequest::Delegate
  virtual void OnResponseStarted(net::URLRequest* request) OVERRIDE;
  virtual void OnReadCompleted(net::URLRequest* request,
                               int bytes_read) OVERRIDE;

 protected:
  net::URLRequestContext* const request_context_;

 private:
  // Performs post-report cleanup.
  void RequestComplete(net::URLRequest* request);

  const GURL upload_url_;
  std::set<net::URLRequest*> inflight_requests_;

  DISALLOW_COPY_AND_ASSIGN(ChromeFraudulentCertificateReporter);
};

}  // namespace chrome_browser_net

#endif  // CHROME_BROWSER_NET_CHROME_FRAUDULENT_CERTIFICATE_REPORTER_H_