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

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

Issue 2453093004: Remove dependence on a message loop for net::PathBuilder. (Closed)
Patch Set: remove unnecessary forward decl Created 4 years 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 | « components/cast_certificate/cast_crl.cc ('k') | net/cert/internal/cert_issuer_source.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_CERT_CERT_NET_FETCHER_H_ 5 #ifndef NET_CERT_CERT_NET_FETCHER_H_
6 #define NET_CERT_CERT_NET_FETCHER_H_ 6 #define NET_CERT_CERT_NET_FETCHER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/base/net_export.h" 16 #include "net/base/net_export.h"
17 17
18 class GURL; 18 class GURL;
19 19
20 namespace net { 20 namespace net {
21 21
22 class URLRequestContext; 22 // CertNetFetcher is a synchronous interface for fetching AIA URLs and CRL
23
24 // CertNetFetcher is an asynchronous interface for fetching AIA URLs and CRL
25 // URLs. 23 // URLs.
26 // 24 //
27 // ------------------------- 25 // A Request object is returned when starting a fetch. The consumer can
28 // Cancellation of requests 26 // use this as a handle for aborting the request (by freeing it), or reading
29 // ------------------------- 27 // the result of the request (WaitForResult)
30 // 28 //
31 // * Network requests started by the CertNetFetcher can be cancelled by 29 // This interface is expected to be operated from a single thread.
32 // deleting the Request object. Cancellation means the request's callback
33 // will no longer be invoked.
34 // 30 //
35 // * If the CertNetFetcher is deleted then any outstanding 31 // The CertNetFetcher must outlive all Request objects it creates.
36 // requests are automatically cancelled.
37 //
38 // * Cancelling a request within the execution of a callback is allowed.
39 //
40 // * Deleting the CertNetFetcher from within the execution of a callback is
41 // allowed.
42 //
43 // -------------------------
44 // Threading
45 // -------------------------
46 //
47 // The CertNetFetcher is expected to be operated from a single thread, which has
48 // an IO message loop. The URLRequestContext will be accessed from this same
49 // thread, and callbacks will be posted to this message loop.
50 //
51 // For more details see the design document:
52 // https://docs.google.com/a/chromium.org/document/d/1CdS9YOnPdAyVZBJqHY7ZJ6tU lU71OCvX8kHnaVhf144/edit
53 class NET_EXPORT CertNetFetcher { 32 class NET_EXPORT CertNetFetcher {
54 public: 33 public:
55 class Request { 34 class Request {
56 public: 35 public:
57 virtual ~Request() {} 36 virtual ~Request() {}
37
38 // WaitForResult() can be called at most once.
39 //
40 // It will block and wait for the (network) request to complete, and
41 // then write the result into the provided out-parameters.
42 virtual void WaitForResult(Error* error, std::vector<uint8_t>* bytes) = 0;
58 }; 43 };
59 44
60 // Callback invoked on request completion. If the Error is OK, then the
61 // vector contains the response bytes.
62 using FetchCallback =
63 base::Callback<void(Error, const std::vector<uint8_t>&)>;
64
65 // This value can be used in place of timeout or max size limits. 45 // This value can be used in place of timeout or max size limits.
66 enum { DEFAULT = -1 }; 46 enum { DEFAULT = -1 };
67 47
68 CertNetFetcher() {} 48 CertNetFetcher() {}
69 49
70 // Deletion implicitly cancels any outstanding requests.
71 virtual ~CertNetFetcher() {} 50 virtual ~CertNetFetcher() {}
72 51
73 // The Fetch*() methods start an asynchronous request which can be cancelled 52 // The Fetch*() methods start a request which can be cancelled by
74 // by deleting the returned Request. Here is the meaning of the common 53 // deleting the returned Request. Here is the meaning of the common
75 // parameters: 54 // parameters:
76 // 55 //
77 // * url -- The http:// URL to fetch. 56 // * url -- The http:// URL to fetch.
78 // * timeout_seconds -- The maximum allowed duration for the fetch job. If 57 // * 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 58 // this delay is exceeded then the request will fail. To use a default
80 // timeout pass DEFAULT. 59 // timeout pass DEFAULT.
81 // * max_response_bytes -- The maximum size of the response body. If this 60 // * 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 61 // size is exceeded then the request will fail. To use a default timeout
83 // pass DEFAULT. 62 // pass DEFAULT.
84 // * callback -- The callback that will be invoked on completion of the job.
85 63
86 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers( 64 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers(
87 const GURL& url, 65 const GURL& url,
88 int timeout_milliseconds, 66 int timeout_milliseconds,
89 int max_response_bytes, 67 int max_response_bytes) = 0;
90 const FetchCallback& callback) = 0;
91 68
92 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl( 69 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl(
93 const GURL& url, 70 const GURL& url,
94 int timeout_milliseconds, 71 int timeout_milliseconds,
95 int max_response_bytes, 72 int max_response_bytes) = 0;
96 const FetchCallback& callback) = 0;
97 73
98 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp( 74 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp(
99 const GURL& url, 75 const GURL& url,
100 int timeout_milliseconds, 76 int timeout_milliseconds,
101 int max_response_bytes, 77 int max_response_bytes) = 0;
102 const FetchCallback& callback) = 0;
103 78
104 private: 79 private:
105 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher); 80 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher);
106 }; 81 };
107 82
108 } // namespace net 83 } // namespace net
109 84
110 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_ 85 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_
OLDNEW
« no previous file with comments | « components/cast_certificate/cast_crl.cc ('k') | net/cert/internal/cert_issuer_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698