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 NET_CERT_CERT_NET_FETCHER_H_ |
| 6 #define NET_CERT_CERT_NET_FETCHER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "net/base/net_errors.h" |
| 12 #include "net/base/net_export.h" |
| 13 |
| 14 class GURL; |
| 15 |
| 16 namespace net { |
| 17 |
| 18 class URLRequestContext; |
| 19 |
| 20 // CertNetFetcher is an asynchronous interface for fetching AIA URLs and CRL |
| 21 // URLs. |
| 22 // |
| 23 // ------------------------- |
| 24 // Cancellation of requests |
| 25 // ------------------------- |
| 26 // |
| 27 // * Network requests started by the CertNetFetcher can be cancelled by |
| 28 // deleting the Request object. Cancellation means the request's callback |
| 29 // will no longer be invoked. |
| 30 // |
| 31 // * If the CertNetFetcher is deleted then any outstanding |
| 32 // requests are automatically cancelled. |
| 33 // |
| 34 // * Cancelling a request within the execution of a callback is allowed. |
| 35 // |
| 36 // * Deleting the CertNetFetcher from within the execution of a callback is |
| 37 // allowed. |
| 38 // |
| 39 // ------------------------- |
| 40 // Threading |
| 41 // ------------------------- |
| 42 // |
| 43 // The CertNetFetcher is expected to be operated from a single thread, which has |
| 44 // an IO message loop. The URLRequestContext will be accessed from this same |
| 45 // thread, and callbacks will be posted to this message loop. |
| 46 // |
| 47 // For more details see the design document: |
| 48 // https://docs.google.com/a/chromium.org/document/d/1CdS9YOnPdAyVZBJqHY7ZJ6tU
lU71OCvX8kHnaVhf144/edit |
| 49 class NET_EXPORT CertNetFetcher { |
| 50 public: |
| 51 class Request { |
| 52 public: |
| 53 virtual ~Request() {} |
| 54 }; |
| 55 |
| 56 // Callback invoked on request completion. If the Error is OK, then the |
| 57 // vector contains the response bytes. |
| 58 using FetchCallback = |
| 59 base::Callback<void(Error, const std::vector<uint8_t>&)>; |
| 60 |
| 61 // This value can be used in place of timeout or max size limits. |
| 62 enum { DEFAULT = -1 }; |
| 63 |
| 64 CertNetFetcher() {} |
| 65 |
| 66 // Deletion implicitly cancels any outstanding requests. |
| 67 virtual ~CertNetFetcher() {} |
| 68 |
| 69 // The Fetch*() methods start an asynchronous request which can be cancelled |
| 70 // by deleting the returned Request. Here is the meaning of the common |
| 71 // parameters: |
| 72 // |
| 73 // * url -- The http:// URL to fetch. |
| 74 // * timeout_seconds -- The maximum allowed duration for the fetch job. If |
| 75 // this delay is exceeded then the request will fail. To use a default |
| 76 // timeout pass DEFAULT. |
| 77 // * max_response_bytes -- The maximum size of the response body. If this |
| 78 // size is exceeded then the request will fail. To use a default timeout |
| 79 // pass DEFAULT. |
| 80 // * callback -- The callback that will be invoked on completion of the job. |
| 81 |
| 82 virtual WARN_UNUSED_RESULT scoped_ptr<Request> FetchCaIssuers( |
| 83 const GURL& url, |
| 84 int timeout_milliseconds, |
| 85 int max_response_bytes, |
| 86 const FetchCallback& callback) = 0; |
| 87 |
| 88 virtual WARN_UNUSED_RESULT scoped_ptr<Request> FetchCrl( |
| 89 const GURL& url, |
| 90 int timeout_milliseconds, |
| 91 int max_response_bytes, |
| 92 const FetchCallback& callback) = 0; |
| 93 |
| 94 virtual WARN_UNUSED_RESULT scoped_ptr<Request> FetchOcsp( |
| 95 const GURL& url, |
| 96 int timeout_milliseconds, |
| 97 int max_response_bytes, |
| 98 const FetchCallback& callback) = 0; |
| 99 |
| 100 private: |
| 101 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher); |
| 102 }; |
| 103 |
| 104 } // namespace net |
| 105 |
| 106 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_ |
OLD | NEW |