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.
5 #ifndef NET_CERT_CERT_NET_FETCHER_H_
6 #define NET_CERT_CERT_NET_FETCHER_H_
10 #include "base/callback.h"
11 #include "net/base/net_errors.h"
12 #include "net/base/net_export.h"
18 class URLRequestContext
;
20 // CertNetFetcher is an asynchronous interface for fetching AIA URLs and CRL
23 // -------------------------
24 // Cancellation of requests
25 // -------------------------
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.
31 // * If the CertNetFetcher is deleted then any outstanding
32 // requests are automatically cancelled.
34 // * Cancelling a request within the execution of a callback is allowed.
36 // * Deleting the CertNetFetcher from within the execution of a callback is
39 // -------------------------
41 // -------------------------
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.
47 // For more details see the design document:
48 // https://docs.google.com/a/chromium.org/document/d/1CdS9YOnPdAyVZBJqHY7ZJ6tUlU71OCvX8kHnaVhf144/edit
49 class NET_EXPORT CertNetFetcher
{
56 // Callback invoked on request completion. If the Error is OK, then the
57 // vector contains the response bytes.
59 base::Callback
<void(Error
, const std::vector
<uint8_t>&)>;
61 // This value can be used in place of timeout or max size limits.
62 enum { DEFAULT
= -1 };
66 // Deletion implicitly cancels any outstanding requests.
67 virtual ~CertNetFetcher() {}
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
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
80 // * callback -- The callback that will be invoked on completion of the job.
82 virtual WARN_UNUSED_RESULT scoped_ptr
<Request
> FetchCaIssuers(
84 int timeout_milliseconds
,
85 int max_response_bytes
,
86 const FetchCallback
& callback
) = 0;
88 virtual WARN_UNUSED_RESULT scoped_ptr
<Request
> FetchCrl(
90 int timeout_milliseconds
,
91 int max_response_bytes
,
92 const FetchCallback
& callback
) = 0;
94 virtual WARN_UNUSED_RESULT scoped_ptr
<Request
> FetchOcsp(
96 int timeout_milliseconds
,
97 int max_response_bytes
,
98 const FetchCallback
& callback
) = 0;
101 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher
);
106 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_