Remove linux_chromium_gn_dbg from the chromium CQ.
[chromium-blink-merge.git] / net / cert / cert_net_fetcher.h
blob2d19e14a27e82fd728403c8513b425e1f439204e
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_
8 #include <vector>
10 #include "base/callback.h"
11 #include "net/base/net_errors.h"
12 #include "net/base/net_export.h"
14 class GURL;
16 namespace net {
18 class URLRequestContext;
20 // CertNetFetcher is an asynchronous interface for fetching AIA URLs and CRL
21 // URLs.
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
37 // allowed.
39 // -------------------------
40 // Threading
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 {
50 public:
51 class Request {
52 public:
53 virtual ~Request() {}
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>&)>;
61 // This value can be used in place of timeout or max size limits.
62 enum { DEFAULT = -1 };
64 CertNetFetcher() {}
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
71 // parameters:
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.
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;
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;
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;
100 private:
101 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher);
104 } // namespace net
106 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_