| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 NET_URL_REQUEST_CERTIFICATE_REPORT_SENDER_H_ | 5 #ifndef NET_URL_REQUEST_CERTIFICATE_REPORT_SENDER_H_ |
| 6 #define NET_URL_REQUEST_CERTIFICATE_REPORT_SENDER_H_ | 6 #define NET_URL_REQUEST_CERTIFICATE_REPORT_SENDER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 13 #include "net/http/transport_security_state.h" | 14 #include "net/http/transport_security_state.h" |
| 14 #include "net/url_request/url_request.h" | 15 #include "net/url_request/url_request.h" |
| 15 | 16 |
| 16 class GURL; | 17 class GURL; |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| 19 | 20 |
| 20 class URLRequestContext; | 21 class URLRequestContext; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 // Represents whether or not to send cookies along with reports. | 33 // Represents whether or not to send cookies along with reports. |
| 33 enum CookiesPreference { SEND_COOKIES, DO_NOT_SEND_COOKIES }; | 34 enum CookiesPreference { SEND_COOKIES, DO_NOT_SEND_COOKIES }; |
| 34 | 35 |
| 35 // Constructs a CertificateReportSender that sends reports with the | 36 // Constructs a CertificateReportSender that sends reports with the |
| 36 // given |request_context| and includes or excludes cookies based on | 37 // given |request_context| and includes or excludes cookies based on |
| 37 // |cookies_preference|. |request_context| must outlive the | 38 // |cookies_preference|. |request_context| must outlive the |
| 38 // CertificateReportSender. | 39 // CertificateReportSender. |
| 39 CertificateReportSender(URLRequestContext* request_context, | 40 CertificateReportSender(URLRequestContext* request_context, |
| 40 CookiesPreference cookies_preference); | 41 CookiesPreference cookies_preference); |
| 41 | 42 |
| 43 // Constructs a CertificateReportSender that sends reports with the |
| 44 // given |request_context| and includes or excludes cookies based on |
| 45 // |cookies_preference|. |request_context| must outlive the |
| 46 // CertificateReportSender. When sending a report results in an error, |
| 47 // |error_callback| is called with a pointer to the URLRequest as an |
| 48 // argument. |
| 49 CertificateReportSender( |
| 50 URLRequestContext* request_context, |
| 51 CookiesPreference cookies_preference, |
| 52 const base::Callback<void(URLRequest*)>& error_callback); |
| 53 |
| 42 ~CertificateReportSender() override; | 54 ~CertificateReportSender() override; |
| 43 | 55 |
| 44 // TransportSecurityState::ReportSender implementation. | 56 // TransportSecurityState::ReportSender implementation. |
| 45 void Send(const GURL& report_uri, const std::string& report) override; | 57 void Send(const GURL& report_uri, const std::string& report) override; |
| 46 | 58 |
| 47 // net::URLRequest::Delegate implementation. | 59 // net::URLRequest::Delegate implementation. |
| 48 void OnResponseStarted(URLRequest* request) override; | 60 void OnResponseStarted(URLRequest* request) override; |
| 49 void OnReadCompleted(URLRequest* request, int bytes_read) override; | 61 void OnReadCompleted(URLRequest* request, int bytes_read) override; |
| 50 | 62 |
| 51 private: | 63 private: |
| 52 net::URLRequestContext* const request_context_; | 64 net::URLRequestContext* const request_context_; |
| 53 | 65 |
| 54 CookiesPreference cookies_preference_; | 66 CookiesPreference cookies_preference_; |
| 55 | 67 |
| 56 // Owns the contained requests. | 68 // Owns the contained requests. |
| 57 std::set<URLRequest*> inflight_requests_; | 69 std::set<URLRequest*> inflight_requests_; |
| 58 | 70 |
| 71 // Called when a sent report results in an error. |
| 72 base::Callback<void(URLRequest* request)> error_callback_; |
| 73 |
| 59 DISALLOW_COPY_AND_ASSIGN(CertificateReportSender); | 74 DISALLOW_COPY_AND_ASSIGN(CertificateReportSender); |
| 60 }; | 75 }; |
| 61 | 76 |
| 62 } // namespace net | 77 } // namespace net |
| 63 | 78 |
| 64 #endif // NET_URL_REQUEST_CERTIFICATE_REPORT_H_ | 79 #endif // NET_URL_REQUEST_CERTIFICATE_REPORT_H_ |
| OLD | NEW |