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

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

Issue 2453093004: Remove dependence on a message loop for net::PathBuilder. (Closed)
Patch Set: Created 4 years, 1 month 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
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 class URLRequestContext;
23 23
24 // CertNetFetcher is an asynchronous interface for fetching AIA URLs and CRL 24 // CertNetFetcher is a synchronous interface for fetching AIA URLs and CRL
25 // URLs. 25 // URLs.
26 // 26 //
27 // ------------------------- 27 // A Request object is returned when starting a fetch. The consumer can
28 // Cancellation of requests 28 // use this as a handle for aborting the request (by freeing it), or reading
29 // ------------------------- 29 // the result of the request (WaitForResult)
30 // 30 //
31 // * Network requests started by the CertNetFetcher can be cancelled by 31 // 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 // 32 //
35 // * If the CertNetFetcher is deleted then any outstanding 33 // 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 { 34 class NET_EXPORT CertNetFetcher {
54 public: 35 public:
55 class Request { 36 class Request {
56 public: 37 public:
57 virtual ~Request() {} 38 virtual ~Request() {}
39
40 // WaitForResult() can be called at most once.
41 //
42 // It will block and wait for the (network) request to complete, and
43 // then write the result into the provided out-parameters.
44 virtual void WaitForResult(Error* error, std::vector<uint8_t>* bytes) = 0;
58 }; 45 };
59 46
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. 47 // This value can be used in place of timeout or max size limits.
66 enum { DEFAULT = -1 }; 48 enum { DEFAULT = -1 };
67 49
68 CertNetFetcher() {} 50 CertNetFetcher() {}
69 51
70 // Deletion implicitly cancels any outstanding requests.
71 virtual ~CertNetFetcher() {} 52 virtual ~CertNetFetcher() {}
72 53
73 // The Fetch*() methods start an asynchronous request which can be cancelled 54 // The Fetch*() methods start a request which can be cancelled by
74 // by deleting the returned Request. Here is the meaning of the common 55 // deleting the returned Request. Here is the meaning of the common
75 // parameters: 56 // parameters:
76 // 57 //
77 // * url -- The http:// URL to fetch. 58 // * url -- The http:// URL to fetch.
78 // * timeout_seconds -- The maximum allowed duration for the fetch job. If 59 // * 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 60 // this delay is exceeded then the request will fail. To use a default
80 // timeout pass DEFAULT. 61 // timeout pass DEFAULT.
81 // * max_response_bytes -- The maximum size of the response body. If this 62 // * 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 63 // size is exceeded then the request will fail. To use a default timeout
83 // pass DEFAULT. 64 // pass DEFAULT.
84 // * callback -- The callback that will be invoked on completion of the job.
85 65
86 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers( 66 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCaIssuers(
87 const GURL& url, 67 const GURL& url,
88 int timeout_milliseconds, 68 int timeout_milliseconds,
89 int max_response_bytes, 69 int max_response_bytes) = 0;
90 const FetchCallback& callback) = 0;
91 70
92 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl( 71 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchCrl(
93 const GURL& url, 72 const GURL& url,
94 int timeout_milliseconds, 73 int timeout_milliseconds,
95 int max_response_bytes, 74 int max_response_bytes) = 0;
96 const FetchCallback& callback) = 0;
97 75
98 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp( 76 virtual WARN_UNUSED_RESULT std::unique_ptr<Request> FetchOcsp(
99 const GURL& url, 77 const GURL& url,
100 int timeout_milliseconds, 78 int timeout_milliseconds,
101 int max_response_bytes, 79 int max_response_bytes) = 0;
102 const FetchCallback& callback) = 0;
103 80
104 private: 81 private:
105 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher); 82 DISALLOW_COPY_AND_ASSIGN(CertNetFetcher);
106 }; 83 };
107 84
108 } // namespace net 85 } // namespace net
109 86
110 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_ 87 #endif // NET_CERT_NET_CERT_NET_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698