Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(383)

Side by Side Diff: net/cert/cert_net_fetcher.h

Issue 908863004: Initial implementation for CertNetFetcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address more feedback Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/cert_net/README » ('j') | net/cert_net/README » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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. Implementations are responsible for issuing and managing the requests.
22 //
23 // -------------------------
24 // Cancellation of requests
25 // -------------------------
26 //
27 // * Network requests started by the CertNetFetcher can be cancelled using
28 // CancelRequest(). Cancellation means the callback will not be invoked.
29 //
30 // * If the CertNetFetcher is deleted then any outstanding
31 // requests are automatically cancelled.
32 //
33 // * Cancelling a request more than once is an error (and may result in a
34 // use-after-free).
35 //
36 // * Cancelling a request within the execution of a callback is allowed.
37 //
38 // * Deleting the CertNetFetcher from within the execution of a callback is
39 // allowed.
40 //
41 // -------------------------
42 // Threading
43 // -------------------------
44 //
45 // The CertNetFetcher is expected to be operated from a single thread, which has
46 // an IO message loop. The URLRequestContext will be accessed from this same
47 // thread, and callbacks will be posted to this message loop.
48 //
49 // For more details see the design document:
50 // https://docs.google.com/a/chromium.org/document/d/1CdS9YOnPdAyVZBJqHY7ZJ6tU lU71OCvX8kHnaVhf144/edit
51 class NET_EXPORT CertNetFetcher {
52 public:
53 // Callback invoked on request completion. If the Error is OK, then the
54 // vector contains the response bytes.
55 using FetchCallback =
56 base::Callback<void(Error, const std::vector<uint8_t>&)>;
57
58 // Opaque handled used to cancel requests.
59 using RequestId = void*;
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 // Cancels the indicated request. It is an error to call this function on a
70 // request which has already completed (including one that was already
71 // cancelled).
72 virtual void CancelRequest(RequestId request) = 0;
davidben 2015/03/27 23:34:31 Rather than CancelRequest, perhaps: class Request
eroman 2015/04/04 21:57:14 Done. I agree this is cleaner, I think we should
73
74 // The Fetch*() methods start an asynchronous request which can be cancelled
75 // using RequestId. Here is the meaning of the common parameters:
76 //
77 // * url -- The http:// URL to fetch.
78 // * timeout_seconds -- The maximum allowed duration for the fetch job. If
79 // this delay is exceeded then the request will fail. To use a default
80 // timeout pass DEFAULT.
81 // * max_response_bytes -- The maximum size of the response body. If this
82 // size is exceeded then the request will fail. To use a default timeout
83 // pass DEFAULT.
84 // * callback -- The callback that will be invoked on completion of the job.
85
86 virtual RequestId FetchCaIssuers(const GURL& url,
87 int timeout_milliseconds,
88 int max_response_bytes,
89 const FetchCallback& callback) = 0;
davidben 2015/03/27 23:34:31 Maybe for a followup, but since we want to be able
eroman 2015/04/04 21:57:14 +1 on NetLog integration. I will add that as a fol
90
91 virtual RequestId FetchCrl(const GURL& url,
92 int timeout_milliseconds,
93 int max_response_bytes,
94 const FetchCallback& callback) = 0;
95
96 virtual RequestId FetchOcsp(const GURL& url,
97 int timeout_milliseconds,
98 int max_response_bytes,
99 const FetchCallback& callback) = 0;
100
101 private:
102 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher);
103 };
104
105 } // namespace net
106
107 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_
OLDNEW
« no previous file with comments | « no previous file | net/cert_net/README » ('j') | net/cert_net/README » ('J')

Powered by Google App Engine
This is Rietveld 408576698